Linux-Sparse Archive on
 help / color / Atom feed
* [PATCH] flex-array: fix location for nesting of flexible members
@ 2020-10-09 16:08 Luc Van Oostenryck
  0 siblings, 0 replies; only message in thread
From: Luc Van Oostenryck @ 2020-10-09 16:08 UTC (permalink / raw)
  To: linux-sparse; +Cc: Luc Van Oostenryck

The warning about the nesting of flexible array members is
given with the location of the outer struct or union but
that is not very interesting. What is needed is the location
of the member causing this nesting.

So, fix the warning message to use the member's location.

Signed-off-by: Luc Van Oostenryck <>
 symbol.c                       | 2 +-
 validation/flex-array-nested.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/symbol.c b/symbol.c
index 9ae827c1d764..5e7f07969f96 100644
--- a/symbol.c
+++ b/symbol.c
@@ -200,7 +200,7 @@ static struct symbol * examine_struct_union_type(struct symbol *sym, int advance
 		if (has_flexible_array(member))
 			info.has_flex_array = 1;
 		if (has_flexible_array(member) && Wflexible_array_nested)
-			warning(sym->pos, "nested flexible arrays");
+			warning(member->pos, "nested flexible arrays");
 		fn(member, &info);
 	} END_FOR_EACH_PTR(member);
diff --git a/validation/flex-array-nested.c b/validation/flex-array-nested.c
index 63767683c56a..a82cbfc9c8e2 100644
--- a/validation/flex-array-nested.c
+++ b/validation/flex-array-nested.c
@@ -23,7 +23,7 @@ static int foo(struct s *s, union u *u)
  * check-command: sparse -Wflexible-array-nested $file
  * check-error-start
-flex-array-nested.c:6:8: warning: nested flexible arrays
-flex-array-nested.c:10:7: warning: nested flexible arrays
+flex-array-nested.c:7:18: warning: nested flexible arrays
+flex-array-nested.c:11:18: warning: nested flexible arrays
  * check-error-end

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-09 16:08 [PATCH] flex-array: fix location for nesting of flexible members Luc Van Oostenryck

Linux-Sparse Archive on

Archives are clonable:
	git clone --mirror linux-sparse/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-sparse linux-sparse/ \
	public-inbox-index linux-sparse

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone