Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pWjdv-0004Re-N3 for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Feb 2023 19:58:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pWjdu-0007qf-Gw for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Feb 2023 19:58:38 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pWjdu-0007qW-7i for pgsql-hackers@lists.postgresql.org; Mon, 27 Feb 2023 19:58:38 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pWjds-0008Ia-6Z for pgsql-hackers@postgresql.org; Mon, 27 Feb 2023 19:58:37 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 31RJwU8j412741; Mon, 27 Feb 2023 14:58:30 -0500 From: Tom Lane To: Melanie Plageman cc: Andres Freund , Kyotaro Horiguchi , vignesh21@gmail.com, pryzby@telsasoft.com, lukas@fittl.com, alvherre@alvh.no-ip.org, magnus@hagander.net, pgsql-hackers@postgresql.org, thomas.munro@gmail.com, m.sakrejda@gmail.com Subject: Re: pg_stat_bgwriter.buffers_backend is pretty meaningless (and more?) In-reply-to: References: <20230124.172203.448918351330829200.horikyota.ntt@gmail.com> <20230124223512.xqp7tjgqvzqokaxq@awork3.anarazel.de> <20230125.165617.724951472557617342.horikyota.ntt@gmail.com> <20230208063814.boyh5ibydbfuo2uk@awork3.anarazel.de> <20230209050319.chyyup4vtq4jzobq@awork3.anarazel.de> <20520.1677435600@sss.pgh.pa.us> <23770.1677437567@sss.pgh.pa.us> <354645.1677511842@sss.pgh.pa.us> Comments: In-reply-to Melanie Plageman message dated "Mon, 27 Feb 2023 14:03:16 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <412739.1677527910.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 27 Feb 2023 14:58:30 -0500 Message-ID: <412740.1677527910@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Melanie Plageman writes: > On Mon, Feb 27, 2023 at 10:30=E2=80=AFAM Tom Lane wr= ote: >> The risk of needing to cast when using the "int" loop variable >> as an enum is obviously the downside of that approach, but we have >> not seen any indication that any compilers actually do warn. >> It's interesting that you did see such a warning ... I wonder which >> compiler you were using at the time? > so, pretty much any version of clang I tried with > -Wsign-conversion produces a warning. > :35:32: warning: implicit conversion changes signedness: 'int' > to 'IOOp' (aka 'enum IOOp') [-Wsign-conversion] Oh, interesting --- so it's not about the implicit conversion to enum but just about signedness. I bet we could silence that by making the loop variables be "unsigned int". I doubt it's worth any extra keystrokes though, because we are not at all clean about sign-conversion warnings. I tried enabling -Wsign-conversion on Apple's clang 14.0.0 just now, and counted 13462 such warnings just in the core build :-(. I don't foresee anybody trying to clean that up. > I didn't do the casts in the attached patch since they aren't done elsew= here. Agreed. I'll push this along with the earlier patch if there are not objections. regards, tom lane