diff mbox series

net: hns3: tracing: fix hclgevf trace event strings

Message ID 20240313093454.3909afe7@gandalf.local.home (mailing list archive)
State Not Applicable
Delegated to: Netdev Maintainers
Headers show
Series net: hns3: tracing: fix hclgevf trace event strings | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 939 this patch: 939
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 10 of 10 maintainers
netdev/build_clang success Errors and warnings before: 956 this patch: 956
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 956 this patch: 956
netdev/checkpatch warning WARNING: Please use correct Fixes: style 'Fixes: <12 chars of sha1> ("<title line>")' - ie: 'Fixes: d8355240cf8f ("net: hns3: add trace event support for PF/VF mailbox")'
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-03-14--12-00 (tests: 908)

Commit Message

Steven Rostedt March 13, 2024, 1:34 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

[
   Note, I need to take this patch through my tree, so I'm looking for acks.
   This causes the build to fail when I add the __assign_str() check, which
   I was about to push to Linus, but it breaks allmodconfig due to this error.
]

The __string() and __assign_str() helper macros of the TRACE_EVENT() macro
are going through some optimizations where only the source string of
__string() will be used and the __assign_str() source will be ignored and
later removed.

To make sure that there's no issues, a new check is added between the
__string() src argument and the __assign_str() src argument that does a
strcmp() to make sure they are the same string.

The hclgevf trace events have:

  __assign_str(devname, &hdev->nic.kinfo.netdev->name);

Which triggers the warning:

hclgevf_trace.h:34:39: error: passing argument 1 of ‘strcmp’ from incompatible pointer type [-Werror=incompatible-pointer-types]
   34 |                 __assign_str(devname, &hdev->nic.kinfo.netdev->name);
 [..]
arch/x86/include/asm/string_64.h:75:24: note: expected ‘const char *’ but argument is of type ‘char (*)[16]’
   75 | int strcmp(const char *cs, const char *ct);
      |            ~~~~~~~~~~~~^~


Because __assign_str() now has:

	WARN_ON_ONCE(__builtin_constant_p(src) ?		\
		     strcmp((src), __data_offsets.dst##_ptr_) :	\
		     (src) != __data_offsets.dst##_ptr_);	\

The problem is the '&' on hdev->nic.kinfo.netdev->name. That's because
that name is:

	char			name[IFNAMSIZ]

Where passing an address '&' of a char array is not compatible with strcmp().

The '&' is not necessary, remove it.

Fixes: d8355240cf8fb ("net: hns3: add trace event support for PF/VF mailbox")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_trace.h  | 8 ++++----
 .../net/ethernet/hisilicon/hns3/hns3vf/hclgevf_trace.h    | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

Comments

Jijie Shao March 14, 2024, 11:48 a.m. UTC | #1
Reviewed-by: Jijie Shao<shaojijie@huawei.com>

on 2024/3/13 21:34, Steven Rostedt wrote:
> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
>
> [
>     Note, I need to take this patch through my tree, so I'm looking for acks.
>     This causes the build to fail when I add the __assign_str() check, which
>     I was about to push to Linus, but it breaks allmodconfig due to this error.
> ]
>
> The __string() and __assign_str() helper macros of the TRACE_EVENT() macro
> are going through some optimizations where only the source string of
> __string() will be used and the __assign_str() source will be ignored and
> later removed.
>
> To make sure that there's no issues, a new check is added between the
> __string() src argument and the __assign_str() src argument that does a
> strcmp() to make sure they are the same string.
>
> The hclgevf trace events have:
>
>    __assign_str(devname, &hdev->nic.kinfo.netdev->name);
>
> Which triggers the warning:
>
> hclgevf_trace.h:34:39: error: passing argument 1 of ‘strcmp’ from incompatible pointer type [-Werror=incompatible-pointer-types]
>     34 |                 __assign_str(devname, &hdev->nic.kinfo.netdev->name);
>   [..]
> arch/x86/include/asm/string_64.h:75:24: note: expected ‘const char *’ but argument is of type ‘char (*)[16]’
>     75 | int strcmp(const char *cs, const char *ct);
>        |            ~~~~~~~~~~~~^~
>
>
> Because __assign_str() now has:
>
> 	WARN_ON_ONCE(__builtin_constant_p(src) ?		\
> 		     strcmp((src), __data_offsets.dst##_ptr_) :	\
> 		     (src) != __data_offsets.dst##_ptr_);	\
>
> The problem is the '&' on hdev->nic.kinfo.netdev->name. That's because
> that name is:
>
> 	char			name[IFNAMSIZ]
>
> Where passing an address '&' of a char array is not compatible with strcmp().
>
> The '&' is not necessary, remove it.
>
> Fixes: d8355240cf8fb ("net: hns3: add trace event support for PF/VF mailbox")
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
>   drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_trace.h  | 8 ++++----
>   .../net/ethernet/hisilicon/hns3/hns3vf/hclgevf_trace.h    | 8 ++++----
>   2 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_trace.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_trace.h
> index 8510b88d4982..f3cd5a376eca 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_trace.h
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_trace.h
> @@ -24,7 +24,7 @@ TRACE_EVENT(hclge_pf_mbx_get,
>   		__field(u8, code)
>   		__field(u8, subcode)
>   		__string(pciname, pci_name(hdev->pdev))
> -		__string(devname, &hdev->vport[0].nic.kinfo.netdev->name)
> +		__string(devname, hdev->vport[0].nic.kinfo.netdev->name)
>   		__array(u32, mbx_data, PF_GET_MBX_LEN)
>   	),
>   
> @@ -33,7 +33,7 @@ TRACE_EVENT(hclge_pf_mbx_get,
>   		__entry->code = req->msg.code;
>   		__entry->subcode = req->msg.subcode;
>   		__assign_str(pciname, pci_name(hdev->pdev));
> -		__assign_str(devname, &hdev->vport[0].nic.kinfo.netdev->name);
> +		__assign_str(devname, hdev->vport[0].nic.kinfo.netdev->name);
>   		memcpy(__entry->mbx_data, req,
>   		       sizeof(struct hclge_mbx_vf_to_pf_cmd));
>   	),
> @@ -56,7 +56,7 @@ TRACE_EVENT(hclge_pf_mbx_send,
>   		__field(u8, vfid)
>   		__field(u16, code)
>   		__string(pciname, pci_name(hdev->pdev))
> -		__string(devname, &hdev->vport[0].nic.kinfo.netdev->name)
> +		__string(devname, hdev->vport[0].nic.kinfo.netdev->name)
>   		__array(u32, mbx_data, PF_SEND_MBX_LEN)
>   	),
>   
> @@ -64,7 +64,7 @@ TRACE_EVENT(hclge_pf_mbx_send,
>   		__entry->vfid = req->dest_vfid;
>   		__entry->code = le16_to_cpu(req->msg.code);
>   		__assign_str(pciname, pci_name(hdev->pdev));
> -		__assign_str(devname, &hdev->vport[0].nic.kinfo.netdev->name);
> +		__assign_str(devname, hdev->vport[0].nic.kinfo.netdev->name);
>   		memcpy(__entry->mbx_data, req,
>   		       sizeof(struct hclge_mbx_pf_to_vf_cmd));
>   	),
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_trace.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_trace.h
> index 5d4895bb57a1..b259e95dd53c 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_trace.h
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_trace.h
> @@ -23,7 +23,7 @@ TRACE_EVENT(hclge_vf_mbx_get,
>   		__field(u8, vfid)
>   		__field(u16, code)
>   		__string(pciname, pci_name(hdev->pdev))
> -		__string(devname, &hdev->nic.kinfo.netdev->name)
> +		__string(devname, hdev->nic.kinfo.netdev->name)
>   		__array(u32, mbx_data, VF_GET_MBX_LEN)
>   	),
>   
> @@ -31,7 +31,7 @@ TRACE_EVENT(hclge_vf_mbx_get,
>   		__entry->vfid = req->dest_vfid;
>   		__entry->code = le16_to_cpu(req->msg.code);
>   		__assign_str(pciname, pci_name(hdev->pdev));
> -		__assign_str(devname, &hdev->nic.kinfo.netdev->name);
> +		__assign_str(devname, hdev->nic.kinfo.netdev->name);
>   		memcpy(__entry->mbx_data, req,
>   		       sizeof(struct hclge_mbx_pf_to_vf_cmd));
>   	),
> @@ -55,7 +55,7 @@ TRACE_EVENT(hclge_vf_mbx_send,
>   		__field(u8, code)
>   		__field(u8, subcode)
>   		__string(pciname, pci_name(hdev->pdev))
> -		__string(devname, &hdev->nic.kinfo.netdev->name)
> +		__string(devname, hdev->nic.kinfo.netdev->name)
>   		__array(u32, mbx_data, VF_SEND_MBX_LEN)
>   	),
>   
> @@ -64,7 +64,7 @@ TRACE_EVENT(hclge_vf_mbx_send,
>   		__entry->code = req->msg.code;
>   		__entry->subcode = req->msg.subcode;
>   		__assign_str(pciname, pci_name(hdev->pdev));
> -		__assign_str(devname, &hdev->nic.kinfo.netdev->name);
> +		__assign_str(devname, hdev->nic.kinfo.netdev->name);
>   		memcpy(__entry->mbx_data, req,
>   		       sizeof(struct hclge_mbx_vf_to_pf_cmd));
>   	),
Paolo Abeni March 14, 2024, 2:39 p.m. UTC | #2
On Wed, 2024-03-13 at 09:34 -0400, Steven Rostedt wrote:
> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
> 
> [
>    Note, I need to take this patch through my tree, so I'm looking for acks.

Note that this device driver is changing quite rapidly, so I expect
some conflicts here later. I guess Liuns will have to handle them ;)

>    This causes the build to fail when I add the __assign_str() check, which
>    I was about to push to Linus, but it breaks allmodconfig due to this error.
> ]
> 
> The __string() and __assign_str() helper macros of the TRACE_EVENT() macro
> are going through some optimizations where only the source string of
> __string() will be used and the __assign_str() source will be ignored and
> later removed.
> 
> To make sure that there's no issues, a new check is added between the
> __string() src argument and the __assign_str() src argument that does a
> strcmp() to make sure they are the same string.
> 
> The hclgevf trace events have:
> 
>   __assign_str(devname, &hdev->nic.kinfo.netdev->name);
> 
> Which triggers the warning:
> 
> hclgevf_trace.h:34:39: error: passing argument 1 of ‘strcmp’ from incompatible pointer type [-Werror=incompatible-pointer-types]
>    34 |                 __assign_str(devname, &hdev->nic.kinfo.netdev->name);
>  [..]
> arch/x86/include/asm/string_64.h:75:24: note: expected ‘const char *’ but argument is of type ‘char (*)[16]’
>    75 | int strcmp(const char *cs, const char *ct);
>       |            ~~~~~~~~~~~~^~
> 
> 
> Because __assign_str() now has:
> 
> 	WARN_ON_ONCE(__builtin_constant_p(src) ?		\
> 		     strcmp((src), __data_offsets.dst##_ptr_) :	\
> 		     (src) != __data_offsets.dst##_ptr_);	\
> 
> The problem is the '&' on hdev->nic.kinfo.netdev->name. That's because
> that name is:
> 
> 	char			name[IFNAMSIZ]
> 
> Where passing an address '&' of a char array is not compatible with strcmp().
> 
> The '&' is not necessary, remove it.
> 
> Fixes: d8355240cf8fb ("net: hns3: add trace event support for PF/VF mailbox")

checkpactch in strict mode complains the hash is not 12 char long.

> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

FWIW

Acked-by: Paolo Abeni <pabeni@redhat.com>
Steven Rostedt March 14, 2024, 4 p.m. UTC | #3
On Thu, 14 Mar 2024 15:39:28 +0100
Paolo Abeni <pabeni@redhat.com> wrote:

> On Wed, 2024-03-13 at 09:34 -0400, Steven Rostedt wrote:
> > From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
> > 
> > [
> >    Note, I need to take this patch through my tree, so I'm looking for acks.  
> 
> Note that this device driver is changing quite rapidly, so I expect
> some conflicts here later. I guess Liuns will have to handle them ;)

Well, it merges fine with linux-next and linus's current master. ;-)

> 
> >    This causes the build to fail when I add the __assign_str() check, which
> >    I was about to push to Linus, but it breaks allmodconfig due to this error.
> > ]
> > 
> > The __string() and __assign_str() helper macros of the TRACE_EVENT() macro
> > are going through some optimizations where only the source string of
> > __string() will be used and the __assign_str() source will be ignored and
> > later removed.
> > 
> > To make sure that there's no issues, a new check is added between the
> > __string() src argument and the __assign_str() src argument that does a
> > strcmp() to make sure they are the same string.
> > 
> > The hclgevf trace events have:
> > 
> >   __assign_str(devname, &hdev->nic.kinfo.netdev->name);
> > 
> > Which triggers the warning:
> > 
> > hclgevf_trace.h:34:39: error: passing argument 1 of ‘strcmp’ from incompatible pointer type [-Werror=incompatible-pointer-types]
> >    34 |                 __assign_str(devname, &hdev->nic.kinfo.netdev->name);
> >  [..]
> > arch/x86/include/asm/string_64.h:75:24: note: expected ‘const char *’ but argument is of type ‘char (*)[16]’
> >    75 | int strcmp(const char *cs, const char *ct);
> >       |            ~~~~~~~~~~~~^~
> > 
> > 
> > Because __assign_str() now has:
> > 
> > 	WARN_ON_ONCE(__builtin_constant_p(src) ?		\
> > 		     strcmp((src), __data_offsets.dst##_ptr_) :	\
> > 		     (src) != __data_offsets.dst##_ptr_);	\
> > 
> > The problem is the '&' on hdev->nic.kinfo.netdev->name. That's because
> > that name is:
> > 
> > 	char			name[IFNAMSIZ]
> > 
> > Where passing an address '&' of a char array is not compatible with strcmp().
> > 
> > The '&' is not necessary, remove it.
> > 
> > Fixes: d8355240cf8fb ("net: hns3: add trace event support for PF/VF mailbox")  
> 
> checkpactch in strict mode complains the hash is not 12 char long.

Hmm, I wonder why my git blame gives me 13 characters in the sha. (I cut
and pasted it from git blame). My git config has:

[core]  
        abbrev = 12


> 
> > Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>  
> 
> FWIW
> 
> Acked-by: Paolo Abeni <pabeni@redhat.com>

Thanks!

-- Steve
Simon Horman March 19, 2024, 11:09 a.m. UTC | #4
On Thu, Mar 14, 2024 at 12:00:27PM -0400, Steven Rostedt wrote:
> On Thu, 14 Mar 2024 15:39:28 +0100
> Paolo Abeni <pabeni@redhat.com> wrote:
> 
> > On Wed, 2024-03-13 at 09:34 -0400, Steven Rostedt wrote:

...

> > > Fixes: d8355240cf8fb ("net: hns3: add trace event support for PF/VF mailbox")  
> > 
> > checkpactch in strict mode complains the hash is not 12 char long.
> 
> Hmm, I wonder why my git blame gives me 13 characters in the sha. (I cut
> and pasted it from git blame). My git config has:
> 
> [core]  
>         abbrev = 12

I wonder if there is a collusion at 12 chars in your local tree.

...
diff mbox series

Patch

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_trace.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_trace.h
index 8510b88d4982..f3cd5a376eca 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_trace.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_trace.h
@@ -24,7 +24,7 @@  TRACE_EVENT(hclge_pf_mbx_get,
 		__field(u8, code)
 		__field(u8, subcode)
 		__string(pciname, pci_name(hdev->pdev))
-		__string(devname, &hdev->vport[0].nic.kinfo.netdev->name)
+		__string(devname, hdev->vport[0].nic.kinfo.netdev->name)
 		__array(u32, mbx_data, PF_GET_MBX_LEN)
 	),
 
@@ -33,7 +33,7 @@  TRACE_EVENT(hclge_pf_mbx_get,
 		__entry->code = req->msg.code;
 		__entry->subcode = req->msg.subcode;
 		__assign_str(pciname, pci_name(hdev->pdev));
-		__assign_str(devname, &hdev->vport[0].nic.kinfo.netdev->name);
+		__assign_str(devname, hdev->vport[0].nic.kinfo.netdev->name);
 		memcpy(__entry->mbx_data, req,
 		       sizeof(struct hclge_mbx_vf_to_pf_cmd));
 	),
@@ -56,7 +56,7 @@  TRACE_EVENT(hclge_pf_mbx_send,
 		__field(u8, vfid)
 		__field(u16, code)
 		__string(pciname, pci_name(hdev->pdev))
-		__string(devname, &hdev->vport[0].nic.kinfo.netdev->name)
+		__string(devname, hdev->vport[0].nic.kinfo.netdev->name)
 		__array(u32, mbx_data, PF_SEND_MBX_LEN)
 	),
 
@@ -64,7 +64,7 @@  TRACE_EVENT(hclge_pf_mbx_send,
 		__entry->vfid = req->dest_vfid;
 		__entry->code = le16_to_cpu(req->msg.code);
 		__assign_str(pciname, pci_name(hdev->pdev));
-		__assign_str(devname, &hdev->vport[0].nic.kinfo.netdev->name);
+		__assign_str(devname, hdev->vport[0].nic.kinfo.netdev->name);
 		memcpy(__entry->mbx_data, req,
 		       sizeof(struct hclge_mbx_pf_to_vf_cmd));
 	),
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_trace.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_trace.h
index 5d4895bb57a1..b259e95dd53c 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_trace.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_trace.h
@@ -23,7 +23,7 @@  TRACE_EVENT(hclge_vf_mbx_get,
 		__field(u8, vfid)
 		__field(u16, code)
 		__string(pciname, pci_name(hdev->pdev))
-		__string(devname, &hdev->nic.kinfo.netdev->name)
+		__string(devname, hdev->nic.kinfo.netdev->name)
 		__array(u32, mbx_data, VF_GET_MBX_LEN)
 	),
 
@@ -31,7 +31,7 @@  TRACE_EVENT(hclge_vf_mbx_get,
 		__entry->vfid = req->dest_vfid;
 		__entry->code = le16_to_cpu(req->msg.code);
 		__assign_str(pciname, pci_name(hdev->pdev));
-		__assign_str(devname, &hdev->nic.kinfo.netdev->name);
+		__assign_str(devname, hdev->nic.kinfo.netdev->name);
 		memcpy(__entry->mbx_data, req,
 		       sizeof(struct hclge_mbx_pf_to_vf_cmd));
 	),
@@ -55,7 +55,7 @@  TRACE_EVENT(hclge_vf_mbx_send,
 		__field(u8, code)
 		__field(u8, subcode)
 		__string(pciname, pci_name(hdev->pdev))
-		__string(devname, &hdev->nic.kinfo.netdev->name)
+		__string(devname, hdev->nic.kinfo.netdev->name)
 		__array(u32, mbx_data, VF_SEND_MBX_LEN)
 	),
 
@@ -64,7 +64,7 @@  TRACE_EVENT(hclge_vf_mbx_send,
 		__entry->code = req->msg.code;
 		__entry->subcode = req->msg.subcode;
 		__assign_str(pciname, pci_name(hdev->pdev));
-		__assign_str(devname, &hdev->nic.kinfo.netdev->name);
+		__assign_str(devname, hdev->nic.kinfo.netdev->name);
 		memcpy(__entry->mbx_data, req,
 		       sizeof(struct hclge_mbx_vf_to_pf_cmd));
 	),