Re: Re: [COMMITTERS] pgsql: Fix blatantly uninitialized variable in recent commit.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: "Simon Riggs" <simon(at)2ndQuadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: [COMMITTERS] pgsql: Fix blatantly uninitialized variable in recent commit.
Date: 2011-02-17 16:26:35
Message-ID: 8847.1297959995@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

"Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov> writes:
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> It might be worth trying to clean up those warn_unused_result
>> things, if other people are seeing those.

> elog.c: In function *write_console*:
> elog.c:1708: warning: ignoring return value of *write*, declared
> with attribute warn_unused_result
> elog.c: In function *write_pipe_chunks*:
> elog.c:2401: warning: ignoring return value of *write*, declared
> with attribute warn_unused_result
> elog.c:2410: warning: ignoring return value of *write*, declared
> with attribute warn_unused_result
> --
> common.c: In function *handle_sigint*:
> common.c:247: warning: ignoring return value of *write*, declared
> with attribute warn_unused_result
> common.c:250: warning: ignoring return value of *write*, declared
> with attribute warn_unused_result
> common.c:251: warning: ignoring return value of *write*, declared
> with attribute warn_unused_result

In at least some of these cases, I think ignoring the write() result
is intentional, because there's really nothing useful we can do about
it if it fails (oh, you wish we'd log a failure to write to the log?).
Would you check whether just casting the function result to (void)
shuts it up?

> option.c: In function *parseCommandLine*:
> option.c:92: warning: ignoring return value of *getcwd*, declared
> with attribute warn_unused_result
> option.c: In function *get_pkglibdir*:
> option.c:336: warning: ignoring return value of *fgets*, declared
> with attribute warn_unused_result

These look like they probably are genuine bugs, or if not bugs at least
the kind of sloppy coding the warning is meant to catch.

regards, tom lane

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Kevin Grittner 2011-02-17 16:38:49 Re: Re: [COMMITTERS] pgsql: Fix blatantly uninitialized variable in recent commit.
Previous Message Kevin Grittner 2011-02-17 16:18:23 Re: Re: [COMMITTERS] pgsql: Fix blatantly uninitialized variable in recent commit.

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2011-02-17 16:28:19 Re: Debian readline/libedit breakage
Previous Message Bruce Momjian 2011-02-17 16:24:46 Re: Debian readline/libedit breakage