Re: [PATCH] sparse/pre-process: introduce "dissect_mode" option to fix dissect/semind

Oleg Nesterov <[email protected]> Sat, 17 Jan 2026 17:32:03 +0100
Newsgroups org.kernel.vger.linux-sparse
Message-ID <[email protected]>
On 01/17, Oleg Nesterov wrote:
>
> Agreed! This was my plan B ;)
>
> With this change
>
> 	-               if (!dissect_mode) {
> 	+               if (preprocess_only) {
>
> make check reports 2 failures
>
> 	-parsing/attr-cleanup.c:10:17: error: argument is not an identifier
> 	+parsing/attr-cleanup.c:10:27: error: argument is not an identifier
>
> 	-sizeof-void.c:20:14: warning: expression using sizeof(void)
> 	+sizeof-void.c:20:27: warning: expression using sizeof(void)
>
> but the new positions look more correct.
>
> However. I didn't dare to send this patch because other warnings from
> sizeof-void.c still blame the column 14, this looks inconsistent...
> But perhaps we don't really care?

On a 2nd thought...

Unlike other warnings, this one (sizeof-void.c:20:27) refers to the
inner "sizeof *ptr", so I think that this patch fixes the reported
position. So yes, I think we don't care even if the new column == 27
differs from other warnings.

What do you think?

Oleg.


> So. I am going to update the changelog and send the trivial V2 below.
>
> Will you agree?
>
> Oleg.
> ---
>
> diff --git a/pre-process.c b/pre-process.c
> index 3fb25082..a4bb6cb6 100644
> --- a/pre-process.c
> +++ b/pre-process.c
> @@ -294,9 +294,11 @@ static struct token *collect_arg(struct token *prev, int vararg, struct position
>  		} else if (match_op(next, ',') && !nesting && !vararg) {
>  			break;
>  		}
> -		next->pos.stream = pos->stream;
> -		next->pos.line = pos->line;
> -		next->pos.pos = pos->pos;
> +		if (preprocess_only) {
> +			next->pos.stream = pos->stream;
> +			next->pos.line = pos->line;
> +			next->pos.pos = pos->pos;
> +		}
>  		next->pos.newline = 0;
>  		p = &next->next;
>  	}
> diff --git a/validation/parsing/attr-cleanup.c b/validation/parsing/attr-cleanup.c
> index ac64649c..fa3cb1ca 100644
> --- a/validation/parsing/attr-cleanup.c
> +++ b/validation/parsing/attr-cleanup.c
> @@ -24,7 +24,7 @@ int test(int n)
>   * check-command: sparse -Wunknown-attribute $file
>   *
>   * check-error-start
> -parsing/attr-cleanup.c:10:17: error: argument is not an identifier
> +parsing/attr-cleanup.c:10:27: error: argument is not an identifier
>  parsing/attr-cleanup.c:11:39: error: an argument is expected for attribute 'cleanup'
>  parsing/attr-cleanup.c:12:40: error: an argument is expected for attribute 'cleanup'
>  parsing/attr-cleanup.c:13:43: error: Expected ) after attribute's argument'
> diff --git a/validation/sizeof-void.c b/validation/sizeof-void.c
> index 0fd917a2..6792ff02 100644
> --- a/validation/sizeof-void.c
> +++ b/validation/sizeof-void.c
> @@ -36,7 +36,7 @@ sizeof-void.c:16:14: warning: expression using sizeof(void)
>  sizeof-void.c:17:14: warning: expression using sizeof(void)
>  sizeof-void.c:18:14: warning: expression using sizeof(void)
>  sizeof-void.c:19:14: warning: expression using sizeof(void)
> -sizeof-void.c:20:14: warning: expression using sizeof(void)
> +sizeof-void.c:20:27: warning: expression using sizeof(void)
>  sizeof-void.c:21:14: warning: expression using sizeof(void)
>  sizeof-void.c:22:14: warning: expression using sizeof(void)
>  sizeof-void.c:23:14: warning: expression using sizeof(void)