From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 33AF61F4B4 for ; Sat, 12 Sep 2020 23:11:04 +0000 (UTC) Received: from localhost ([::1]:48302 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kHEfe-0004uq-8g for normalperson@yhbt.net; Sat, 12 Sep 2020 19:11:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kHEfY-0004ui-66 for bug-gnulib@gnu.org; Sat, 12 Sep 2020 19:10:56 -0400 Received: from smtp2.cs.stanford.edu ([171.64.64.26]:55030) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kHEfW-0007Zi-F4 for bug-gnulib@gnu.org; Sat, 12 Sep 2020 19:10:55 -0400 Received: from 75-54-222-30.lightspeed.rdcyca.sbcglobal.net ([75.54.222.30]:54704 helo=sigxcpu.attlocal.net) by smtp2.cs.Stanford.EDU with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.3) (envelope-from ) id 1kHEfP-0006dv-6m; Sat, 12 Sep 2020 16:10:47 -0700 From: Ben Pfaff To: bug-gnulib@gnu.org, Jim Meyering , Simon Josefsson Subject: [PATCH] getpass: Do not check for nonnull prompt argument in Win32 implementation. Date: Sat, 12 Sep 2020 16:10:30 -0700 Message-Id: <20200912231030.2964126-1-blp@cs.stanford.edu> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scan-Signature: 3e263c829a24e9e508d860775f9d44fb Received-SPF: pass client-ip=171.64.64.26; envelope-from=blp@cs.stanford.edu; helo=smtp2.cs.Stanford.EDU X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/12 19:10:49 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ben Pfaff Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" 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 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