From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Turn 'if' condition around to avoid Svace complaint
Date: Wed, 25 Sep 2024 14:47:28 +0000
Message-ID: <E1stTIe-000r50-8L@gemulon.postgresql.org> (raw)
Turn 'if' condition around to avoid Svace complaint
The unwritten assumption of this code is that both events->head and
events->tail are NULL together (an empty list) or they aren't. So the
code was testing events->head for nullness and using that as a cue to
deference events->tail, which annoys the Svace static code analyzer.
We can silence it by testing events->tail member instead, and add an
assertion about events->head to ensure it's all consistent.
This code is very old and as far as we know, there's never been a bug
report related to this, so there's no need to backpatch.
This was found by the ALT Linux Team using Svace.
Author: Alexander Kuznetsov <kuznetsovam@altlinux.org>
Discussion: https://postgr.es/m/6d0323c3-3f5d-4137-af73-98a5ab90e77c@altlinux.org
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/dce507356a4ab7d548dca9d7abf1800a0fc0a18e
Modified Files
--------------
src/backend/commands/trigger.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
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 using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: alvherre@alvh.no-ip.org, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Turn 'if' condition around to avoid Svace complaint
In-Reply-To: <E1stTIe-000r50-8L@gemulon.postgresql.org>
* 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