From unknown Mon Aug 18 14:23:42 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#15634 <15634@debbugs.gnu.org> To: bug#15634 <15634@debbugs.gnu.org> Subject: Status: coreutils-8.21 possible coding error ? Reply-To: bug#15634 <15634@debbugs.gnu.org> Date: Mon, 18 Aug 2025 21:23:42 +0000 retitle 15634 coreutils-8.21 possible coding error ? reassign 15634 coreutils submitter 15634 David Binderman severity 15634 normal tag 15634 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 17 03:54:07 2013 Received: (at submit) by debbugs.gnu.org; 17 Oct 2013 07:54:07 +0000 Received: from localhost ([127.0.0.1]:54993 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VWiPF-00052c-FD for submit@debbugs.gnu.org; Thu, 17 Oct 2013 03:54:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41902) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VWiPB-000522-Ql for submit@debbugs.gnu.org; Thu, 17 Oct 2013 03:54:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VWiOx-0001oA-4Y for submit@debbugs.gnu.org; Thu, 17 Oct 2013 03:53:56 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: *** X-Spam-Status: No, score=3.6 required=5.0 tests=BAYES_50, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RECEIVED_FROM_WINDOWS_HOST autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:56843) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWiOx-0001o6-1L for submit@debbugs.gnu.org; Thu, 17 Oct 2013 03:53:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWiOp-0000Ig-Nm for bug-coreutils@gnu.org; Thu, 17 Oct 2013 03:53:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VWiOi-0001m4-Ds for bug-coreutils@gnu.org; Thu, 17 Oct 2013 03:53:39 -0400 Received: from dub0-omc3-s4.dub0.hotmail.com ([157.55.2.13]:61815) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWiOi-0001lt-7u for bug-coreutils@gnu.org; Thu, 17 Oct 2013 03:53:32 -0400 Received: from DUB118-W42 ([157.55.2.7]) by dub0-omc3-s4.dub0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 17 Oct 2013 00:33:34 -0700 X-TMN: [pOpMT7osttUonnsuFcz41kw7bY7H7DH0] X-Originating-Email: [dcb314@hotmail.com] Message-ID: From: David Binderman To: "bug-coreutils@gnu.org" Subject: coreutils-8.21 possible coding error ? Date: Thu, 17 Oct 2013 07:33:33 +0000 Importance: Normal Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginalArrivalTime: 17 Oct 2013 07:33:34.0109 (UTC) FILETIME=[2F6D3CD0:01CECB0B] X-detected-operating-system: by eggs.gnu.org: Windows XP X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -3.8 (---) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.8 (---) Hello there=2C=0A= =0A= I just ran the static analysis tool cppcheck over the source code=0A= of coreutils-8.21=0A= =0A= It said many things=2C including=0A= =0A= [src/dircolors.c:445]: (warning) Comparison of a boolean value using relati= onal operator (<=2C>=2C <=3D or>=3D).=0A= =0A= Source code is=0A= =0A= =A0 if (!print_database < argc)=0A= =0A= Some round brackets might help clarify the code=0A= =0A= =A0 if ((!print_database) < argc)=0A= =0A= or was perhaps=0A= =0A= =A0 if (!(print_database < argc))=0A= =0A= intended ? Here are some other things cppcheck found.=0A= =0A= [lib/mountlist.c:945]: (error) Resource leak: dirp=0A= [lib/sig2str.c:329]: (warning) Logical conjunction always evaluates to fals= e: signum <=3D -1 && signum>=3D 0.=0A= [lib/closein.c:91]: (error) fflush() called on input stream 'stdin' results= in undefined behaviour.=0A= =0A= Regards=0A= =0A= David Binderman = From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 17 07:19:51 2013 Received: (at 15634) by debbugs.gnu.org; 17 Oct 2013 11:19:51 +0000 Received: from localhost ([127.0.0.1]:55072 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VWlcM-0001kN-8F for submit@debbugs.gnu.org; Thu, 17 Oct 2013 07:19:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15628) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VWlcI-0001kD-CW for 15634@debbugs.gnu.org; Thu, 17 Oct 2013 07:19:48 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9HBJjdL022945 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 17 Oct 2013 07:19:45 -0400 Received: from [10.3.113.38] (ovpn-113-38.phx2.redhat.com [10.3.113.38]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r9HBJiMb000980; Thu, 17 Oct 2013 07:19:44 -0400 Message-ID: <525FC7D0.4010307@redhat.com> Date: Thu, 17 Oct 2013 05:19:44 -0600 From: Eric Blake Organization: Red Hat, Inc. User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: David Binderman , 15634@debbugs.gnu.org Subject: Re: bug#15634: coreutils-8.21 possible coding error ? References: In-Reply-To: X-Enigmail-Version: 1.6 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="kghnMGEvMeVXuTWW2Ku9JddTELnncK4RT" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-Spam-Score: -5.4 (-----) X-Debbugs-Envelope-To: 15634 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.4 (-----) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --kghnMGEvMeVXuTWW2Ku9JddTELnncK4RT Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 10/17/2013 01:33 AM, David Binderman wrote: > Hello there, >=20 > I just ran the static analysis tool cppcheck over the source code > of coreutils-8.21 Thanks for reporting that. >=20 > It said many things, including >=20 > [src/dircolors.c:445]: (warning) Comparison of a boolean value using re= lational operator (<,>, <=3D or>=3D). >=20 > Source code is >=20 > if (!print_database < argc) >=20 > Some round brackets might help clarify the code >=20 > if ((!print_database) < argc) This is the intended form; gcc doesn't warn about the precedence, but silencing cppcheck may be worth it. >=20 > or was perhaps >=20 > if (!(print_database < argc)) >=20 > intended ? Here are some other things cppcheck found. >=20 > [lib/mountlist.c:945]: (error) Resource leak: dirp This one has already been fixed in gnulib (commit 98171ec); it will be fixed in coreutils the next time coreutils updates to latest gnulib. > [lib/sig2str.c:329]: (warning) Logical conjunction always evaluates to = false: signum <=3D -1 && signum>=3D 0. Line 329 is: if (! (rtmin <=3D signum && signum <=3D rtmax)) with rtmin set to SIGRTMIN. I'm not sure I follow how the error message is claiming we are comparing signum <=3D -1. Bug in cppcheck? > [lib/closein.c:91]: (error) fflush() called on input stream 'stdin' res= ults in undefined behaviour. Bug in cppcheck. Calling fflush(stdin) IS defined behavior, if stdin is seekable (which the code prior to that line guaranteed). POSIX 2013 explicitly says so: http://pubs.opengroup.org/onlinepubs/9699919799/functions/fflush.html [CX] [Option Start] For a stream open for reading, if the file is not already at EOF, and the file is one capable of seeking, the file offset of the underlying open file description shall be set to the file position of the stream, and any characters pushed back onto the stream by ungetc() or ungetwc() that have not subsequently been read from the stream shall be discarded (without further changing the file offset). [Option End] --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --kghnMGEvMeVXuTWW2Ku9JddTELnncK4RT Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSX8fQAAoJEKeha0olJ0Nq6JkH/iDa3tgfKOpxI1YZYZ47NR/E fCIDpElJ9dpto6opB/gfIFaM7Drj/zUip0OR0BxoSLInEWu7iNSAgo4usCSu+oN4 gcOQDhVPTLoOdnVsqg8Fz7TaawtipQsPCzNo3fZu4JmtApaq7Kt/PgLFZc+pHNFE +gKJl8mHDQR82uAS+JtIxl94u4hjdKLleP1QUBEz1Z/cshbnuRSvrzFQJwcHtxXz Aib+e58oU6tNDDsIKGNPVVo0Q7gH4NTaqjMs5Ef0Z8Td6DyJWNGCVRxOlqFqTG+k e6FgH7xjiHILLLNJt4yIsh7l4ICDCb0V7+RmDtytBMLFhwx2Ecu6dnpU7mUxNkQ= =TKI/ -----END PGP SIGNATURE----- --kghnMGEvMeVXuTWW2Ku9JddTELnncK4RT-- From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 17 10:10:04 2013 Received: (at 15634) by debbugs.gnu.org; 17 Oct 2013 14:10:04 +0000 Received: from localhost ([127.0.0.1]:55596 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VWoH3-0006oh-Th for submit@debbugs.gnu.org; Thu, 17 Oct 2013 10:10:03 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:55538) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VWoH1-0006oH-4E for 15634@debbugs.gnu.org; Thu, 17 Oct 2013 10:10:00 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 2C6FB39E810A; Thu, 17 Oct 2013 07:09:53 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bYjmyvaB8SwU; Thu, 17 Oct 2013 07:09:52 -0700 (PDT) Received: from [192.168.1.9] (pool-108-0-233-62.lsanca.fios.verizon.net [108.0.233.62]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id A50F039E8100; Thu, 17 Oct 2013 07:09:52 -0700 (PDT) Message-ID: <525FEFAC.8000404@cs.ucla.edu> Date: Thu, 17 Oct 2013 07:09:48 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: David Binderman , 15634@debbugs.gnu.org Subject: Re: bug#15634: coreutils-8.21 possible coding error ? References: In-Reply-To: X-Enigmail-Version: 1.5.2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 15634 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.7 (--) David Binderman wrote: > [lib/sig2str.c:329]: (warning) Logical conjunction always evaluates to false: signum <= -1 && signum>= 0. This seems to be cppcheck complaining about a test that is needed on other platforms, but which the compiler can optimize away on your platform. We can safely ignore this diagnostic as well: it's perfectly OK, and in fact nice, to have code that a compiler can optimize away on some platforms. > if (!print_database < argc) > > Some round brackets might help clarify the code > > if ((!print_database) < argc) The code's pretty clear as-is, since there are spaces around the " < " but not after the "!". I think I'd rather ignore this diagnostic; in general, "Comparison of a boolean value using relational operator (<,>, <= or>=)" is bogus. There's nothing wrong with comparing Booleans. If you have two Booleans A and B, and want to write "A implies B", it's often faster and (once you get used to it) more comprehensible to write "A <= B", instead of the "!A | B" that cppcheck would seem to require. (Admittedly I'd rather write "A -> B" but this is C we're talking about....) Eric already covered the other two diagnostics you mentioned. From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 11 18:15:48 2018 Received: (at control) by debbugs.gnu.org; 11 Oct 2018 22:15:48 +0000 Received: from localhost ([127.0.0.1]:45654 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gAjFE-0002PD-5i for submit@debbugs.gnu.org; Thu, 11 Oct 2018 18:15:48 -0400 Received: from mail-pf1-f181.google.com ([209.85.210.181]:39391) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gAjFC-0002Ow-D5 for control@debbugs.gnu.org; Thu, 11 Oct 2018 18:15:46 -0400 Received: by mail-pf1-f181.google.com with SMTP id c25-v6so5102440pfe.6 for ; Thu, 11 Oct 2018 15:15:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:message-id:date:user-agent:mime-version:content-language :content-transfer-encoding; bh=aCMPf+7kyoxN+rBTekFZz3oWrRjDvMuc6vTuYT21Ayk=; b=jQSTj1oIOh/kU+0QgvVa9jAf+WwO4i158LaHlPg5KcDpTdIIMVsexf46xGQWHnYLM8 +zReHcVThWS5DKY2PtiaYQGoq0/qHoDTNNNQ7BTSHUqQwf5HTyh5a6RobQNQugQFtydJ Rt2cbxuXfVQHEozp/uVR62CVqhNPR6aaaYGnlGU20ZoIjt4uN5rnGh2BcOMDV5upRjvo 6dwGWMSXjJC8ddSe+KJfFeLw6KnDTzBrUeAiZj247qIw5PooKZAmz9jkgQfx2LmRWPJC 98xDJquUSuqjjWj758gJwUlPLaWqlEn+H43oIvxpqV7epCT+uuams8HD7MkjZy1uo3/8 nwXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=aCMPf+7kyoxN+rBTekFZz3oWrRjDvMuc6vTuYT21Ayk=; b=XAcJmAEOey9bb2WzHT6+srgmRjRzR4cDJbuTkbhLNQxG/XSET2F5+c/jjtle2ISd0V YsQW4UwM1Z1NbdhHaf5HYWoZ0bZ6A7oO7bzRAWXn4000cNozruOCjhAqqpwg2RAkePfP CboI+2L8zn9621bO6EApDM3/7ZZVOJt7Ca3HO7PZ4EXgZXAorXCKS93G/O64ggjklOud 3XKuBNBnYabnsHdE00C3fOPEUO9WVB+MFDzrf7X37xHyNiFxeTz24yLJJxTZ5gEYlMWQ s0j/PGkwzaDWVWEWjs5iKC2GQvuq9P92h+5Y5lCllSnlj8/pChugcBAQtQhPz3RZnIbG h/8A== X-Gm-Message-State: ABuFfogJB04BZVDOwb0VfdxCQKygSQpusXbFwqFvlObU9/zrOBl+BIHK lIYX2UAUTb546doifRv5Qh/++IfM X-Google-Smtp-Source: ACcGV63/p1ZxnixeZlKyAhWdRojntCOIqhMBML/uGDJBsBc9xOlhDy1myTnczOQ7SPvTJ1b7zRMyWA== X-Received: by 2002:a62:3384:: with SMTP id z126-v6mr3277051pfz.85.1539296139769; Thu, 11 Oct 2018 15:15:39 -0700 (PDT) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id t15-v6sm66768319pfj.7.2018.10.11.15.15.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Oct 2018 15:15:38 -0700 (PDT) To: control@debbugs.gnu.org From: Assaf Gordon Message-ID: Date: Thu, 11 Oct 2018 16:15:36 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: tags 15308 notabug close 15308 tags 15634 notabug close 15634 tags 16004 notabug severity 16004 wishlist close 16004 [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (assafgordon[at]gmail.com) -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.210.181 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.210.181 listed in wl.mailspike.net] 1.8 MISSING_SUBJECT Missing Subject: header 0.2 NO_SUBJECT Extra score for no subject 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) tags 15308 notabug close 15308 tags 15634 notabug close 15634 tags 16004 notabug severity 16004 wishlist close 16004 tags 16245 notabug close 16245 tags 16249 notabug close 16249 tags 16249 notabug close 16249 close 16309 tags 16468 notabug close 16468 tag 16530 notabug close 16530 tags 16718 notabug close 16718 tags 16742 +moreinfo close 16742 tags 16831 wontfix close 16831 tags 16838 wontfix close 16838 tags 16872 fixed close 16872 close 16945 close 17224 tags 17503 + notabug close 17503 close 17546 tags 17904 notabug close 17904 From unknown Mon Aug 18 14:23:42 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 09 Nov 2018 12:24:07 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator