pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nathan Bossart <nathandbossart@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: Cleaning up pgcrypto/crypt-des.c to avoid compiler warnings
Date: Fri, 25 Sep 2026 13:54:58 -0500
Message-ID: <arbDghG1ccMXTSZH@nathan> (raw)
In-Reply-To: <2005885.1790359097@sss.pgh.pa.us>
References: <2005885.1790359097@sss.pgh.pa.us>

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






view thread (5+ messages)  latest in thread

Message-ID: <arbDghG1ccMXTSZH@nathan>
Permalink:  ../arbDghG1ccMXTSZH@nathan/
Also on:    postgresql.org/message-id/arbDghG1ccMXTSZH@nathan

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: nathandbossart@gmail.com, tgl@sss.pgh.pa.us
  Subject: Re: Cleaning up pgcrypto/crypt-des.c to avoid compiler warnings
  In-Reply-To: <arbDghG1ccMXTSZH@nathan>
  References: <2005885.1790359097@sss.pgh.pa.us> <arbDghG1ccMXTSZH@nathan>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox