bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] getpass: Do not check for nonnull prompt argument in Win32 imple


From: Ben Pfaff
Subject: [PATCH] getpass: Do not check for nonnull prompt argument in Win32 implementation.
Date: Sat, 12 Sep 2020 16:10:30 -0700

The prompt parameter to getpass() is declared as nonnull (using a GCC
nonnull attribute), but the implementation checks whether it is null in
two places.  GCC warns about this.  This commit removes the checks, which
don't appear in the Gnulib POSIX implementation or the glibc
implementation.
---
I haven't pushed this yet; I'm posting it for review.

2020-09-12  Ben Pfaff  <blp@cs.stanford.edu>

        Remove null checks for parameter declared as nonnull.
        * lib/getpass.c (getpass) [_WIN32]: Don't check whether 'prompt'
        argument is nonnull.

diff --git a/lib/getpass.c b/lib/getpass.c
index 3b0552ec58..f256bacdd8 100644
--- a/lib/getpass.c
+++ b/lib/getpass.c
@@ -194,11 +194,8 @@ getpass (const char *prompt)
   size_t i = 0;
   int c;
 
-  if (prompt)
-    {
-      fputs (prompt, stderr);
-      fflush (stderr);
-    }
+  fputs (prompt, stderr);
+  fflush (stderr);
 
   for (;;)
     {
@@ -220,11 +217,8 @@ getpass (const char *prompt)
         }
     }
 
-  if (prompt)
-    {
-      fputs ("\r\n", stderr);
-      fflush (stderr);
-    }
+  fputs ("\r\n", stderr);
+  fflush (stderr);
 
   return strdup (getpassbuf);
 }
-- 
2.28.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]