Re: Cleaning up pgcrypto/crypt-des.c to avoid compiler warnings

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Cleaning up pgcrypto/crypt-des.c to avoid compiler warnings
Date: 2026-09-25 19:18:36
Message-ID: 2012819.1790363916@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com> writes:
> On Fri, 25 Sept 2026 at 23:28, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> For some time now, buildfarm member serinus has been complaining
>> about pgcrypto/crypt-des.c:
>> ...
>> I think this odd coding, perhaps combined with all the cowboy casting
>> that's going on here, is what's confusing gcc into giving a warning.
>> I propose the attached patch to make this code less ugly and (with
>> luck) suppress the warning.

> Yeah I agree that it's pretty ugly.
> We had an open patch for that obscure loop earlier[1].
> (I'll close that commitfest item)

Oh! I'd missed that thread. Thank you for pointing me to it, because
I had been unable to reproduce the warning, but now I know that it's
necessary to use -O3 along with a recent gcc to see it. Armed with
that knowledge, I find that my patch does not suppress the warning :-(
I'll use this variant of your proposal instead:

for (size_t q = 0; q < lengthof(keybuf.bytes); q++)
{
keybuf.bytes[q] = *key << 1;
...

That does suppress the warning, at least with the gcc 16.2.1 that
I'm testing with.

Thanks for the review!

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-09-25 19:39:15 Re: Cleaning up pgcrypto/crypt-des.c to avoid compiler warnings
Previous Message Ayush Tiwari 2026-09-25 19:13:42 [PATCH] Table sync race with REFRESH PUBLICATION