Re: Cleaning up pgcrypto/crypt-des.c to avoid compiler warnings - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Cleaning up pgcrypto/crypt-des.c to avoid compiler warnings
Date
Msg-id 2012819.1790363916@sss.pgh.pa.us
Whole thread
In response to Re: Cleaning up pgcrypto/crypt-des.c to avoid compiler warnings  (Ayush Tiwari <ayushtiwari.slg01@gmail.com>)
List pgsql-hackers
Ayush Tiwari <ayushtiwari.slg01@gmail.com> writes:
> On Fri, 25 Sept 2026 at 23:28, Tom Lane <tgl@sss.pgh.pa.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



pgsql-hackers by date:

Previous
From: Ayush Tiwari
Date:
Subject: [PATCH] Table sync race with REFRESH PUBLICATION
Next
From: Tom Lane
Date:
Subject: Re: Cleaning up pgcrypto/crypt-des.c to avoid compiler warnings