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
Signed-off-by: Hariprasad Kelam <[email protected]>
---
include/trace/events/neigh.h | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/include/trace/events/neigh.h b/include/trace/events/neigh.h
index 0bdb085..6e310ea 100644
--- a/include/trace/events/neigh.h
+++ b/include/trace/events/neigh.h
@@ -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;
--
2.7.4
On Tue, 26 Mar 2019 01:23:03 +0530
Hariprasad Kelam <[email protected]> wrote:
> ---
> include/trace/events/neigh.h | 19 +++++--------------
> 1 file changed, 5 insertions(+), 14 deletions(-)
>
> diff --git a/include/trace/events/neigh.h b/include/trace/events/neigh.h
> index 0bdb085..6e310ea 100644
> --- a/include/trace/events/neigh.h
> +++ b/include/trace/events/neigh.h
> @@ -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;
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
On Mon, Mar 25, 2019 at 1:11 PM Steven Rostedt <[email protected]> wrote:
>
> On Tue, 26 Mar 2019 01:23:03 +0530
> Hariprasad Kelam <[email protected]> wrote:
>
>
> > ---
> > include/trace/events/neigh.h | 19 +++++--------------
> > 1 file changed, 5 insertions(+), 14 deletions(-)
> >
> > diff --git a/include/trace/events/neigh.h b/include/trace/events/neigh.h
> > index 0bdb085..6e310ea 100644
> > --- a/include/trace/events/neigh.h
> > +++ b/include/trace/events/neigh.h
> > @@ -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;
>
> 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.
yes, agree. I will send a follow up patch to remove the redundant pin6
assignment.
On Mon, Mar 25, 2019 at 12:53 PM Hariprasad Kelam
<[email protected]> wrote:
>
> 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
>
> Signed-off-by: Hariprasad Kelam <[email protected]>
Acked-by: Roopa Prabhu <[email protected]>
Thanks!
On Tue, 26 Mar 2019 01:23:03 +0530
Hariprasad Kelam <[email protected]> wrote:
> 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
> 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(-)
>
> diff --git a/include/trace/events/neigh.h b/include/trace/events/neigh.h
> index 0bdb085..6e310ea 100644
> --- a/include/trace/events/neigh.h
> +++ b/include/trace/events/neigh.h
> @@ -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;
On Wed, Mar 27, 2019 at 11:53:30AM -0400, Steven Rostedt wrote:
> On Tue, 26 Mar 2019 01:23:03 +0530
> Hariprasad Kelam <[email protected]> wrote:
>
> > 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.
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
On Tue, Mar 26, 2019 at 01:23:03AM +0530, Hariprasad Kelam wrote:
> 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
>
> Signed-off-by: Hariprasad Kelam <[email protected]>
> ---
> include/trace/events/neigh.h | 19 +++++--------------
> 1 file changed, 5 insertions(+), 14 deletions(-)
>
> diff --git a/include/trace/events/neigh.h b/include/trace/events/neigh.h
> index 0bdb085..6e310ea 100644
> --- a/include/trace/events/neigh.h
> +++ b/include/trace/events/neigh.h
> @@ -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;
> @@ -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
On Sat, Mar 30, 2019 at 12:22:17AM +0100, Luc Van Oostenryck wrote:
> On Tue, Mar 26, 2019 at 01:23:03AM +0530, Hariprasad Kelam wrote:
> > 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
> >
> > Signed-off-by: Hariprasad Kelam <[email protected]>
> > ---
> > include/trace/events/neigh.h | 19 +++++--------------
> > 1 file changed, 5 insertions(+), 14 deletions(-)
> >
> > diff --git a/include/trace/events/neigh.h b/include/trace/events/neigh.h
> > index 0bdb085..6e310ea 100644
> > --- a/include/trace/events/neigh.h
> > +++ b/include/trace/events/neigh.h
> > @@ -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;
>
> > @@ -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>
> Same here.
>
> -- Luc Van Oostenryck
On Sat, Mar 30, 2019 at 04:37:48PM +0530, Hariprasad Kelam wrote:
> On Sat, Mar 30, 2019 at 12:22:17AM +0100, Luc Van Oostenryck wrote:
> > On Tue, Mar 26, 2019 at 01:23:03AM +0530, Hariprasad Kelam wrote:
> > > 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
> > >
> > > Signed-off-by: Hariprasad Kelam <[email protected]>
> > > ---
> > > include/trace/events/neigh.h | 19 +++++--------------
> > > 1 file changed, 5 insertions(+), 14 deletions(-)
> > >
> > > diff --git a/include/trace/events/neigh.h b/include/trace/events/neigh.h
> > > index 0bdb085..6e310ea 100644
> > > --- a/include/trace/events/neigh.h
> > > +++ b/include/trace/events/neigh.h
> > > @@ -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;
> >
> > > @@ -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 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
Reviewed-by: Luc Van Oostenryck <[email protected]>
-- Luc
On Sat, 30 Mar 2019 13:01:41 +0100
Luc Van Oostenryck <[email protected]> wrote:
> 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
I agree with it being separate patches. I'm big on the "one patch
accomplishes one task" ideology.
-- Steve
On Sat, Mar 30, 2019 at 5:40 AM Steven Rostedt <[email protected]> wrote:
>
> On Sat, 30 Mar 2019 13:01:41 +0100
> Luc Van Oostenryck <[email protected]> wrote:
>
> > 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
>
> I 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.