trace: events: fix error directive in argument list
Subsystems (2)
PATCH 1/1 trace: events: fix error directive in argument list
This patch fixes below spare errors.
Sparse error:
make C=2 CF=-D__CHECK_ENDIAN__ M=net/core ./include/trace/events/neigh.h:73:1: error: directive in argument list ./include/trace/events/neigh.h:78:1: error: directive in argument list ./include/trace/events/neigh.h:150:1: error: directive in argument list ./include/trace/events/neigh.h:155:1: error: directive in argument list
Changes below two lines to signle line to avoid sparse error
#if IS_ENABLED(CONFIG_IPV6)
if (n->tbl->family == AF_INET6) {to if (IS_ENABLED(CONFIG_IPV6) && n->tbl->family == AF_INET6)
and removes reassigning pin6 pointer when IPV6 is enabled
--- include/trace/events/neigh.h | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)
include/trace/events/neigh.h +5 -14
@@ -70,15 +70,11 @@ TRACE_EVENT(neigh_update,else *p32 =0 ; -#if IS_ENABLED (CONFIG_IPV6 ) -if (n->tbl->family ==AF_INET6 ) { - pin6 = (struct in6_addr *)__entry->primary_key6; +if (IS_ENABLED (CONFIG_IPV6 ) && n->tbl->family ==AF_INET6 ) *pin6 = *(struct in6_addr *)n->primary_key; - } else -#endif - { +else ipv6_addr_set_v4mapped (*p32, pin6); - } + __entry->confirmed = n->confirmed; __entry->updated = n->updated; __entry->used = n->used;
@@ -147,15 +143,10 @@ DECLARE_EVENT_CLASS(neigh__update,else *p32 =0 ; -#if IS_ENABLED (CONFIG_IPV6 ) -if (n->tbl->family ==AF_INET6 ) { - pin6 = (struct in6_addr *)__entry->primary_key6; +if (IS_ENABLED (CONFIG_IPV6 ) && n->tbl->family ==AF_INET6 ) *pin6 = *(struct in6_addr *)n->primary_key; - } else -#endif - { +else ipv6_addr_set_v4mapped (*p32, pin6); - } __entry->confirmed = n->confirmed; __entry->updated = n->updated;
Signature · 1 line
2.7.4
Steven Rostedt
maintainerQuoted 17 lines · On Tue, 26 Mar 2019 01:23:03 +0530 Hariprasad Kelam…
--- include/trace/events/neigh.h | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)include/trace/events/neigh.h +1
-3@@ -70,15 +70,11 @@ TRACE_EVENT(neigh_update,else *p32 =0 ; -#if IS_ENABLED (CONFIG_IPV6 ) -if (n->tbl->family ==AF_INET6 ) { - pin6 = (struct in6_addr *)__entry->primary_key6; +if (IS_ENABLED (CONFIG_IPV6 ) && n->tbl->family ==AF_INET6 ) *pin6 = *(struct in6_addr *)n->primary_key;
include/trace/events/neigh.h TRACE_EVENT(neigh_update, · line 80
Quoted 10 lines
include/trace/events/neigh.h +2
-4- } else -#endif - { +else ipv6_addr_set_v4mapped (*p32, pin6); - } + __entry->confirmed = n->confirmed; __entry->updated = n->updated; __entry->used = n->used;
Not sure why the added pin6 assignment was there to begin with:
<code-snippet>
pin6 = (struct in6_addr *)__entry->primary_key6;
p32 = (__be32 *)__entry->primary_key4;
if (n->tbl->family == AF_INET)
*p32 = *(__be32 *)n->primary_key;
else
*p32 = 0;#if IS_ENABLED(CONFIG_IPV6)
if (n->tbl->family == AF_INET6) {
pin6 = (struct in6_addr *)__entry->primary_key6;
*pin6 = *(struct in6_addr *)n->primary_key;
} else
#endif
{
ipv6_addr_set_v4mapped(*p32, pin6);
}</code-snippet>
It was already assigned. Looks fine to me, at least from a tracing point of view.
-- Steve
Quoted 53 lines · Steven Rostedt
Quoted 17 lines · On Tue, 26 Mar 2019 01:23:03 +0530 Hariprasad Kelam…
--- include/trace/events/neigh.h | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)include/trace/events/neigh.h +1
-3@@ -70,15 +70,11 @@ TRACE_EVENT(neigh_update,else *p32 =0 ; -#if IS_ENABLED (CONFIG_IPV6 ) -if (n->tbl->family ==AF_INET6 ) { - pin6 = (struct in6_addr *)__entry->primary_key6; +if (IS_ENABLED (CONFIG_IPV6 ) && n->tbl->family ==AF_INET6 ) *pin6 = *(struct in6_addr *)n->primary_key;include/trace/events/neigh.h TRACE_EVENT(neigh_update, · line 80
Quoted 10 lines
include/trace/events/neigh.h +2
-4- } else -#endif - { +else ipv6_addr_set_v4mapped (*p32, pin6); - } + __entry->confirmed = n->confirmed; __entry->updated = n->updated; __entry->used = n->used;Not sure why the added pin6 assignment was there to begin with:
<code-snippet>
pin6 = (struct in6_addr *)__entry->primary_key6; p32 = (__be32 *)__entry->primary_key4; if (n->tbl->family == AF_INET) *p32 = *(__be32 *)n->primary_key; else *p32 = 0;#if IS_ENABLED(CONFIG_IPV6) if (n->tbl->family == AF_INET6) { pin6 = (struct in6_addr *)__entry->primary_key6; *pin6 = *(struct in6_addr *)n->primary_key; } else #endif { ipv6_addr_set_v4mapped(*p32, pin6); }
Quoted 4 lines
</code-snippet>
It was already assigned. Looks fine to me, at least from a tracing point of view.
yes, agree. I will send a follow up patch to remove the redundant pin6 assignment.
Quoted 10 lines · Hariprasad Kelam
This patch fixes below spare errors.
Sparse error:
make C=2 CF=-D__CHECK_ENDIAN__ M=net/core./include/trace/events/neigh.h:73:1: error: directive in argument list./include/trace/events/neigh.h:78:1: error: directive in argument list./include/trace/events/neigh.h:150:1: error: directive in argument list./include/trace/events/neigh.h:155:1: error: directive in argument list
Quoted 8 lines
Changes below two lines to signle line to avoid sparse error
#if IS_ENABLED(CONFIG_IPV6) if (n->tbl->family == AF_INET6) {to if (
IS_ENABLED(CONFIG_IPV6)&&n->tbl->family==AF_INET6)and removes reassigning pin6 pointer when IPV6 is enabled
Signed-off-by Hariprasad Kelam <[email protected]>
Thanks!
Steven Rostedt
maintainerQuoted 9 lines · On Tue, 26 Mar 2019 01:23:03 +0530 Hariprasad Kelam…
This patch fixes below spare errors.
Sparse error:
make C=2 CF=-D__CHECK_ENDIAN__ M=net/core./include/trace/events/neigh.h:73:1: error: directive in argument list./include/trace/events/neigh.h:78:1: error: directive in argument list./include/trace/events/neigh.h:150:1: error: directive in argument list./include/trace/events/neigh.h:155:1: error: directive in argument list
I have nothing really against these patches, but why is the current code considered wrong?
Note, TRACE_EVENTS() are "special macros". They hold structure definitions and full code inside the argument list. There should be no reason that this is causing a warning.
Perhaps we should blacklist the include/trace directory from sparse checking for these types of "errors".
-- Steve
Quoted 53 lines
Changes below two lines to signle line to avoid sparse error
#if IS_ENABLED(CONFIG_IPV6) if (n->tbl->family == AF_INET6) {to if (
IS_ENABLED(CONFIG_IPV6)&&n->tbl->family==AF_INET6)and removes reassigning pin6 pointer when IPV6 is enabled
Signed-off-by Hariprasad Kelam <[email protected]>--- include/trace/events/neigh.h | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)include/trace/events/neigh.h +5
-14@@ -70,15 +70,11 @@ TRACE_EVENT(neigh_update,else *p32 =0 ; -#if IS_ENABLED (CONFIG_IPV6 ) -if (n->tbl->family ==AF_INET6 ) { - pin6 = (struct in6_addr *)__entry->primary_key6; +if (IS_ENABLED (CONFIG_IPV6 ) && n->tbl->family ==AF_INET6 ) *pin6 = *(struct in6_addr *)n->primary_key; - } else -#endif - { +else ipv6_addr_set_v4mapped (*p32, pin6); - } + __entry->confirmed = n->confirmed; __entry->updated = n->updated; __entry->used = n->used;@@ -147,15 +143,10 @@ DECLARE_EVENT_CLASS(neigh__update,else *p32 =0 ; -#if IS_ENABLED (CONFIG_IPV6 ) -if (n->tbl->family ==AF_INET6 ) { - pin6 = (struct in6_addr *)__entry->primary_key6; +if (IS_ENABLED (CONFIG_IPV6 ) && n->tbl->family ==AF_INET6 ) *pin6 = *(struct in6_addr *)n->primary_key; - } else -#endif - { +else ipv6_addr_set_v4mapped (*p32, pin6); - } __entry->confirmed = n->confirmed; __entry->updated = n->updated;
Quoted 13 lines · Steven Rostedt
Quoted 9 lines · On Tue, 26 Mar 2019 01:23:03 +0530 Hariprasad Kelam…
This patch fixes below spare errors.
Sparse error:
make C=2 CF=-D__CHECK_ENDIAN__ M=net/core./include/trace/events/neigh.h:73:1: error: directive in argument list./include/trace/events/neigh.h:78:1: error: directive in argument list./include/trace/events/neigh.h:150:1: error: directive in argument list./include/trace/events/neigh.h:155:1: error: directive in argument list
Quoted 6 lines
I have nothing really against these patches, but why is the current code considered wrong?
Note,
TRACE_EVENTS()are "special macros". They hold structure definitions and full code inside the argument list. There should be no reason that this is causing a warning.
The problem is that #ifdefs at line 73 & 150 are inside TRACE_EVENT()'s invocation and this is undefined behaviour. From the standard:
... If there are sequences of preprocessing tokens within the list of arguments that would otherwise act as preprocessing directives, the behavior is undefined.
[C90 6.8.3, C99 & C11 6.10.3p11]
GCC can handle it (and sparse too) but yes sparse complains about it.
-- Luc Van Oostenryck
Quoted 26 lines · Hariprasad Kelam
This patch fixes below spare errors.
Sparse error:
make C=2 CF=-D__CHECK_ENDIAN__ M=net/core./include/trace/events/neigh.h:73:1: error: directive in argument list./include/trace/events/neigh.h:78:1: error: directive in argument list./include/trace/events/neigh.h:150:1: error: directive in argument list./include/trace/events/neigh.h:155:1: error: directive in argument listChanges below two lines to signle line to avoid sparse error
#if IS_ENABLED(CONFIG_IPV6) if (n->tbl->family == AF_INET6) {to if (
IS_ENABLED(CONFIG_IPV6)&&n->tbl->family==AF_INET6)and removes reassigning pin6 pointer when IPV6 is enabled
Signed-off-by Hariprasad Kelam <[email protected]>--- include/trace/events/neigh.h | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)include/trace/events/neigh.h +0
-0
include/trace/events/neigh.h TRACE_EVENT(neigh_update, · line 74
Quoted 8 lines
include/trace/events/neigh.h +1
-3@@ -70,15 +70,11 @@ TRACE_EVENT(neigh_update,else *p32 =0 ; -#if IS_ENABLED (CONFIG_IPV6 ) -if (n->tbl->family ==AF_INET6 ) { - pin6 = (struct in6_addr *)__entry->primary_key6; +if (IS_ENABLED (CONFIG_IPV6 ) && n->tbl->family ==AF_INET6 ) *pin6 = *(struct in6_addr *)n->primary_key;
Why removing the line wheer pin6 is assigned?
IMO, the patch should be:
-#if IS_ENABLED(CONFIG_IPV6)
- if (n->tbl->family == AF_INET6) {
+ if (IS_ENABLED(CONFIG_IPV6) && n->tbl->family == AF_INET6)
pin6 = (struct in6_addr *)__entry->primary_key6; *pin6 = *(struct in6_addr *)n->primary_key;
include/trace/events/neigh.h DECLARE_EVENT_CLASS(neigh__update, · line 152
Quoted 7 lines
include/trace/events/neigh.h +0
-3@@ -147,15 +143,10 @@ DECLARE_EVENT_CLASS(neigh__update,else *p32 =0 ; -#if IS_ENABLED (CONFIG_IPV6 ) -if (n->tbl->family ==AF_INET6 ) { - pin6 = (struct in6_addr *)__entry->primary_key6;
Same here.
-- Luc Van Oostenryck
Quoted 44 lines · Luc Van Oostenryck
Quoted 26 lines · Hariprasad Kelam
This patch fixes below spare errors.
Sparse error:
make C=2 CF=-D__CHECK_ENDIAN__ M=net/core./include/trace/events/neigh.h:73:1: error: directive in argument list./include/trace/events/neigh.h:78:1: error: directive in argument list./include/trace/events/neigh.h:150:1: error: directive in argument list./include/trace/events/neigh.h:155:1: error: directive in argument listChanges below two lines to signle line to avoid sparse error
#if IS_ENABLED(CONFIG_IPV6) if (n->tbl->family == AF_INET6) {to if (
IS_ENABLED(CONFIG_IPV6)&&n->tbl->family==AF_INET6)and removes reassigning pin6 pointer when IPV6 is enabled
Signed-off-by Hariprasad Kelam <[email protected]>--- include/trace/events/neigh.h | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)include/trace/events/neigh.h +0
-0include/trace/events/neigh.h TRACE_EVENT(neigh_update, · line 74
Quoted 8 lines
include/trace/events/neigh.h +1
-3@@ -70,15 +70,11 @@ TRACE_EVENT(neigh_update,else *p32 =0 ; -#if IS_ENABLED (CONFIG_IPV6 ) -if (n->tbl->family ==AF_INET6 ) { - pin6 = (struct in6_addr *)__entry->primary_key6; +if (IS_ENABLED (CONFIG_IPV6 ) && n->tbl->family ==AF_INET6 ) *pin6 = *(struct in6_addr *)n->primary_key;Why removing the line wheer pin6 is assigned?
IMO, the patch should be:include/trace/events/neigh.h +1
-2-#if IS_ENABLED (CONFIG_IPV6 ) -if (n->tbl->family ==AF_INET6 ) { +if (IS_ENABLED (CONFIG_IPV6 ) && n->tbl->family ==AF_INET6 ) pin6 = (struct in6_addr *)__entry->primary_key6; *pin6 = *(struct in6_addr *)n->primary_key;
Quoted 8 lines
include/trace/events/neigh.h DECLARE_EVENT_CLASS(neigh__update, · line 152
Quoted 7 lines
include/trace/events/neigh.h +0
-3@@ -147,15 +143,10 @@ DECLARE_EVENT_CLASS(neigh__update,else *p32 =0 ; -#if IS_ENABLED (CONFIG_IPV6 ) -if (n->tbl->family ==AF_INET6 ) { - pin6 = (struct in6_addr *)__entry->primary_key6;
pin6 is already assinged .Assinging pin6 is redudant in if loop
Below is the original code
<code-snippet>
pin6 = (struct in6_addr *)__entry->primary_key6; p32 = (__be32 *)__entry->primary_key4; if (n->tbl->family == AF_INET) *p32 = *(__be32 *)n->primary_key; else *p32 = 0;
#if IS_ENABLED(CONFIG_IPV6)
if (n->tbl->family == AF_INET6) {
pin6 = (struct in6_addr *)__entry->primary_key6;
*pin6 = *(struct in6_addr *)n->primary_key;
} else
#endif
{
ipv6_addr_set_v4mapped(*p32, pin6);
}</code-snippet>
Quoted 3 lines
Same here.
-- Luc Van Oostenryck
Luc Van Oostenryck
Reviewed-byQuoted 49 lines · Hariprasad Kelam
Quoted 48 lines · Luc Van Oostenryck
Quoted 26 lines · Hariprasad Kelam
This patch fixes below spare errors.
Sparse error:
make C=2 CF=-D__CHECK_ENDIAN__ M=net/core./include/trace/events/neigh.h:73:1: error: directive in argument list./include/trace/events/neigh.h:78:1: error: directive in argument list./include/trace/events/neigh.h:150:1: error: directive in argument list./include/trace/events/neigh.h:155:1: error: directive in argument listChanges below two lines to signle line to avoid sparse error
#if IS_ENABLED(CONFIG_IPV6) if (n->tbl->family == AF_INET6) {to if (
IS_ENABLED(CONFIG_IPV6)&&n->tbl->family==AF_INET6)and removes reassigning pin6 pointer when IPV6 is enabled
Signed-off-by Hariprasad Kelam <[email protected]>--- include/trace/events/neigh.h | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)include/trace/events/neigh.h +0
-0include/trace/events/neigh.h TRACE_EVENT(neigh_update, · line 74
Quoted 8 lines
include/trace/events/neigh.h +1
-3@@ -70,15 +70,11 @@ TRACE_EVENT(neigh_update,else *p32 =0 ; -#if IS_ENABLED (CONFIG_IPV6 ) -if (n->tbl->family ==AF_INET6 ) { - pin6 = (struct in6_addr *)__entry->primary_key6; +if (IS_ENABLED (CONFIG_IPV6 ) && n->tbl->family ==AF_INET6 ) *pin6 = *(struct in6_addr *)n->primary_key;Why removing the line wheer pin6 is assigned?
IMO, the patch should be:include/trace/events/neigh.h +1
-2-#if IS_ENABLED (CONFIG_IPV6 ) -if (n->tbl->family ==AF_INET6 ) { +if (IS_ENABLED (CONFIG_IPV6 ) && n->tbl->family ==AF_INET6 ) pin6 = (struct in6_addr *)__entry->primary_key6; *pin6 = *(struct in6_addr *)n->primary_key;Quoted 5 lines
include/trace/events/neigh.h +0
-0@@ -147,15 +143,10 @@ DECLARE_EVENT_CLASS(neigh__update,else *p32 =0 ;
Quoted 5 lines
Quoted 4 lines
include/trace/events/neigh.h TRACE_EVENT(neigh_update, · line 75
Quoted 3 lines
include/trace/events/neigh.h +0
-3-#if IS_ENABLED (CONFIG_IPV6 ) -if (n->tbl->family ==AF_INET6 ) { - pin6 = (struct in6_addr *)__entry->primary_key6;pin6 is already assigned.
OK, I see. IMO, it would be better to have 2 patches for this:
one for the redundant assignment to pin6 and anotther one for the IS_ENABLED() change but feel free, if needed, to add my
-- Luc
Steven Rostedt
maintainerQuoted 3 lines · On Sat, 30 Mar 2019 13:01:41 +0100 Luc Van Oostenryck…
OK, I see. IMO, it would be better to have 2 patches for this:
one for the redundant assignment to pin6 and anotther one for theIS_ENABLED()change but feel free, if needed, to add my
I agree with it being separate patches. I'm big on the "one patch accomplishes one task" ideology.
-- Steve
Quoted 11 lines · Steven Rostedt
Quoted 3 lines · On Sat, 30 Mar 2019 13:01:41 +0100 Luc Van Oostenryck…
OK, I see. IMO, it would be better to have 2 patches for this:
one for the redundant assignment to pin6 and anotther one for theIS_ENABLED()change but feel free, if needed, to add myI agree with it being separate patches. I'm big on the "one patch accomplishes one task" ideology.
yes, I will take care of the pin6 assignment separately. This patch can only address the sparse error.