netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/4] net: hns3: There are some cleanup for the HNS3 ethernet driver
@ 2023-06-12 12:23 Hao Lan
  2023-06-12 12:23 ` [PATCH net-next v2 1/4] net: hns3: refine the tcam key convert handle Hao Lan
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Hao Lan @ 2023-06-12 12:23 UTC (permalink / raw)
  To: netdev
  Cc: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni,
	richardcochran, lanhao, wangpeiyang1, shenjian15, chenhao418,
	simon.horman, wangjie125, yuanjilin, cai.huoqing, xiujianfeng

There are some cleanup for the HNS3 ethernet driver.

Hao Chen (2):
  net: hns3: fix hns3 driver header file not self-contained issue
  net: hns3: fix strncpy() not using dest-buf length as length issue

Jian Shen (1):
  net: hns3: refine the tcam key convert handle

Peiyang Wang (1):
  net: hns3: clear hns unused parameter alarm

 .../net/ethernet/hisilicon/hns3/hclge_mbx.h   |  4 +-
 drivers/net/ethernet/hisilicon/hns3/hnae3.h   |  3 +-
 .../hns3/hns3_common/hclge_comm_rss.c         |  3 +-
 .../hns3/hns3_common/hclge_comm_rss.h         |  3 +-
 .../hns3/hns3_common/hclge_comm_tqp_stats.h   |  2 +
 .../ethernet/hisilicon/hns3/hns3_debugfs.c    | 36 ++++++++++----
 .../net/ethernet/hisilicon/hns3/hns3_enet.c   |  2 +-
 .../net/ethernet/hisilicon/hns3/hns3_enet.h   |  3 ++
 .../ethernet/hisilicon/hns3/hns3_ethtool.c    |  7 ++-
 .../hisilicon/hns3/hns3pf/hclge_debugfs.c     | 29 ++++++++++--
 .../hisilicon/hns3/hns3pf/hclge_main.c        | 47 ++++++++-----------
 .../hisilicon/hns3/hns3pf/hclge_main.h        | 11 ++---
 .../hisilicon/hns3/hns3pf/hclge_ptp.h         |  5 +-
 .../hisilicon/hns3/hns3vf/hclgevf_main.c      | 14 ++----
 14 files changed, 96 insertions(+), 73 deletions(-)

-- 
2.30.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH net-next v2 1/4] net: hns3: refine the tcam key convert handle
  2023-06-12 12:23 [PATCH net-next v2 0/4] net: hns3: There are some cleanup for the HNS3 ethernet driver Hao Lan
@ 2023-06-12 12:23 ` Hao Lan
  2023-06-13 10:03   ` Simon Horman
  2023-06-12 12:23 ` [PATCH net-next v2 2/4] net: hns3: fix hns3 driver header file not self-contained issue Hao Lan
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Hao Lan @ 2023-06-12 12:23 UTC (permalink / raw)
  To: netdev
  Cc: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni,
	richardcochran, lanhao, wangpeiyang1, shenjian15, chenhao418,
	simon.horman, wangjie125, yuanjilin, cai.huoqing, xiujianfeng

From: Jian Shen <shenjian15@huawei.com>

The result of expression '(k ^ ~v)  & k' is exactly
the same with  'k & v', so simplify it.
(k ^ ~v) & k == k & v
The truth table (in non table form):
k == 0, v == 0:
  (k ^ ~v) & k == (0 ^ ~0) & 0 == (0 ^ 1) & 0 == 1 & 0 == 0
  k & v == 0 & 0 == 0

k == 0, v == 1:
  (k ^ ~v) & k == (0 ^ ~1) & 0 == (0 ^ 0) & 0 == 1 & 0 == 0
  k & v == 0 & 1 == 0

k == 1, v == 0:
  (k ^ ~v) & k == (1 ^ ~0) & 1 == (1 ^ 1) & 1 == 0 & 1 == 0
  k & v == 1 & 0 == 0

k == 1, v == 1:
  (k ^ ~v) & k == (1 ^ ~1) & 1 == (1 ^ 0) & 1 == 1 & 1 == 1
  k & v == 1 & 1 == 1

ChangeLog:
v1->v2:
Fixed the comment description error and added
the truth table in the comment.
suggested by Simon Horman.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Hao Lan <lanhao@huawei.com>
---
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h   | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
index 81aa6b0facf5..6a43d1515585 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
@@ -835,15 +835,10 @@ struct hclge_vf_vlan_cfg {
  * Then for input key(k) and mask(v), we can calculate the value by
  * the formulae:
  *	x = (~k) & v
- *	y = (k ^ ~v) & k
+ *	y = k & v
  */
-#define calc_x(x, k, v) (x = ~(k) & (v))
-#define calc_y(y, k, v) \
-	do { \
-		const typeof(k) _k_ = (k); \
-		const typeof(v) _v_ = (v); \
-		(y) = (_k_ ^ ~_v_) & (_k_); \
-	} while (0)
+#define calc_x(x, k, v) ((x) = ~(k) & (v))
+#define calc_y(y, k, v) ((y) = (k) & (v))
 
 #define HCLGE_MAC_STATS_FIELD_OFF(f) (offsetof(struct hclge_mac_stats, f))
 #define HCLGE_STATS_READ(p, offset) (*(u64 *)((u8 *)(p) + (offset)))
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH net-next v2 2/4] net: hns3: fix hns3 driver header file not self-contained issue
  2023-06-12 12:23 [PATCH net-next v2 0/4] net: hns3: There are some cleanup for the HNS3 ethernet driver Hao Lan
  2023-06-12 12:23 ` [PATCH net-next v2 1/4] net: hns3: refine the tcam key convert handle Hao Lan
@ 2023-06-12 12:23 ` Hao Lan
  2023-06-13 17:41   ` Simon Horman
  2023-06-12 12:23 ` [PATCH net-next v2 3/4] net: hns3: fix strncpy() not using dest-buf length as length issue Hao Lan
  2023-06-12 12:23 ` [PATCH net-next v2 4/4] net: hns3: clear hns unused parameter alarm Hao Lan
  3 siblings, 1 reply; 12+ messages in thread
From: Hao Lan @ 2023-06-12 12:23 UTC (permalink / raw)
  To: netdev
  Cc: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni,
	richardcochran, lanhao, wangpeiyang1, shenjian15, chenhao418,
	simon.horman, wangjie125, yuanjilin, cai.huoqing, xiujianfeng

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(-)

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
 
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH net-next v2 3/4] net: hns3: fix strncpy() not using dest-buf length as length issue
  2023-06-12 12:23 [PATCH net-next v2 0/4] net: hns3: There are some cleanup for the HNS3 ethernet driver Hao Lan
  2023-06-12 12:23 ` [PATCH net-next v2 1/4] net: hns3: refine the tcam key convert handle Hao Lan
  2023-06-12 12:23 ` [PATCH net-next v2 2/4] net: hns3: fix hns3 driver header file not self-contained issue Hao Lan
@ 2023-06-12 12:23 ` Hao Lan
  2023-06-14 10:34   ` Paolo Abeni
  2023-06-14 10:36   ` Paolo Abeni
  2023-06-12 12:23 ` [PATCH net-next v2 4/4] net: hns3: clear hns unused parameter alarm Hao Lan
  3 siblings, 2 replies; 12+ messages in thread
From: Hao Lan @ 2023-06-12 12:23 UTC (permalink / raw)
  To: netdev
  Cc: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni,
	richardcochran, lanhao, wangpeiyang1, shenjian15, chenhao418,
	simon.horman, wangjie125, yuanjilin, cai.huoqing, xiujianfeng

From: Hao Chen <chenhao418@huawei.com>

Now, strncpy() in hns3_dbg_fill_content() use src-length as copy-length,
it may result in dest-buf overflow.

This patch is to fix intel compile warning for csky-linux-gcc (GCC) 12.1.0
compiler.

The warning reports as below:

hclge_debugfs.c:92:25: warning: 'strncpy' specified bound depends on
the length of the source argument [-Wstringop-truncation]

strncpy(pos, items[i].name, strlen(items[i].name));

hclge_debugfs.c:90:25: warning: 'strncpy' output truncated before
terminating nul copying as many bytes from a string as its length
[-Wstringop-truncation]

strncpy(pos, result[i], strlen(result[i]));

strncpy() use src-length as copy-length, it may result in
dest-buf overflow.

So,this patch add some values check to avoid this issue.

ChangeLog:
v1->v2:
Use strcpy substitutes for memcpy
suggested by Simon Horman.

Signed-off-by: Hao Chen <chenhao418@huawei.com>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/lkml/202207170606.7WtHs9yS-lkp@intel.com/T/
Signed-off-by: Hao Lan <lanhao@huawei.com>
---
 .../ethernet/hisilicon/hns3/hns3_debugfs.c    | 31 ++++++++++++++-----
 .../hisilicon/hns3/hns3pf/hclge_debugfs.c     | 29 ++++++++++++++---
 2 files changed, 48 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
index d385ffc21876..0749515e270b 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
@@ -438,19 +438,36 @@ static void hns3_dbg_fill_content(char *content, u16 len,
 				  const struct hns3_dbg_item *items,
 				  const char **result, u16 size)
 {
+#define HNS3_DBG_LINE_END_LEN	2
 	char *pos = content;
+	u16 item_len;
 	u16 i;
 
+	if (!len) {
+		return;
+	} else if (len <= HNS3_DBG_LINE_END_LEN) {
+		*pos++ = '\0';
+		return;
+	}
+
 	memset(content, ' ', len);
-	for (i = 0; i < size; i++) {
-		if (result)
-			strncpy(pos, result[i], strlen(result[i]));
-		else
-			strncpy(pos, items[i].name, strlen(items[i].name));
+	len -= HNS3_DBG_LINE_END_LEN;
 
-		pos += strlen(items[i].name) + items[i].interval;
+	for (i = 0; i < size; i++) {
+		item_len = strlen(items[i].name) + items[i].interval;
+		if (len < item_len)
+			break;
+
+		if (result) {
+			if (item_len < strlen(result[i]))
+				break;
+			strcpy(pos, result[i]);
+		} else {
+			strcpy(pos, items[i].name);
+		}
+		pos += item_len;
+		len -= item_len;
 	}
-
 	*pos++ = '\n';
 	*pos++ = '\0';
 }
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
index a0b46e7d863e..0a1cc7084602 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
@@ -88,16 +88,35 @@ static void hclge_dbg_fill_content(char *content, u16 len,
 				   const struct hclge_dbg_item *items,
 				   const char **result, u16 size)
 {
+#define HCLGE_DBG_LINE_END_LEN	2
 	char *pos = content;
+	u16 item_len;
 	u16 i;
 
+	if (!len) {
+		return;
+	} else if (len <= HCLGE_DBG_LINE_END_LEN) {
+		*pos++ = '\0';
+		return;
+	}
+
 	memset(content, ' ', len);
+	len -= HCLGE_DBG_LINE_END_LEN;
+
 	for (i = 0; i < size; i++) {
-		if (result)
-			strncpy(pos, result[i], strlen(result[i]));
-		else
-			strncpy(pos, items[i].name, strlen(items[i].name));
-		pos += strlen(items[i].name) + items[i].interval;
+		item_len = strlen(items[i].name) + items[i].interval;
+		if (len < item_len)
+			break;
+
+		if (result) {
+			if (item_len < strlen(result[i]))
+				break;
+			strcpy(pos, result[i]);
+		} else {
+			strcpy(pos, items[i].name);
+		}
+		pos += item_len;
+		len -= item_len;
 	}
 	*pos++ = '\n';
 	*pos++ = '\0';
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH net-next v2 4/4] net: hns3: clear hns unused parameter alarm
  2023-06-12 12:23 [PATCH net-next v2 0/4] net: hns3: There are some cleanup for the HNS3 ethernet driver Hao Lan
                   ` (2 preceding siblings ...)
  2023-06-12 12:23 ` [PATCH net-next v2 3/4] net: hns3: fix strncpy() not using dest-buf length as length issue Hao Lan
@ 2023-06-12 12:23 ` Hao Lan
  3 siblings, 0 replies; 12+ messages in thread
From: Hao Lan @ 2023-06-12 12:23 UTC (permalink / raw)
  To: netdev
  Cc: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni,
	richardcochran, lanhao, wangpeiyang1, shenjian15, chenhao418,
	simon.horman, wangjie125, yuanjilin, cai.huoqing, xiujianfeng

From: Peiyang Wang <wangpeiyang1@huawei.com>

Several functions in the hns3 driver have unused parameters.
The compiler will warn about them when building
with -Wunused-parameter option of hns3.

ChangeLog:
v1->v2:
Delete topic-independent code
suggested by Simon Horman.

Signed-off-by: Peiyang Wang <wangpeiyang1@huawei.com>
Signed-off-by: Hao Lan <lanhao@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h   |  3 +-
 .../hns3/hns3_common/hclge_comm_rss.c         |  3 +-
 .../hns3/hns3_common/hclge_comm_rss.h         |  3 +-
 .../ethernet/hisilicon/hns3/hns3_debugfs.c    |  5 +-
 .../net/ethernet/hisilicon/hns3/hns3_enet.c   |  2 +-
 .../ethernet/hisilicon/hns3/hns3_ethtool.c    |  7 ++-
 .../hisilicon/hns3/hns3pf/hclge_main.c        | 47 ++++++++-----------
 .../hisilicon/hns3/hns3vf/hclgevf_main.c      | 14 ++----
 8 files changed, 33 insertions(+), 51 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index 9c9c72dc57e0..b99d75260d59 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -647,8 +647,7 @@ struct hnae3_ae_ops {
 	int (*rm_mc_addr)(struct hnae3_handle *handle,
 			  const unsigned char *addr);
 	void (*set_tso_stats)(struct hnae3_handle *handle, int enable);
-	void (*update_stats)(struct hnae3_handle *handle,
-			     struct net_device_stats *net_stats);
+	void (*update_stats)(struct hnae3_handle *handle);
 	void (*get_stats)(struct hnae3_handle *handle, u64 *data);
 	void (*get_mac_stats)(struct hnae3_handle *handle,
 			      struct hns3_mac_stats *mac_stats);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_rss.c b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_rss.c
index ae2736549526..b4ae2160aff4 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_rss.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_rss.c
@@ -305,8 +305,7 @@ int hclge_comm_set_rss_indir_table(struct hnae3_ae_dev *ae_dev,
 	return 0;
 }
 
-int hclge_comm_set_rss_input_tuple(struct hnae3_handle *nic,
-				   struct hclge_comm_hw *hw, bool is_pf,
+int hclge_comm_set_rss_input_tuple(struct hclge_comm_hw *hw,
 				   struct hclge_comm_rss_cfg *rss_cfg)
 {
 	struct hclge_comm_rss_input_tuple_cmd *req;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_rss.h b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_rss.h
index 92af3d2980d3..cdafa63fe38b 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_rss.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_rss.h
@@ -112,8 +112,7 @@ int hclge_comm_init_rss_tuple_cmd(struct hclge_comm_rss_cfg *rss_cfg,
 				  struct hnae3_ae_dev *ae_dev,
 				  struct hclge_comm_rss_input_tuple_cmd *req);
 u64 hclge_comm_convert_rss_tuple(u8 tuple_sets);
-int hclge_comm_set_rss_input_tuple(struct hnae3_handle *nic,
-				   struct hclge_comm_hw *hw, bool is_pf,
+int hclge_comm_set_rss_input_tuple(struct hclge_comm_hw *hw,
 				   struct hclge_comm_rss_cfg *rss_cfg);
 int hclge_comm_set_rss_indir_table(struct hnae3_ae_dev *ae_dev,
 				   struct hclge_comm_hw *hw, const u16 *indir);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
index 0749515e270b..56167f006f66 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
@@ -958,8 +958,7 @@ static const struct hns3_dbg_item tx_bd_info_items[] = {
 	{ "MSS_HW_CSUM", 0 },
 };
 
-static void hns3_dump_tx_bd_info(struct hns3_nic_priv *priv,
-				 struct hns3_desc *desc, char **result, int idx)
+static void hns3_dump_tx_bd_info(struct hns3_desc *desc, char **result, int idx)
 {
 	unsigned int j = 0;
 
@@ -1008,7 +1007,7 @@ static int hns3_dbg_tx_bd_info(struct hns3_dbg_data *d, char *buf, int len)
 	for (i = 0; i < ring->desc_num; i++) {
 		desc = &ring->desc[i];
 
-		hns3_dump_tx_bd_info(priv, desc, result, i);
+		hns3_dump_tx_bd_info(desc, result, i);
 		hns3_dbg_fill_content(content, sizeof(content),
 				      tx_bd_info_items, (const char **)result,
 				      ARRAY_SIZE(tx_bd_info_items));
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index b676496ec6d7..9f6890059666 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -2538,7 +2538,7 @@ static void hns3_nic_get_stats64(struct net_device *netdev,
 	if (test_bit(HNS3_NIC_STATE_DOWN, &priv->state))
 		return;
 
-	handle->ae_algo->ops->update_stats(handle, &netdev->stats);
+	handle->ae_algo->ops->update_stats(handle);
 
 	memset(&ring_total_stats, 0, sizeof(ring_total_stats));
 	for (idx = 0; idx < queue_num; idx++) {
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 51d1278b18f6..407d30ee55d2 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -228,7 +228,7 @@ static u32 hns3_lb_check_rx_ring(struct hns3_nic_priv *priv, u32 budget)
 }
 
 static void hns3_lb_clear_tx_ring(struct hns3_nic_priv *priv, u32 start_ringid,
-				  u32 end_ringid, u32 budget)
+				  u32 end_ringid)
 {
 	u32 i;
 
@@ -295,8 +295,7 @@ static int hns3_lp_run_test(struct net_device *ndev, enum hnae3_loop mode)
 
 out:
 	hns3_lb_clear_tx_ring(priv, HNS3_NIC_LB_TEST_RING_ID,
-			      HNS3_NIC_LB_TEST_RING_ID,
-			      HNS3_NIC_LB_TEST_PKT_NUM);
+			      HNS3_NIC_LB_TEST_RING_ID);
 
 	kfree_skb(skb);
 	return ret_val;
@@ -618,7 +617,7 @@ static void hns3_get_stats(struct net_device *netdev,
 		return;
 	}
 
-	h->ae_algo->ops->update_stats(h, &netdev->stats);
+	h->ae_algo->ops->update_stats(h);
 
 	/* get per-queue stats */
 	p = hns3_get_stats_tqps(h, p);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 2689b108f7df..bf675c15fbb9 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -689,8 +689,7 @@ static void hclge_update_stats_for_all(struct hclge_dev *hdev)
 			"Update MAC stats fail, status = %d.\n", status);
 }
 
-static void hclge_update_stats(struct hnae3_handle *handle,
-			       struct net_device_stats *net_stats)
+static void hclge_update_stats(struct hnae3_handle *handle)
 {
 	struct hclge_vport *vport = hclge_get_vport(handle);
 	struct hclge_dev *hdev = vport->back;
@@ -824,7 +823,7 @@ static void hclge_get_mac_stat(struct hnae3_handle *handle,
 	struct hclge_vport *vport = hclge_get_vport(handle);
 	struct hclge_dev *hdev = vport->back;
 
-	hclge_update_stats(handle, NULL);
+	hclge_update_stats(handle);
 
 	mac_stats->tx_pause_cnt = hdev->mac_stats.mac_tx_mac_pause_num;
 	mac_stats->rx_pause_cnt = hdev->mac_stats.mac_rx_mac_pause_num;
@@ -4965,9 +4964,7 @@ int hclge_rss_init_hw(struct hclge_dev *hdev)
 	if (ret)
 		return ret;
 
-	ret = hclge_comm_set_rss_input_tuple(&hdev->vport[0].nic,
-					     &hdev->hw.hw, true,
-					     &hdev->rss_cfg);
+	ret = hclge_comm_set_rss_input_tuple(&hdev->hw.hw, &hdev->rss_cfg);
 	if (ret)
 		return ret;
 
@@ -6243,8 +6240,7 @@ static int hclge_fd_check_spec(struct hclge_dev *hdev,
 	return hclge_fd_check_ext_tuple(hdev, fs, unused_tuple);
 }
 
-static void hclge_fd_get_tcpip4_tuple(struct hclge_dev *hdev,
-				      struct ethtool_rx_flow_spec *fs,
+static void hclge_fd_get_tcpip4_tuple(struct ethtool_rx_flow_spec *fs,
 				      struct hclge_fd_rule *rule, u8 ip_proto)
 {
 	rule->tuples.src_ip[IPV4_INDEX] =
@@ -6273,8 +6269,7 @@ static void hclge_fd_get_tcpip4_tuple(struct hclge_dev *hdev,
 	rule->tuples_mask.ip_proto = 0xFF;
 }
 
-static void hclge_fd_get_ip4_tuple(struct hclge_dev *hdev,
-				   struct ethtool_rx_flow_spec *fs,
+static void hclge_fd_get_ip4_tuple(struct ethtool_rx_flow_spec *fs,
 				   struct hclge_fd_rule *rule)
 {
 	rule->tuples.src_ip[IPV4_INDEX] =
@@ -6297,8 +6292,7 @@ static void hclge_fd_get_ip4_tuple(struct hclge_dev *hdev,
 	rule->tuples_mask.ether_proto = 0xFFFF;
 }
 
-static void hclge_fd_get_tcpip6_tuple(struct hclge_dev *hdev,
-				      struct ethtool_rx_flow_spec *fs,
+static void hclge_fd_get_tcpip6_tuple(struct ethtool_rx_flow_spec *fs,
 				      struct hclge_fd_rule *rule, u8 ip_proto)
 {
 	be32_to_cpu_array(rule->tuples.src_ip, fs->h_u.tcp_ip6_spec.ip6src,
@@ -6327,8 +6321,7 @@ static void hclge_fd_get_tcpip6_tuple(struct hclge_dev *hdev,
 	rule->tuples_mask.ip_proto = 0xFF;
 }
 
-static void hclge_fd_get_ip6_tuple(struct hclge_dev *hdev,
-				   struct ethtool_rx_flow_spec *fs,
+static void hclge_fd_get_ip6_tuple(struct ethtool_rx_flow_spec *fs,
 				   struct hclge_fd_rule *rule)
 {
 	be32_to_cpu_array(rule->tuples.src_ip, fs->h_u.usr_ip6_spec.ip6src,
@@ -6351,8 +6344,7 @@ static void hclge_fd_get_ip6_tuple(struct hclge_dev *hdev,
 	rule->tuples_mask.ether_proto = 0xFFFF;
 }
 
-static void hclge_fd_get_ether_tuple(struct hclge_dev *hdev,
-				     struct ethtool_rx_flow_spec *fs,
+static void hclge_fd_get_ether_tuple(struct ethtool_rx_flow_spec *fs,
 				     struct hclge_fd_rule *rule)
 {
 	ether_addr_copy(rule->tuples.src_mac, fs->h_u.ether_spec.h_source);
@@ -6388,8 +6380,7 @@ static void hclge_fd_get_user_def_tuple(struct hclge_fd_user_def_info *info,
 	rule->ep.user_def = *info;
 }
 
-static int hclge_fd_get_tuple(struct hclge_dev *hdev,
-			      struct ethtool_rx_flow_spec *fs,
+static int hclge_fd_get_tuple(struct ethtool_rx_flow_spec *fs,
 			      struct hclge_fd_rule *rule,
 			      struct hclge_fd_user_def_info *info)
 {
@@ -6397,31 +6388,31 @@ static int hclge_fd_get_tuple(struct hclge_dev *hdev,
 
 	switch (flow_type) {
 	case SCTP_V4_FLOW:
-		hclge_fd_get_tcpip4_tuple(hdev, fs, rule, IPPROTO_SCTP);
+		hclge_fd_get_tcpip4_tuple(fs, rule, IPPROTO_SCTP);
 		break;
 	case TCP_V4_FLOW:
-		hclge_fd_get_tcpip4_tuple(hdev, fs, rule, IPPROTO_TCP);
+		hclge_fd_get_tcpip4_tuple(fs, rule, IPPROTO_TCP);
 		break;
 	case UDP_V4_FLOW:
-		hclge_fd_get_tcpip4_tuple(hdev, fs, rule, IPPROTO_UDP);
+		hclge_fd_get_tcpip4_tuple(fs, rule, IPPROTO_UDP);
 		break;
 	case IP_USER_FLOW:
-		hclge_fd_get_ip4_tuple(hdev, fs, rule);
+		hclge_fd_get_ip4_tuple(fs, rule);
 		break;
 	case SCTP_V6_FLOW:
-		hclge_fd_get_tcpip6_tuple(hdev, fs, rule, IPPROTO_SCTP);
+		hclge_fd_get_tcpip6_tuple(fs, rule, IPPROTO_SCTP);
 		break;
 	case TCP_V6_FLOW:
-		hclge_fd_get_tcpip6_tuple(hdev, fs, rule, IPPROTO_TCP);
+		hclge_fd_get_tcpip6_tuple(fs, rule, IPPROTO_TCP);
 		break;
 	case UDP_V6_FLOW:
-		hclge_fd_get_tcpip6_tuple(hdev, fs, rule, IPPROTO_UDP);
+		hclge_fd_get_tcpip6_tuple(fs, rule, IPPROTO_UDP);
 		break;
 	case IPV6_USER_FLOW:
-		hclge_fd_get_ip6_tuple(hdev, fs, rule);
+		hclge_fd_get_ip6_tuple(fs, rule);
 		break;
 	case ETHER_FLOW:
-		hclge_fd_get_ether_tuple(hdev, fs, rule);
+		hclge_fd_get_ether_tuple(fs, rule);
 		break;
 	default:
 		return -EOPNOTSUPP;
@@ -6578,7 +6569,7 @@ static int hclge_add_fd_entry(struct hnae3_handle *handle,
 	if (!rule)
 		return -ENOMEM;
 
-	ret = hclge_fd_get_tuple(hdev, fs, rule, &info);
+	ret = hclge_fd_get_tuple(fs, rule, &info);
 	if (ret) {
 		kfree(rule);
 		return ret;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index dd08989a4c7c..34f02ca8d1d2 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -121,8 +121,7 @@ static struct hclgevf_dev *hclgevf_ae_get_hdev(struct hnae3_handle *handle)
 		return container_of(handle, struct hclgevf_dev, nic);
 }
 
-static void hclgevf_update_stats(struct hnae3_handle *handle,
-				 struct net_device_stats *net_stats)
+static void hclgevf_update_stats(struct hnae3_handle *handle)
 {
 	struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
 	int status;
@@ -1645,8 +1644,7 @@ static void hclgevf_reset(struct hclgevf_dev *hdev)
 	hclgevf_reset_err_handle(hdev);
 }
 
-static enum hnae3_reset_type hclgevf_get_reset_level(struct hclgevf_dev *hdev,
-						     unsigned long *addr)
+static enum hnae3_reset_type hclgevf_get_reset_level(unsigned long *addr)
 {
 	enum hnae3_reset_type rst_level = HNAE3_NONE_RESET;
 
@@ -1685,8 +1683,7 @@ static void hclgevf_reset_event(struct pci_dev *pdev,
 
 	if (hdev->default_reset_request)
 		hdev->reset_level =
-			hclgevf_get_reset_level(hdev,
-						&hdev->default_reset_request);
+			hclgevf_get_reset_level(&hdev->default_reset_request);
 	else
 		hdev->reset_level = HNAE3_VF_FUNC_RESET;
 
@@ -1828,7 +1825,7 @@ static void hclgevf_reset_service_task(struct hclgevf_dev *hdev)
 
 		hdev->last_reset_time = jiffies;
 		hdev->reset_type =
-			hclgevf_get_reset_level(hdev, &hdev->reset_pending);
+			hclgevf_get_reset_level(&hdev->reset_pending);
 		if (hdev->reset_type != HNAE3_NONE_RESET)
 			hclgevf_reset(hdev);
 	} else if (test_and_clear_bit(HCLGEVF_RESET_REQUESTED,
@@ -2160,8 +2157,7 @@ static int hclgevf_rss_init_hw(struct hclgevf_dev *hdev)
 		if (ret)
 			return ret;
 
-		ret = hclge_comm_set_rss_input_tuple(&hdev->nic, &hdev->hw.hw,
-						     false, rss_cfg);
+		ret = hclge_comm_set_rss_input_tuple(&hdev->hw.hw, rss_cfg);
 		if (ret)
 			return ret;
 	}
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH net-next v2 1/4] net: hns3: refine the tcam key convert handle
  2023-06-12 12:23 ` [PATCH net-next v2 1/4] net: hns3: refine the tcam key convert handle Hao Lan
@ 2023-06-13 10:03   ` Simon Horman
  0 siblings, 0 replies; 12+ messages in thread
From: Simon Horman @ 2023-06-13 10:03 UTC (permalink / raw)
  To: Hao Lan
  Cc: netdev, yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni,
	richardcochran, wangpeiyang1, shenjian15, chenhao418, wangjie125,
	yuanjilin, cai.huoqing, xiujianfeng

On Mon, Jun 12, 2023 at 08:23:55PM +0800, Hao Lan wrote:
> From: Jian Shen <shenjian15@huawei.com>
> 
> The result of expression '(k ^ ~v)  & k' is exactly
> the same with  'k & v', so simplify it.
> (k ^ ~v) & k == k & v
> The truth table (in non table form):
> k == 0, v == 0:
>   (k ^ ~v) & k == (0 ^ ~0) & 0 == (0 ^ 1) & 0 == 1 & 0 == 0
>   k & v == 0 & 0 == 0
> 
> k == 0, v == 1:
>   (k ^ ~v) & k == (0 ^ ~1) & 0 == (0 ^ 0) & 0 == 1 & 0 == 0
>   k & v == 0 & 1 == 0
> 
> k == 1, v == 0:
>   (k ^ ~v) & k == (1 ^ ~0) & 1 == (1 ^ 1) & 1 == 0 & 1 == 0
>   k & v == 1 & 0 == 0
> 
> k == 1, v == 1:
>   (k ^ ~v) & k == (1 ^ ~1) & 1 == (1 ^ 0) & 1 == 1 & 1 == 1
>   k & v == 1 & 1 == 1
> 
> ChangeLog:
> v1->v2:
> Fixed the comment description error and added
> the truth table in the comment.
> suggested by Simon Horman.
> 
> Signed-off-by: Jian Shen <shenjian15@huawei.com>
> Signed-off-by: Hao Lan <lanhao@huawei.com>

Reviewed-by: Simon Horman <simon.horman@corigine.com>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH net-next v2 2/4] net: hns3: fix hns3 driver header file not self-contained issue
  2023-06-12 12:23 ` [PATCH net-next v2 2/4] net: hns3: fix hns3 driver header file not self-contained issue Hao Lan
@ 2023-06-13 17:41   ` Simon Horman
  2023-06-14 11:52     ` Hao Lan
  0 siblings, 1 reply; 12+ messages in thread
From: Simon Horman @ 2023-06-13 17:41 UTC (permalink / raw)
  To: Hao Lan
  Cc: netdev, yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni,
	richardcochran, wangpeiyang1, shenjian15, chenhao418, wangjie125,
	yuanjilin, cai.huoqing, xiujianfeng

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.

...

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH net-next v2 3/4] net: hns3: fix strncpy() not using dest-buf length as length issue
  2023-06-12 12:23 ` [PATCH net-next v2 3/4] net: hns3: fix strncpy() not using dest-buf length as length issue Hao Lan
@ 2023-06-14 10:34   ` Paolo Abeni
  2023-06-14 11:55     ` Hao Lan
  2023-06-21  6:38     ` Hao Lan
  2023-06-14 10:36   ` Paolo Abeni
  1 sibling, 2 replies; 12+ messages in thread
From: Paolo Abeni @ 2023-06-14 10:34 UTC (permalink / raw)
  To: Hao Lan, netdev
  Cc: yisen.zhuang, salil.mehta, davem, edumazet, kuba, richardcochran,
	wangpeiyang1, shenjian15, chenhao418, simon.horman, wangjie125,
	yuanjilin, cai.huoqing, xiujianfeng

On Mon, 2023-06-12 at 20:23 +0800, Hao Lan wrote:
> From: Hao Chen <chenhao418@huawei.com>
> 
> Now, strncpy() in hns3_dbg_fill_content() use src-length as copy-length,
> it may result in dest-buf overflow.
> 
> This patch is to fix intel compile warning for csky-linux-gcc (GCC) 12.1.0
> compiler.
> 
> The warning reports as below:
> 
> hclge_debugfs.c:92:25: warning: 'strncpy' specified bound depends on
> the length of the source argument [-Wstringop-truncation]
> 
> strncpy(pos, items[i].name, strlen(items[i].name));
> 
> hclge_debugfs.c:90:25: warning: 'strncpy' output truncated before
> terminating nul copying as many bytes from a string as its length
> [-Wstringop-truncation]
> 
> strncpy(pos, result[i], strlen(result[i]));
> 
> strncpy() use src-length as copy-length, it may result in
> dest-buf overflow.
> 
> So,this patch add some values check to avoid this issue.
> 
> ChangeLog:
> v1->v2:
> Use strcpy substitutes for memcpy
> suggested by Simon Horman.
> 
> Signed-off-by: Hao Chen <chenhao418@huawei.com>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/lkml/202207170606.7WtHs9yS-lkp@intel.com/T/
> Signed-off-by: Hao Lan <lanhao@huawei.com>
> ---
>  .../ethernet/hisilicon/hns3/hns3_debugfs.c    | 31 ++++++++++++++-----
>  .../hisilicon/hns3/hns3pf/hclge_debugfs.c     | 29 ++++++++++++++---
>  2 files changed, 48 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
> index d385ffc21876..0749515e270b 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
> @@ -438,19 +438,36 @@ static void hns3_dbg_fill_content(char *content, u16 len,
>  				  const struct hns3_dbg_item *items,
>  				  const char **result, u16 size)
>  {
> +#define HNS3_DBG_LINE_END_LEN	2

IMHO this macro should be defined outside the function (just before)
for better readability.

>  	char *pos = content;
> +	u16 item_len;
>  	u16 i;
>  
> +	if (!len) {
> +		return;
> +	} else if (len <= HNS3_DBG_LINE_END_LEN) {
> +		*pos++ = '\0';
> +		return;
> +	}
> +
>  	memset(content, ' ', len);
> -	for (i = 0; i < size; i++) {
> -		if (result)
> -			strncpy(pos, result[i], strlen(result[i]));
> -		else
> -			strncpy(pos, items[i].name, strlen(items[i].name));
> +	len -= HNS3_DBG_LINE_END_LEN;
>  
> -		pos += strlen(items[i].name) + items[i].interval;
> +	for (i = 0; i < size; i++) {
> +		item_len = strlen(items[i].name) + items[i].interval;
> +		if (len < item_len)
> +			break;
> +
> +		if (result) {
> +			if (item_len < strlen(result[i]))
> +				break;
> +			strcpy(pos, result[i]);
> +		} else {
> +			strcpy(pos, items[i].name);
> +		}
> +		pos += item_len;
> +		len -= item_len;

I think it would be better using 'strscpy' instead of papering over
more unsecure functions.

Thanks,

Paolo


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH net-next v2 3/4] net: hns3: fix strncpy() not using dest-buf length as length issue
  2023-06-12 12:23 ` [PATCH net-next v2 3/4] net: hns3: fix strncpy() not using dest-buf length as length issue Hao Lan
  2023-06-14 10:34   ` Paolo Abeni
@ 2023-06-14 10:36   ` Paolo Abeni
  1 sibling, 0 replies; 12+ messages in thread
From: Paolo Abeni @ 2023-06-14 10:36 UTC (permalink / raw)
  To: Hao Lan, netdev
  Cc: yisen.zhuang, salil.mehta, davem, edumazet, kuba, richardcochran,
	wangpeiyang1, shenjian15, chenhao418, simon.horman, wangjie125,
	yuanjilin, cai.huoqing, xiujianfeng

On Mon, 2023-06-12 at 20:23 +0800, Hao Lan wrote:
> From: Hao Chen <chenhao418@huawei.com>
> 
> Now, strncpy() in hns3_dbg_fill_content() use src-length as copy-length,
> it may result in dest-buf overflow.
> 
> This patch is to fix intel compile warning for csky-linux-gcc (GCC) 12.1.0
> compiler.
> 
> The warning reports as below:
> 
> hclge_debugfs.c:92:25: warning: 'strncpy' specified bound depends on
> the length of the source argument [-Wstringop-truncation]
> 
> strncpy(pos, items[i].name, strlen(items[i].name));
> 
> hclge_debugfs.c:90:25: warning: 'strncpy' output truncated before
> terminating nul copying as many bytes from a string as its length
> [-Wstringop-truncation]
> 
> strncpy(pos, result[i], strlen(result[i]));
> 
> strncpy() use src-length as copy-length, it may result in
> dest-buf overflow.
> 
> So,this patch add some values check to avoid this issue.
> 
> ChangeLog:
> v1->v2:
> Use strcpy substitutes for memcpy
> suggested by Simon Horman.

In the next revision, please move the changelog after the '---'
separator below, so that it will no included into the actual commit
message. (Applies to all the patch in the series)

Thanks!

Paolo


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH net-next v2 2/4] net: hns3: fix hns3 driver header file not self-contained issue
  2023-06-13 17:41   ` Simon Horman
@ 2023-06-14 11:52     ` Hao Lan
  0 siblings, 0 replies; 12+ messages in thread
From: Hao Lan @ 2023-06-14 11:52 UTC (permalink / raw)
  To: Simon Horman
  Cc: netdev, yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni,
	richardcochran, wangpeiyang1, shenjian15, chenhao418, wangjie125,
	yuanjilin, cai.huoqing, xiujianfeng



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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH net-next v2 3/4] net: hns3: fix strncpy() not using dest-buf length as length issue
  2023-06-14 10:34   ` Paolo Abeni
@ 2023-06-14 11:55     ` Hao Lan
  2023-06-21  6:38     ` Hao Lan
  1 sibling, 0 replies; 12+ messages in thread
From: Hao Lan @ 2023-06-14 11:55 UTC (permalink / raw)
  To: Paolo Abeni, netdev
  Cc: yisen.zhuang, salil.mehta, davem, edumazet, kuba, richardcochran,
	wangpeiyang1, shenjian15, chenhao418, simon.horman, wangjie125,
	yuanjilin, cai.huoqing, xiujianfeng



On 2023/6/14 18:34, Paolo Abeni wrote:
> On Mon, 2023-06-12 at 20:23 +0800, Hao Lan wrote:
> 
> I think it would be better using 'strscpy' instead of papering over
> more unsecure functions.
> 
> Thanks,
> 
> Paolo
> 
> .
> 
Hi Paolo Abeni,

We accept your suggestion,
thank you.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH net-next v2 3/4] net: hns3: fix strncpy() not using dest-buf length as length issue
  2023-06-14 10:34   ` Paolo Abeni
  2023-06-14 11:55     ` Hao Lan
@ 2023-06-21  6:38     ` Hao Lan
  1 sibling, 0 replies; 12+ messages in thread
From: Hao Lan @ 2023-06-21  6:38 UTC (permalink / raw)
  To: Paolo Abeni, netdev
  Cc: yisen.zhuang, salil.mehta, davem, edumazet, kuba, richardcochran,
	wangpeiyang1, shenjian15, chenhao418, simon.horman, wangjie125,
	yuanjilin, cai.huoqing, xiujianfeng



On 2023/6/14 18:34, Paolo Abeni wrote:
> On Mon, 2023-06-12 at 20:23 +0800, Hao Lan wrote:
>> From: Hao Chen <chenhao418@huawei.com>
>>
>> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
>> index d385ffc21876..0749515e270b 100644
>> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
>> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
>> @@ -438,19 +438,36 @@ static void hns3_dbg_fill_content(char *content, u16 len,
>>  				  const struct hns3_dbg_item *items,
>>  				  const char **result, u16 size)
>>  {
>> +#define HNS3_DBG_LINE_END_LEN	2
> 
> IMHO this macro should be defined outside the function (just before)
> for better readability.
> 

Hi Paolo Abeni,
Thank you for your advice. We use this macro style elsewhere in our code.
The style is consistent. Here we keep this macro style.

Yours,
Hao Lan

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-06-21  6:38 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-12 12:23 [PATCH net-next v2 0/4] net: hns3: There are some cleanup for the HNS3 ethernet driver Hao Lan
2023-06-12 12:23 ` [PATCH net-next v2 1/4] net: hns3: refine the tcam key convert handle Hao Lan
2023-06-13 10:03   ` Simon Horman
2023-06-12 12:23 ` [PATCH net-next v2 2/4] net: hns3: fix hns3 driver header file not self-contained issue Hao Lan
2023-06-13 17:41   ` Simon Horman
2023-06-14 11:52     ` Hao Lan
2023-06-12 12:23 ` [PATCH net-next v2 3/4] net: hns3: fix strncpy() not using dest-buf length as length issue Hao Lan
2023-06-14 10:34   ` Paolo Abeni
2023-06-14 11:55     ` Hao Lan
2023-06-21  6:38     ` Hao Lan
2023-06-14 10:36   ` Paolo Abeni
2023-06-12 12:23 ` [PATCH net-next v2 4/4] net: hns3: clear hns unused parameter alarm Hao Lan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).