warning in pg_upgrade

Started by Kevin Grittnerover 14 years ago4 messageshackers
Jump to latest
#1Kevin Grittner
Kevin.Grittner@wicourts.gov

I just noticed a warning in pg_upgrade:

option.c: In function *parseCommandLine*:
option.c:96:8: warning: ignoring return value of *getcwd*,
declared
with attribute warn_unused_result

It looks like it might be worth testing the return value here for
NULL, which would indicate an error accessing the current working
directory. Untested patch attached for purposes of discussion.

http://www.kernel.org/doc/man-pages/online/pages/man3/getcwd.3.html

-Kevin

Attachments:

getcwd-return-value.patchtext/plain; name=getcwd-return-value.patchDownload+5-4
#2Kevin Grittner
Kevin.Grittner@wicourts.gov
In reply to: Kevin Grittner (#1)
Re: warning in pg_upgrade

"Kevin Grittner" <Kevin.Grittner@wicourts.gov> wrote:

Untested patch attached for purposes of discussion.

I got in a little testing on it -- not only does this patch
eliminate the compile-time warning, but if you try to run pg_upgrade
when another session has removed your current working directory, you
get a reasonable message instead of the program attempting to
proceed with undefined (potential garbage) for a working directory.

-Kevin

#3Robert Haas
robertmhaas@gmail.com
In reply to: Kevin Grittner (#2)
Re: warning in pg_upgrade

On Thu, Nov 3, 2011 at 3:45 PM, Kevin Grittner
<Kevin.Grittner@wicourts.gov> wrote:

"Kevin Grittner" <Kevin.Grittner@wicourts.gov> wrote:

Untested patch attached for purposes of discussion.

I got in a little testing on it -- not only does this patch
eliminate the compile-time warning, but if you try to run pg_upgrade
when another session has removed your current working directory, you
get a reasonable message instead of the program attempting to
proceed with undefined (potential garbage) for a working directory.

Committed. Also fixed another compiler warning that popped up for me.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

#4Bruce Momjian
bruce@momjian.us
In reply to: Robert Haas (#3)
Re: warning in pg_upgrade

Robert Haas wrote:

On Thu, Nov 3, 2011 at 3:45 PM, Kevin Grittner
<Kevin.Grittner@wicourts.gov> wrote:

"Kevin Grittner" <Kevin.Grittner@wicourts.gov> wrote:

Untested patch attached for purposes of discussion.

I got in a little testing on it -- not only does this patch
eliminate the compile-time warning, but if you try to run pg_upgrade
when another session has removed your current working directory, you
get a reasonable message instead of the program attempting to
proceed with undefined (potential garbage) for a working directory.

Committed. Also fixed another compiler warning that popped up for me.

Thanks Kevin and Robert.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +