Add warning about duplicate initializers
PATCH 1/2 Add warning about duplicate initializers
From: Linus Torvalds <[email protected]>
Date: Sun, 30 Mar 2014 09:49:13 -0700
Subject: [PATCH 1/2] Add warning about duplicate initializers
Noticed this while looking at an independent bug reported by Hans Verkuil.
---
This is not a big deal, but the next patch will make us take the array size from any initializer, so let's warn on multiple initializers.
evaluate.c | 8 ++++++++ 1 file changed, 8 insertions(+)
evaluate.c +8 -0
@@ -3043,10 +3043,18 @@ static void check_duplicates(struct symbol *sym) {int declared =0 ;struct symbol *next = sym; +int initialized = sym->initializer !=NULL ;while ((next = next->same_symbol) !=NULL ) {const char *typediff;evaluate_symbol (next); +if (initialized && next->initializer) { +sparse_error (sym->pos,"symbol '%s' has multiple initializers (originally initialized at %s:%d)" , +show_ident (sym->ident), +stream_name (next->pos.stream), next->pos.line); +/* Only warn once */ + initialized =0 ; + } declared++; typediff =type_difference (&sym->ctype, &next->ctype,0 ,0 );if (typediff) {
Signature · 1 line
1.9.0
Quoted 9 lines · Linus Torvalds
From: Linus Torvalds <[email protected]>
Date: Sun, 30 Mar 2014 09:49:13 -0700
Subject: [PATCH 1/2] Add warning about duplicate initializersNoticed this while looking at an independent bug reported by Hans Verkuil.
Signed-off-by Linus Torvalds <[email protected]>
Quoted 37 lines
This is not a big deal, but the next patch will make us take the array size from any initializer, so let's warn on multiple initializers.
evaluate.c | 8 ++++++++ 1 file changed, 8 insertions(+)evaluate.c +8
-0@@ -3043,10 +3043,18 @@ static void check_duplicates(struct symbol *sym) {int declared =0 ;struct symbol *next = sym; +int initialized = sym->initializer !=NULL ;while ((next = next->same_symbol) !=NULL ) {const char *typediff;evaluate_symbol (next); +if (initialized && next->initializer) { +sparse_error (sym->pos,"symbol '%s' has multiple initializers (originally initialized at %s:%d)" , +show_ident (sym->ident), +stream_name (next->pos.stream), next->pos.line); +/* Only warn once */ + initialized =0 ; + } declared++; typediff =type_difference (&sym->ctype, &next->ctype,0 ,0 );if (typediff) {Signature · 6 lines
1.9.0 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Christopher Li
maintainerQuoted 7 lines · Josh Triplett
Quoted 4 lines · Linus Torvalds
Noticed this while looking at an independent bug reported by Hans Verkuil.
Signed-off-by Linus Torvalds <[email protected]>Reviewed-by Josh Triplett <[email protected]>
This change looks good. Will apply.
Chris