getpass: Check for nonnull prompt argument while avoiding warnings.
commit1e737bb51ffc7e75e56758fab3340a7abc4d8cd4
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 13 Sep 2020 18:59:53 +0000 (13 20:59 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 13 Sep 2020 19:00:58 +0000 (13 21:00 +0200)
treee36c0523f1c951e24395040c8b444777f4f206ff
parent4e14bef83b3c8096efebe343069baf13277337bc
getpass: Check for nonnull prompt argument while avoiding warnings.

The prompt parameter to getpass() is declared as nonnull (using a GCC
nonnull attribute).  Gnulib contains two implementations of this function,
one for POSIX, one for Windows.  The Windows implementation checked for
a nonnull prompt, which caused a GCC warning.  This commit fixes that by
avoiding the nonnull attribute when building getpass.c.  The POSIX
implementation did not check for a nonnull prompt.  This commit increases
the robustness by adding such a check.

* lib/getpass.c (_GL_ARG_NONNULL): Define to empty.
(getpass) [!_WIN32]: Print prompt only if nonnull.
ChangeLog
lib/getpass.c