Re: BUG #18914: REDUNDANT_COMPARISON.ALWAYS_FALSE Redundant comparison '0' > 'nb' (0 > {4, 16}) is always false
Daniel Gustafsson <daniel@yesql.se>
From: Daniel Gustafsson <daniel@yesql.se>
To: gorcom2012@gmail.com,
pgsql-bugs@lists.postgresql.org
Date: 2025-05-07T10:35:30Z
Lists: pgsql-bugs
> On 7 May 2025, at 10:48, PG Bug reporting form <noreply@postgresql.org> wrote:
>
> The following bug has been logged on the website:
>
> Bug reference: 18914
> Logged by: Eugeny Goryachev
> Email address: gorcom2012@gmail.com
> PostgreSQL version: 17.4
> Operating system: Ubuntu
> Description:
>
> REDUNDANT_COMPARISON.ALWAYS_FALSE Redundant comparison '0' > 'nb' (0 > {4,
> 16}) is always false at network.c:282.
> The function 'network_send()' in src/backend/utils/adt/network.c contains a
> redundant comparison:
> if (nb < 0)
> nb = 0;
> Since 'nb' is set via 'ip_addrsize(addr)', which returns either 4 or 16 (for
> IPv4 and IPv6 addresses respectively), this condition can never be true.
This was already addressed in commit f27eb0325b7b2c.
If you are going to run a static analyzer you should make sure to run it
against HEAD as small things like this one aren't backported.
--
Daniel Gustafsson
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Remove useless check for negative result of ip_addrsize().
- f27eb0325b7b 18.0 cited