Silence uninitialized variable warning with some compiler versions

Heikki Linnakangas <heikki.linnakangas@iki.fi>

Commit: f29299c42b0b7877db0c339147d95524be69b4e6
Author: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: 2026-06-17T06:00:49Z
Silence uninitialized variable warning with some compiler versions

The first "if (difffile)" block initializes the startpos variable, and
the second "if (difffile)" block reads it. The second if-condition can
only be true when the first one was true, so the startpos variable is
always initialized when it's used. However, the compiler might not be
able to deduce that, and warn about startpos being used uninitialized.

To silence the warning, rearrange the if-checks. Also, bail out if the
diff file cannot be opened, instead of ignoring it silently.

Author: Mikhail Litsarev <m.litsarev@postgrespro.ru>
Reviewed-by; Ewan Young <kdbase.hack@gmail.com>
Discussion: https://www.postgresql.org/message-id/ee06f058c626cd37babd8c81579ffb1e@postgrespro.ru

Files

PathChange+/−
src/test/regress/pg_regress.c modified +24 −22

Discussion