| From: | Andres Freund <andres(at)anarazel(dot)de> |
|---|---|
| To: | Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: [REPORT] Static analys warnings |
| Date: | 2020-05-03 21:20:12 |
| Message-ID: | 20200503212012.penuxcee6btvw5be@alap3.anarazel.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 2020-05-03 17:05:54 -0300, Ranier Vilela wrote:
> 1. Warning: the right operand to | always evaluates to 0
>
> src/include/storage/bufpage.h
> #define PAI_OVERWRITE (1 << 0)
> #define PAI_IS_HEAP (1 << 1)
>
> #define PageAddItem(page, item, size, offsetNumber, overwrite, is_heap) \
> PageAddItemExtended(page, item, size, offsetNumber, \
> ((overwrite) ? PAI_OVERWRITE : 0) | \
> ((is_heap) ? PAI_IS_HEAP : 0))
>
> Typo | should be ||:
> ((overwrite) ? PAI_OVERWRITE : 0) || \
> ((is_heap) ? PAI_IS_HEAP : 0))
Definitely not. PageAddItemExtended's flags argument is not a boolean,
it's a flag bitmask. It'd entirely break the semantics to make the
change you suggest.
Nor do I know what this warning is about, because clearly in the general
case the right argument to the | does not generally evaluate to 0. I
guess this about a particular use of the macro (with a constant
argument), rather than the macro itself.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2020-05-04 00:20:07 | Re: Should program exit, When close() failed for O_RDONLY mode |
| Previous Message | Ranier Vilela | 2020-05-03 20:05:54 | [REPORT] Static analys warnings |