Re: [PATCH] gcc warning 'expression which evaluates to zero treated as a null pointer'

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: didier <did447(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] gcc warning 'expression which evaluates to zero treated as a null pointer'
Date: 2019-11-13 19:52:48
Message-ID: 11678.1573674768@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

didier <did447(at)gmail(dot)com> writes:
> Trivial patch:
> - remove a gcc warning (since commit 7a0574b5)
> expression which evaluates to zero treated as a null pointer constant of
> type 'HeapTuple' (aka 'struct HeapTupleData *')

Hmm, the initializations "HeapTuple newtuple = false" are certainly
bogus-looking and not per project style; I wonder who's to blame for
those? (I do not see what 7a0574b5 would have had to do with it;
that didn't affect any backend code.)

> - always use "if (newtuple == NULL)" rather than mixing !newtuple and
> newtuple == NULL

Don't particularly agree with these changes though. "if (!ptr)" is
a very common C idiom, and no programmer would tolerate a compiler
that warned about it.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Fetter 2019-11-13 19:57:04 Re: Invisible PROMPT2
Previous Message Peter Geoghegan 2019-11-13 19:51:18 Re: [HACKERS] [WIP] Effective storage of duplicates in B-tree index.