All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <junio@pobox.com>
To: Luc Van Oostenryck <lucvoo@kernel.org>
Cc: Ramsay Jones <ramsay@ramsayjones.plus.com>,
	 Luc Van Oostenryck <luc.vanoostenryck@gmail.com>,
	 Sparse Mailing-list <linux-sparse@vger.kernel.org>
Subject: Re: sparse regex error
Date: Wed, 17 Jul 2024 11:44:13 -0700	[thread overview]
Message-ID: <xmqqzfqf270i.fsf@gitster.g> (raw)
In-Reply-To: <uug4xslokvlxr6z24q52z4pt7nrtiimbzunz2gz3kpilk4kxts@7jljsksi6baq> (Luc Van Oostenryck's message of "Thu, 21 Dec 2023 00:13:38 +0100")

Luc Van Oostenryck <lucvoo@kernel.org> writes:

>>   $ git diff
>>   diff --git a/validation/restrict-array.c b/validation/restrict-array.c
>>   index 04bfdad9..86753b7d 100644
>>   --- a/validation/restrict-array.c
>>   +++ b/validation/restrict-array.c
>>   @@ -29,9 +29,19 @@ typedef unsigned long int size_t;
>>    
>>    extern int regexec (const regex_t *__restrict __preg,
>>                       const char *__restrict __string, size_t __nmatch,
>>   -                   regmatch_t __pmatch[__restrict_arr],
>>   +                   regmatch_t __pmatch[__restrict_arr __nmatch],
>>                       int __eflags);
>
> ...    
>
>> which, similarly to git, shows errors not on the declaration of the
>> regexec() function, but on each call site (about a dozen in git):
>> 
>>   $ ./sparse validation/restrict-array.c
>>   validation/restrict-array.c:32:56: error: undefined identifier '__nmatch'
>>   validation/restrict-array.c:32:56: error: bad constant expression type
>
> Yes, it's because __nmatch should be in the function's prototype scope but
> Sparse hasn't such a thing.
>
> The following patch is a bit ugly but should solve the problem here above.
> It's hasn't had much testing, only the testsuite.

The same breakage came up recently on the Git mailing list.

  https://lore.kernel.org/git/xmqqikx42c42.fsf@gitster.g/

The patch seems to fix the problem when locally applyed to the tip
at v0.6.4-67-g3a4c5743 (of course we have to add -Wno-vla in our
Makefile when invoking sparse).

Any plan to polish it to "unugly" it and merge?

Thanks.



      parent reply	other threads:[~2024-07-17 18:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-20  0:18 sparse regex error Ramsay Jones
2023-12-20 23:13 ` Luc Van Oostenryck
2023-12-21  1:45   ` Ramsay Jones
2024-07-17 18:44   ` Junio C Hamano [this message]

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

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

  git send-email \
    --in-reply-to=xmqqzfqf270i.fsf@gitster.g \
    --to=junio@pobox.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=luc.vanoostenryck@gmail.com \
    --cc=lucvoo@kernel.org \
    --cc=ramsay@ramsayjones.plus.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.