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-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,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 CA8E31F463 for ; Wed, 11 Sep 2019 16:23:12 +0000 (UTC) Received: from localhost ([::1]:53522 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i85Oh-0003aA-BJ for normalperson@yhbt.net; Wed, 11 Sep 2019 12:23:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38247) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i85Oc-0003X9-BQ for bug-gnulib@gnu.org; Wed, 11 Sep 2019 12:23:07 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:47973) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1i85Ob-0001MU-SA; Wed, 11 Sep 2019 12:23:05 -0400 Received: from [2a02:8071:2cc2:ca00:f276:1cff:fe69:ac2c] (port=45486 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1i85Ob-0005WR-Do; Wed, 11 Sep 2019 12:23:05 -0400 Date: Wed, 11 Sep 2019 18:23:04 +0200 From: Darshit Shah To: Jim Meyering Subject: Re: sc_prohibit_magic_number_exit false positive on string Message-ID: <20190911162303.jgqqju6qzl3vjocp@tardis.localdomain> Mail-Followup-To: Jim Meyering , "bug-gnulib@gnu.org List" References: <20190908125619.qabhrayjeeium3du@tardis.localdomain> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ecjxro24bfo2vj3v" Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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: "bug-gnulib@gnu.org List" Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" --ecjxro24bfo2vj3v Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Jim Meyering [190908 17:19]: > On Sun, Sep 8, 2019 at 6:06 AM Darshit Shah wrote: > > I just realized that the syntax check rule sc_prohibit_magic_number_exi= t will > > cause a false positive when it finds the relevant tokens within a strin= g as > > well. > > > > For example, in Wget, we have the following snippet in our tests which = trips > > this rule: > > > > > WGET_TEST_EXPECTED_FILES, &(wget_test_file_t []) { > > > { "exit-status.txt", "exit(8)\n" }, > > > { NULL } }, > > > > I made a very tiny change to the rule in maint.mk(L408) to account for = this: > > > > -exclude=3D'exit \(77\)|error ?\(((0|77),|[^,]*)' \ > > +exclude=3D'exit \(77\)|error ?\(((0|77),|[^,]*)|"(usage|exit|error).*"= ' \ >=20 > Hi Darshit, that feels a little too specific. > Did you consider exempting that file from this one check? > You can do that by adding a line like the following to cfg.mk: >=20 > exclude_file_name_regexp--sc_prohibit_magic_number_exit =3D > offending-file-regexp\.c$$ I agree that my solution is a little too specific. I did not intend for it = to be applied as-is. However, I think it makes sense that the syntax-check rul= es check to make sure that the token is not found within a string. Ideally, you'd update the except regex like I did to check if it's a string literal, a comment or multi-line variants of those. --=20 Thanking You, Darshit Shah PGP Fingerprint: 7845 120B 07CB D8D6 ECE5 FF2B 2A17 43ED A91A 35B6 --ecjxro24bfo2vj3v Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJgBAABCgBKFiEEa5j2N9h5xSNuJ3xcZP+QqujHCvkFAl15H1UsFIAAAAAAFQAO cGthLWFkZHJlc3NAZ251cGcub3JnZGFybmlyQGdudS5vcmcACgkQZP+QqujHCvld vQ/+LzUK/BrXWYunNg5TX6fUsyCz2zVAEbc7scYsT0DQi6E+xZdxxnV480wlQYCe qVMu+XEW0mBp6AOwPZa+S69WentXHiTPL4o1w/izKA7heb3iJew8m5b9BCr2Mu4P MbpWpwEczSnotGy3i5El3Gz7//0hPOu/Y1Sc8DJQfGLLT3rhRiMPXD3ntwgJTV40 6di4ZoLAEfS1vYSyJEJPFaZwp5NX9mei5veElNuDDg0YAj7aDJfQlBIhZCrYQPK9 yvnCRAGRvVKZBa0Jg7Z2Pi814C6pjXHtAEasbus5IdqPMHm2CKo7oywGlVG8P752 lUmt0ZA86WrPBl+Vx6layMaGGBJtdXFQQbu8KuRwn05ak4bh2XcVjlXzFd+mbGbQ LiDiNleNkrHCvDdgWwD/YAcjKeWEwe2erRxxKkNukj4lcorXiO7S+4G2IbTWhFrs aQsSyvPeunrdCGtL2Mfvr/Hkydq3ddo8MaS2RgWG1FniH5bwMN018ymlqPS7ihGo 4TnYSmcGoK6LrPxICyvmQvM+0DRajyb/ythSRJjUKDi+d0QOlDmGa9bi7u/nmW7q Rz/vFrJCXILOwgnDcekkmm6VTecmAd67aj3O3Bsy5vYLD3GXRccbIYo8Fn3F7v9K 3J6S9G0vpQLay8i27flD1YRXSzqTMrEEVRy8K0B6djr/1BA= =JikO -----END PGP SIGNATURE----- --ecjxro24bfo2vj3v--