* sc_prohibit_magic_number_exit false positive on string
@ 2019-09-08 12:56 Darshit Shah
2019-09-08 15:19 ` Jim Meyering
0 siblings, 1 reply; 3+ messages in thread
From: Darshit Shah @ 2019-09-08 12:56 UTC (permalink / raw)
To: bug-gnulib
[-- Attachment #1: Type: text/plain, Size: 680 bytes --]
I just realized that the syntax check rule sc_prohibit_magic_number_exit will
cause a false positive when it finds the relevant tokens within a string 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='exit \(77\)|error ?\(((0|77),|[^,]*)' \
+exclude='exit \(77\)|error ?\(((0|77),|[^,]*)|"(usage|exit|error).*"' \
--
Thanking You,
Darshit Shah
PGP Fingerprint: 7845 120B 07CB D8D6 ECE5 FF2B 2A17 43ED A91A 35B6
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 894 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: sc_prohibit_magic_number_exit false positive on string
2019-09-08 12:56 sc_prohibit_magic_number_exit false positive on string Darshit Shah
@ 2019-09-08 15:19 ` Jim Meyering
2019-09-11 16:23 ` Darshit Shah
0 siblings, 1 reply; 3+ messages in thread
From: Jim Meyering @ 2019-09-08 15:19 UTC (permalink / raw)
To: bug-gnulib@gnu.org List
On Sun, Sep 8, 2019 at 6:06 AM Darshit Shah <darnir@gnu.org> wrote:
> I just realized that the syntax check rule sc_prohibit_magic_number_exit will
> cause a false positive when it finds the relevant tokens within a string 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='exit \(77\)|error ?\(((0|77),|[^,]*)' \
> +exclude='exit \(77\)|error ?\(((0|77),|[^,]*)|"(usage|exit|error).*"' \
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:
exclude_file_name_regexp--sc_prohibit_magic_number_exit =
offending-file-regexp\.c$$
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: sc_prohibit_magic_number_exit false positive on string
2019-09-08 15:19 ` Jim Meyering
@ 2019-09-11 16:23 ` Darshit Shah
0 siblings, 0 replies; 3+ messages in thread
From: Darshit Shah @ 2019-09-11 16:23 UTC (permalink / raw)
To: Jim Meyering; +Cc: bug-gnulib@gnu.org List
[-- Attachment #1: Type: text/plain, Size: 1521 bytes --]
* Jim Meyering <jim@meyering.net> [190908 17:19]:
> On Sun, Sep 8, 2019 at 6:06 AM Darshit Shah <darnir@gnu.org> wrote:
> > I just realized that the syntax check rule sc_prohibit_magic_number_exit will
> > cause a false positive when it finds the relevant tokens within a string 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='exit \(77\)|error ?\(((0|77),|[^,]*)' \
> > +exclude='exit \(77\)|error ?\(((0|77),|[^,]*)|"(usage|exit|error).*"' \
>
> 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:
>
> exclude_file_name_regexp--sc_prohibit_magic_number_exit =
> 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 rules
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.
--
Thanking You,
Darshit Shah
PGP Fingerprint: 7845 120B 07CB D8D6 ECE5 FF2B 2A17 43ED A91A 35B6
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 894 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-09-11 16:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-08 12:56 sc_prohibit_magic_number_exit false positive on string Darshit Shah
2019-09-08 15:19 ` Jim Meyering
2019-09-11 16:23 ` Darshit Shah
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).