diff mbox series

[RFC] net: qrtr: correct types of trace event parameters

Message ID 20230402-qrtr-trace-types-v1-1-da062d368e74@kernel.org (mailing list archive)
State Superseded
Headers show
Series [RFC] net: qrtr: correct types of trace event parameters | expand

Commit Message

Simon Horman April 2, 2023, 11:15 a.m. UTC
The arguments passed to the trace events are of type unsigned int,
however the signature of the events used __le32 parameters.

I may be missing the point here, but sparse flagged this and it
does seem incorrect to me.

  net/qrtr/ns.c: note: in included file (through include/trace/trace_events.h, include/trace/define_trace.h, include/trace/events/qrtr.h):
  ./include/trace/events/qrtr.h:11:1: warning: cast to restricted __le32
  ./include/trace/events/qrtr.h:11:1: warning: restricted __le32 degrades to integer
  ./include/trace/events/qrtr.h:11:1: warning: restricted __le32 degrades to integer
  ... (a lot more similar warnings)
  net/qrtr/ns.c:115:47:    expected restricted __le32 [usertype] service
  net/qrtr/ns.c:115:47:    got unsigned int service
  net/qrtr/ns.c:115:61: warning: incorrect type in argument 2 (different base types)
  ... (a lot more similar warnings)

Signed-off-by: Simon Horman <horms@kernel.org>
---
 include/trace/events/qrtr.h | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

Comments

Manivannan Sadhasivam April 3, 2023, 5:14 a.m. UTC | #1
On Sun, Apr 02, 2023 at 01:15:33PM +0200, Simon Horman wrote:
> The arguments passed to the trace events are of type unsigned int,
> however the signature of the events used __le32 parameters.
> 
> I may be missing the point here, but sparse flagged this and it
> does seem incorrect to me.
> 
>   net/qrtr/ns.c: note: in included file (through include/trace/trace_events.h, include/trace/define_trace.h, include/trace/events/qrtr.h):
>   ./include/trace/events/qrtr.h:11:1: warning: cast to restricted __le32
>   ./include/trace/events/qrtr.h:11:1: warning: restricted __le32 degrades to integer
>   ./include/trace/events/qrtr.h:11:1: warning: restricted __le32 degrades to integer
>   ... (a lot more similar warnings)
>   net/qrtr/ns.c:115:47:    expected restricted __le32 [usertype] service
>   net/qrtr/ns.c:115:47:    got unsigned int service
>   net/qrtr/ns.c:115:61: warning: incorrect type in argument 2 (different base types)
>   ... (a lot more similar warnings)
> 

You are right. The actual arguments (service, instance, node, port) transferred/
received over QRTR are in le32 as per the protocol. But in the NS driver, the
arguments passed to the trace events are in the native endian (i.e) before
getting typecased to le32 for transmission.

And my intention was to trace the arguments in native endian format only. So
this patch indeed fixes the issue.

> Signed-off-by: Simon Horman <horms@kernel.org>

Please add the fixes tag once you remove RFC,

Fixes: dfddb54043f0 ("net: qrtr: Add tracepoint support")

Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>

- Mani

> ---
>  include/trace/events/qrtr.h | 33 ++++++++++++++++++---------------
>  1 file changed, 18 insertions(+), 15 deletions(-)
> 
> diff --git a/include/trace/events/qrtr.h b/include/trace/events/qrtr.h
> index b1de14c3bb93..441132c67133 100644
> --- a/include/trace/events/qrtr.h
> +++ b/include/trace/events/qrtr.h
> @@ -10,15 +10,16 @@
>  
>  TRACE_EVENT(qrtr_ns_service_announce_new,
>  
> -	TP_PROTO(__le32 service, __le32 instance, __le32 node, __le32 port),
> +	TP_PROTO(unsigned int service, unsigned int instance,
> +		 unsigned int node, unsigned int port),
>  
>  	TP_ARGS(service, instance, node, port),
>  
>  	TP_STRUCT__entry(
> -		__field(__le32, service)
> -		__field(__le32, instance)
> -		__field(__le32, node)
> -		__field(__le32, port)
> +		__field(unsigned int, service)
> +		__field(unsigned int, instance)
> +		__field(unsigned int, node)
> +		__field(unsigned int, port)
>  	),
>  
>  	TP_fast_assign(
> @@ -36,15 +37,16 @@ TRACE_EVENT(qrtr_ns_service_announce_new,
>  
>  TRACE_EVENT(qrtr_ns_service_announce_del,
>  
> -	TP_PROTO(__le32 service, __le32 instance, __le32 node, __le32 port),
> +	TP_PROTO(unsigned int service, unsigned int instance,
> +		 unsigned int node, unsigned int port),
>  
>  	TP_ARGS(service, instance, node, port),
>  
>  	TP_STRUCT__entry(
> -		__field(__le32, service)
> -		__field(__le32, instance)
> -		__field(__le32, node)
> -		__field(__le32, port)
> +		__field(unsigned int, service)
> +		__field(unsigned int, instance)
> +		__field(unsigned int, node)
> +		__field(unsigned int, port)
>  	),
>  
>  	TP_fast_assign(
> @@ -62,15 +64,16 @@ TRACE_EVENT(qrtr_ns_service_announce_del,
>  
>  TRACE_EVENT(qrtr_ns_server_add,
>  
> -	TP_PROTO(__le32 service, __le32 instance, __le32 node, __le32 port),
> +	TP_PROTO(unsigned int service, unsigned int instance,
> +		 unsigned int node, unsigned int port),
>  
>  	TP_ARGS(service, instance, node, port),
>  
>  	TP_STRUCT__entry(
> -		__field(__le32, service)
> -		__field(__le32, instance)
> -		__field(__le32, node)
> -		__field(__le32, port)
> +		__field(unsigned int, service)
> +		__field(unsigned int, instance)
> +		__field(unsigned int, node)
> +		__field(unsigned int, port)
>  	),
>  
>  	TP_fast_assign(
>
Simon Horman April 3, 2023, 1:10 p.m. UTC | #2
On Mon, Apr 03, 2023 at 10:44:56AM +0530, Manivannan Sadhasivam wrote:
> On Sun, Apr 02, 2023 at 01:15:33PM +0200, Simon Horman wrote:
> > The arguments passed to the trace events are of type unsigned int,
> > however the signature of the events used __le32 parameters.
> > 
> > I may be missing the point here, but sparse flagged this and it
> > does seem incorrect to me.
> > 
> >   net/qrtr/ns.c: note: in included file (through include/trace/trace_events.h, include/trace/define_trace.h, include/trace/events/qrtr.h):
> >   ./include/trace/events/qrtr.h:11:1: warning: cast to restricted __le32
> >   ./include/trace/events/qrtr.h:11:1: warning: restricted __le32 degrades to integer
> >   ./include/trace/events/qrtr.h:11:1: warning: restricted __le32 degrades to integer
> >   ... (a lot more similar warnings)
> >   net/qrtr/ns.c:115:47:    expected restricted __le32 [usertype] service
> >   net/qrtr/ns.c:115:47:    got unsigned int service
> >   net/qrtr/ns.c:115:61: warning: incorrect type in argument 2 (different base types)
> >   ... (a lot more similar warnings)
> > 
> 
> You are right. The actual arguments (service, instance, node, port) transferred/
> received over QRTR are in le32 as per the protocol. But in the NS driver, the
> arguments passed to the trace events are in the native endian (i.e) before
> getting typecased to le32 for transmission.
> 
> And my intention was to trace the arguments in native endian format only. So
> this patch indeed fixes the issue.
> 
> > Signed-off-by: Simon Horman <horms@kernel.org>
> 
> Please add the fixes tag once you remove RFC,
> 
> Fixes: dfddb54043f0 ("net: qrtr: Add tracepoint support")
> 
> Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>

Hi Manivannan,

thanks for your review.
I'll add the tags and drop the RFC designation.
Mukesh Ojha April 4, 2023, 8:20 a.m. UTC | #3
On 4/2/2023 4:45 PM, Simon Horman wrote:
> The arguments passed to the trace events are of type unsigned int,
> however the signature of the events used __le32 parameters.
> 
> I may be missing the point here, but sparse flagged this and it
> does seem incorrect to me.
> 
>    net/qrtr/ns.c: note: in included file (through include/trace/trace_events.h, include/trace/define_trace.h, include/trace/events/qrtr.h):
>    ./include/trace/events/qrtr.h:11:1: warning: cast to restricted __le32
>    ./include/trace/events/qrtr.h:11:1: warning: restricted __le32 degrades to integer
>    ./include/trace/events/qrtr.h:11:1: warning: restricted __le32 degrades to integer
>    ... (a lot more similar warnings)
>    net/qrtr/ns.c:115:47:    expected restricted __le32 [usertype] service
>    net/qrtr/ns.c:115:47:    got unsigned int service
>    net/qrtr/ns.c:115:61: warning: incorrect type in argument 2 (different base types)
>    ... (a lot more similar warnings)
> 
> Signed-off-by: Simon Horman <horms@kernel.org>
> ---
>   include/trace/events/qrtr.h | 33 ++++++++++++++++++---------------
>   1 file changed, 18 insertions(+), 15 deletions(-)
> 
> diff --git a/include/trace/events/qrtr.h b/include/trace/events/qrtr.h
> index b1de14c3bb93..441132c67133 100644
> --- a/include/trace/events/qrtr.h
> +++ b/include/trace/events/qrtr.h
> @@ -10,15 +10,16 @@
>   
>   TRACE_EVENT(qrtr_ns_service_announce_new,
>   
> -	TP_PROTO(__le32 service, __le32 instance, __le32 node, __le32 port),
> +	TP_PROTO(unsigned int service, unsigned int instance,
> +		 unsigned int node, unsigned int port),
>   
>   	TP_ARGS(service, instance, node, port),
>   
>   	TP_STRUCT__entry(
> -		__field(__le32, service)
> -		__field(__le32, instance)
> -		__field(__le32, node)
> -		__field(__le32, port)
> +		__field(unsigned int, service)
> +		__field(unsigned int, instance)
> +		__field(unsigned int, node)
> +		__field(unsigned int, port)
>   	),
>   
>   	TP_fast_assign(
> @@ -36,15 +37,16 @@ TRACE_EVENT(qrtr_ns_service_announce_new,
>   
>   TRACE_EVENT(qrtr_ns_service_announce_del,
>   
> -	TP_PROTO(__le32 service, __le32 instance, __le32 node, __le32 port),
> +	TP_PROTO(unsigned int service, unsigned int instance,
> +		 unsigned int node, unsigned int port),
>   
>   	TP_ARGS(service, instance, node, port),
>   
>   	TP_STRUCT__entry(
> -		__field(__le32, service)
> -		__field(__le32, instance)
> -		__field(__le32, node)
> -		__field(__le32, port)
> +		__field(unsigned int, service)
> +		__field(unsigned int, instance)
> +		__field(unsigned int, node)
> +		__field(unsigned int, port)
>   	),
>   
>   	TP_fast_assign(
> @@ -62,15 +64,16 @@ TRACE_EVENT(qrtr_ns_service_announce_del,
>   
>   TRACE_EVENT(qrtr_ns_server_add,
>   
> -	TP_PROTO(__le32 service, __le32 instance, __le32 node, __le32 port),
> +	TP_PROTO(unsigned int service, unsigned int instance,
> +		 unsigned int node, unsigned int port),
>   
>   	TP_ARGS(service, instance, node, port),
>   
>   	TP_STRUCT__entry(
> -		__field(__le32, service)
> -		__field(__le32, instance)
> -		__field(__le32, node)
> -		__field(__le32, port)
> +		__field(unsigned int, service)
> +		__field(unsigned int, instance)
> +		__field(unsigned int, node)
> +		__field(unsigned int, port)
>   	),
>   
>   	TP_fast_assign(

LGTM.

Acked-by: Mukesh Ojha <quic_mojha@quicinc.com>

--Mukesh

>
diff mbox series

Patch

diff --git a/include/trace/events/qrtr.h b/include/trace/events/qrtr.h
index b1de14c3bb93..441132c67133 100644
--- a/include/trace/events/qrtr.h
+++ b/include/trace/events/qrtr.h
@@ -10,15 +10,16 @@ 
 
 TRACE_EVENT(qrtr_ns_service_announce_new,
 
-	TP_PROTO(__le32 service, __le32 instance, __le32 node, __le32 port),
+	TP_PROTO(unsigned int service, unsigned int instance,
+		 unsigned int node, unsigned int port),
 
 	TP_ARGS(service, instance, node, port),
 
 	TP_STRUCT__entry(
-		__field(__le32, service)
-		__field(__le32, instance)
-		__field(__le32, node)
-		__field(__le32, port)
+		__field(unsigned int, service)
+		__field(unsigned int, instance)
+		__field(unsigned int, node)
+		__field(unsigned int, port)
 	),
 
 	TP_fast_assign(
@@ -36,15 +37,16 @@  TRACE_EVENT(qrtr_ns_service_announce_new,
 
 TRACE_EVENT(qrtr_ns_service_announce_del,
 
-	TP_PROTO(__le32 service, __le32 instance, __le32 node, __le32 port),
+	TP_PROTO(unsigned int service, unsigned int instance,
+		 unsigned int node, unsigned int port),
 
 	TP_ARGS(service, instance, node, port),
 
 	TP_STRUCT__entry(
-		__field(__le32, service)
-		__field(__le32, instance)
-		__field(__le32, node)
-		__field(__le32, port)
+		__field(unsigned int, service)
+		__field(unsigned int, instance)
+		__field(unsigned int, node)
+		__field(unsigned int, port)
 	),
 
 	TP_fast_assign(
@@ -62,15 +64,16 @@  TRACE_EVENT(qrtr_ns_service_announce_del,
 
 TRACE_EVENT(qrtr_ns_server_add,
 
-	TP_PROTO(__le32 service, __le32 instance, __le32 node, __le32 port),
+	TP_PROTO(unsigned int service, unsigned int instance,
+		 unsigned int node, unsigned int port),
 
 	TP_ARGS(service, instance, node, port),
 
 	TP_STRUCT__entry(
-		__field(__le32, service)
-		__field(__le32, instance)
-		__field(__le32, node)
-		__field(__le32, port)
+		__field(unsigned int, service)
+		__field(unsigned int, instance)
+		__field(unsigned int, node)
+		__field(unsigned int, port)
 	),
 
 	TP_fast_assign(