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

From Nathan Bossart
Subject Re: Cleaning up pgcrypto/crypt-des.c to avoid compiler warnings
Date
Msg-id arbDghG1ccMXTSZH@nathan
Whole thread
In response to Cleaning up pgcrypto/crypt-des.c to avoid compiler warnings  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Cleaning up pgcrypto/crypt-des.c to avoid compiler warnings
List pgsql-hackers
On Fri, Sep 25, 2026 at 01:58:17PM -0400, Tom Lane wrote:
> 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.

Getting rid of the "q" variable altogether might have a better chance of
clearing the warnings, and IMHO it further improves readability:

> +    q = &keybuf.bytes[0];
> +    while (q < &keybuf.bytes[8])
>      {
>          *q++ = *key << 1;

    for (i = 0; i < 8; i++)
    {
        keybuf.bytes[i] = *key << 1;

> +            q = &keybuf.bytes[0];
> +            while (q < &keybuf.bytes[8] && *key)
>                  *q++ ^= *key++ << 1;

    for (i = 0; i < 8 && *key; i++)
        keybuf.bytes[i] ^= *key++ << 1;

-- 
nathan



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [PATCH] btree_gist: add cross-type integer operator support for GiST
Next
From: Ayush Tiwari
Date:
Subject: [PATCH] Table sync race with REFRESH PUBLICATION