Re: Wrong dead return value in jsonb_utils.c - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Wrong dead return value in jsonb_utils.c
Date
Msg-id 20190512090738.GB2120@paquier.xyz
Whole thread Raw
In response to Wrong dead return value in jsonb_utils.c  (Rikard Falkeborn <rikard.falkeborn@gmail.com>)
Responses Re: Wrong dead return value in jsonb_utils.c
List pgsql-hackers
On Sun, May 12, 2019 at 03:18:08AM +0200, Rikard Falkeborn wrote:
> Returning -1 from a function with bool as return value is the same as
> returning true. Now, the code is dead (since elog(ERROR, ...) does not
> return) so it doesn't matter to the compiler, but changing to false is less
> confusing for the programmer. Appologies if this is seen as unnecessary
> churn.
>
> The same code is present since 9.4, but perhaps it's not really worth
> backporting since it is more of an aesthetic change?

This is an aesthetic change in the fact that elog(ERROR) would not
cause -1 to be returned, still I agree that it is cleaner to do things
the way your patch does.  And the origin of the issue is I think that
the code of equalsJsonbScalarValue() has been copy-pasted from
compareJsonbScalarValue().

As that's really cosmetic, I would just change that on HEAD, or
perhaps others feel differently?
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Fabien COELHO
Date:
Subject: make libpq documentation navigable between functions
Next
From: Julien Rouhaud
Date:
Subject: cleanup & refactoring on reindexdb.c