diff mbox series

[net-next,v2,2/4] net: hns3: fix hns3 driver header file not self-contained issue

Message ID 20230612122358.10586-3-lanhao@huawei.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: hns3: There are some cleanup for the HNS3 ethernet driver | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
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: 9 this patch: 9
netdev/cc_maintainers warning 4 maintainers not CCed: llvm@lists.linux.dev ndesaulniers@google.com nathan@kernel.org trix@redhat.com
netdev/build_clang success Errors and warnings before: 8 this patch: 8
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 No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 10 this patch: 10
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 45 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Hao Lan June 12, 2023, 12:23 p.m. UTC
From: Hao Chen <chenhao418@huawei.com>

Hns3 driver header file uses the structure of other files, but does
not include corresponding file, which causes a check warning that the
header file is not self-contained by clang-tidy checker.

For example,

Use command clang-tidy -checks=-*,header-should-self-contain
-p $build_dir  $src_file

It reports:
Header file 'hclge_mbx.h' is not self contained.
It should include following headers: (1) 'hclgevf_main.h'
due to symbols 'struct hclgevf_dev'. The main source file is hns3_enet.c

Therefore, the required header file is included in the header file, and
the structure declaration is added to the header file to avoid cyclic
dependency of the header file.

ChangeLog:
v1->v2:
Add the clang-tidy command to be used in the comment
suggested by Simon Horman.

Signed-off-by: Hao Chen <chenhao418@huawei.com>
Signed-off-by: Hao Lan <lanhao@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h              | 4 +++-
 .../hisilicon/hns3/hns3_common/hclge_comm_tqp_stats.h        | 2 ++
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.h              | 3 +++
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.h       | 5 ++++-
 4 files changed, 12 insertions(+), 2 deletions(-)

Comments

Simon Horman June 13, 2023, 5:41 p.m. UTC | #1
On Mon, Jun 12, 2023 at 08:23:56PM +0800, Hao Lan wrote:
> From: Hao Chen <chenhao418@huawei.com>
> 
> Hns3 driver header file uses the structure of other files, but does
> not include corresponding file, which causes a check warning that the
> header file is not self-contained by clang-tidy checker.
> 
> For example,
> 
> Use command clang-tidy -checks=-*,header-should-self-contain
> -p $build_dir  $src_file

Hi Hao Lan,

I tried this with clang-tidy-16 and src_file=".../hns3_enet.c"
but i get an error:

  Error: no checks enabled.
  USAGE: clang-tidy-16 [options] <source0> [... <sourceN>]

I feel that I'm missing something obvious here.

...
Hao Lan June 14, 2023, 11:52 a.m. UTC | #2
On 2023/6/14 1:41, Simon Horman wrote:
> On Mon, Jun 12, 2023 at 08:23:56PM +0800, Hao Lan wrote:
>> From: Hao Chen <chenhao418@huawei.com>
>>
>> Hns3 driver header file uses the structure of other files, but does
>> not include corresponding file, which causes a check warning that the
>> header file is not self-contained by clang-tidy checker.
>>
>> For example,
>>
>> Use command clang-tidy -checks=-*,header-should-self-contain
>> -p $build_dir  $src_file
> 
> Hi Hao Lan,
> 
> I tried this with clang-tidy-16 and src_file=".../hns3_enet.c"
> but i get an error:
> 
>   Error: no checks enabled.
>   USAGE: clang-tidy-16 [options] <source0> [... <sourceN>]
> 
> I feel that I'm missing something obvious here.
> 
> ...
> .
> 
Hi Simon Horman,

This code is checked by our company's internal static check tool.
CodeArts Check can be used outside of our company for this check.
You can use the link and you can find CodeArts Check.
In the ruleset codechecknew, you can find the CodeArts Check C
recommendation ruleset, which the clangtidy G.INC.05 header should contain itself.
You can sign up for a new account and have an one-year try free.

Link: https://www.huaweicloud.com/intl/en-us/product/codecheck.html
Link: https://devcloud.cn-north-4.huaweicloud.com/codechecknew/ruleset/9e43befe8c2611edab16fa163e0fa374/config
diff mbox series

Patch

diff --git a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h
index abcd7877f7d2..487216aeae50 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h
@@ -7,6 +7,8 @@ 
 #include <linux/mutex.h>
 #include <linux/types.h>
 
+struct hclgevf_dev;
+
 enum HCLGE_MBX_OPCODE {
 	HCLGE_MBX_RESET = 0x01,		/* (VF -> PF) assert reset */
 	HCLGE_MBX_ASSERTING_RESET,	/* (PF -> VF) PF is asserting reset */
@@ -233,7 +235,7 @@  struct hclgevf_mbx_arq_ring {
 	__le16 msg_q[HCLGE_MBX_MAX_ARQ_MSG_NUM][HCLGE_MBX_MAX_ARQ_MSG_SIZE];
 };
 
-struct hclge_dev;
+struct hclge_vport;
 
 #define HCLGE_MBX_OPCODE_MAX 256
 struct hclge_mbx_ops_param {
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_tqp_stats.h b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_tqp_stats.h
index a46350162ee8..7aff1a544cf4 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_tqp_stats.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_tqp_stats.h
@@ -7,6 +7,8 @@ 
 #include <linux/etherdevice.h>
 #include "hnae3.h"
 
+struct hclge_comm_hw;
+
 /* each tqp has TX & RX two queues */
 #define HCLGE_COMM_QUEUE_PAIR_SIZE 2
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
index 88af34bbee34..1b360aa52e5d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
@@ -13,6 +13,9 @@ 
 
 struct iphdr;
 struct ipv6hdr;
+struct gre_base_hdr;
+struct tcphdr;
+struct udphdr;
 
 enum hns3_nic_state {
 	HNS3_NIC_STATE_TESTING,
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.h
index bbee74cd8404..bceb61c791a1 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.h
@@ -8,8 +8,11 @@ 
 #include <linux/net_tstamp.h>
 #include <linux/types.h>
 
-struct hclge_dev;
 struct ifreq;
+struct ethtool_ts_info;
+
+struct hnae3_handle;
+struct hclge_dev;
 
 #define HCLGE_PTP_REG_OFFSET	0x29000