bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Ben Pfaff <blp@cs.stanford.edu>
To: bug-gnulib@gnu.org, Jim Meyering <jim@meyering.net>,
	Simon Josefsson <simon@josefsson.org>
Cc: Ben Pfaff <blp@cs.stanford.edu>
Subject: [PATCH] getpass: Do not check for nonnull prompt argument in Win32 implementation.
Date: Sat, 12 Sep 2020 16:10:30 -0700	[thread overview]
Message-ID: <20200912231030.2964126-1-blp@cs.stanford.edu> (raw)

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	other threads:[~2020-09-12 23:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-12 23:10 Ben Pfaff [this message]
2020-09-13  8:32 ` [PATCH] getpass: Do not check for nonnull prompt argument in Win32 implementation Bruno Haible
2020-09-13 18:10   ` Ben Pfaff
2020-09-13 19:05     ` Bruno Haible
2020-09-13 19:22       ` Ben Pfaff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200912231030.2964126-1-blp@cs.stanford.edu \
    --to=blp@cs.stanford.edu \
    --cc=bug-gnulib@gnu.org \
    --cc=jim@meyering.net \
    --cc=simon@josefsson.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).