Synchronize code, Modify the review comments to increase the reliability of the code Signed-off-by: veega2022 <zhuweijia@huawei.com> (cherry picked from commit d2a23f9ffed0201385c7864b9cd58312fb395cb6)
103 lines
3.7 KiB
Diff
103 lines
3.7 KiB
Diff
From de71b27c71022e1051b1c3e85f849aedb13ec644 Mon Sep 17 00:00:00 2001
|
|
From: veega2022 <zhuweijia@huawei.com>
|
|
Date: Thu, 24 Oct 2024 20:52:48 +0800
|
|
Subject: [PATCH 26/27] hikptool: Rectify the compilation alarm.
|
|
|
|
Replace -Wextra with -Werror option.
|
|
|
|
Signed-off-by: veega2022 <zhuweijia@huawei.com>
|
|
---
|
|
CMakeLists.txt | 2 +-
|
|
net/hikp_net_lib.c | 3 ++-
|
|
net/nic/nic_dfx/hikp_nic_dfx.c | 5 +++--
|
|
net/nic/nic_ft/hikp_nic_port_fault.c | 2 +-
|
|
net/nic/nic_qos/hikp_nic_qos.c | 7 ++++---
|
|
5 files changed, 11 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index f2ffe6c..4fb82ca 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -11,7 +11,7 @@
|
|
|
|
project(hikptool C)
|
|
|
|
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -fPIC -fPIE -Wall -Wextra -fno-common -std=gnu11")
|
|
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -fPIC -fPIE -Wall -Werror -fno-common -std=gnu11")
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wfloat-equal -fstack-protector-strong -D_FORTIFY_SOURCE=2")
|
|
set(CMAKE_SKIP_RPATH TRUE)
|
|
|
|
diff --git a/net/hikp_net_lib.c b/net/hikp_net_lib.c
|
|
index fbf03bd..f4d4c2a 100644
|
|
--- a/net/hikp_net_lib.c
|
|
+++ b/net/hikp_net_lib.c
|
|
@@ -142,7 +142,8 @@ static bool check_dev_name_and_get_bdf(int sockfd, struct tool_target *target)
|
|
ifr.ifr_data = (char *)&drvinfo;
|
|
drvinfo.cmd = ETHTOOL_GDRVINFO;
|
|
|
|
- strncpy(ifr.ifr_name, target->dev_name, IFNAMSIZ - 1);
|
|
+ strncpy(ifr.ifr_name, target->dev_name, IFNAMSIZ);
|
|
+ ifr.ifr_name[IFNAMSIZ - 1] = '\0';
|
|
|
|
if (ioctl(sockfd, SIOCETHTOOL, &ifr) < 0)
|
|
return false;
|
|
diff --git a/net/nic/nic_dfx/hikp_nic_dfx.c b/net/nic/nic_dfx/hikp_nic_dfx.c
|
|
index 67a5fe1..c42b8e7 100644
|
|
--- a/net/nic/nic_dfx/hikp_nic_dfx.c
|
|
+++ b/net/nic/nic_dfx/hikp_nic_dfx.c
|
|
@@ -17,6 +17,7 @@
|
|
#include <sys/types.h>
|
|
#include <ifaddrs.h>
|
|
#include <unistd.h>
|
|
+#include <inttypes.h>
|
|
#include "tool_cmd.h"
|
|
#include "hikp_net_lib.h"
|
|
#include "hikp_nic_dfx.h"
|
|
@@ -626,10 +627,10 @@ static void hikp_nic_dfx_print_b64(struct nic_dfx_type_head *type_head, uint32_t
|
|
(HI_GET_BITFIELD((uint64_t)reg_data[i], DFX_REG_VALUE_OFF,
|
|
DFX_REG_VALUE_MASK) << BIT_NUM_OF_WORD);
|
|
if (reg_list != NULL) {
|
|
- printf("%-30s\t0x%04x\t0x%016lx\n", reg_list->name, offset, value);
|
|
+ printf("%-30s\t0x%04x\t0x%" PRIx64 "\n", reg_list->name, offset, value);
|
|
reg_list++;
|
|
} else {
|
|
- printf("%-30s\t0x%04x\t0x%08x\n", "", offset, value);
|
|
+ printf("%-30s\t0x%04x\t0x%" PRIx64 "\n", "", offset, value);
|
|
}
|
|
}
|
|
}
|
|
diff --git a/net/nic/nic_ft/hikp_nic_port_fault.c b/net/nic/nic_ft/hikp_nic_port_fault.c
|
|
index 6561e3e..5f78cdd 100644
|
|
--- a/net/nic/nic_ft/hikp_nic_port_fault.c
|
|
+++ b/net/nic/nic_ft/hikp_nic_port_fault.c
|
|
@@ -41,7 +41,7 @@ static int hikp_nic_port_fault_query(const struct bdf_t *bdf,
|
|
}
|
|
|
|
rsp = (struct nic_port_fault_rsp *)cmd_ret->rsp_data;
|
|
- *info = *(struct nic_port_fault_status *)rsp->data;
|
|
+ memcpy(info, rsp->data, sizeof(struct nic_port_fault_status));
|
|
hikp_cmd_free(&cmd_ret);
|
|
|
|
return 0;
|
|
diff --git a/net/nic/nic_qos/hikp_nic_qos.c b/net/nic/nic_qos/hikp_nic_qos.c
|
|
index 32f251e..c620a08 100644
|
|
--- a/net/nic/nic_qos/hikp_nic_qos.c
|
|
+++ b/net/nic/nic_qos/hikp_nic_qos.c
|
|
@@ -286,9 +286,10 @@ static void hikp_nic_qos_cmd_execute(struct major_cmd_ctrl *self)
|
|
memset(revision_id, 0, MAX_PCI_ID_LEN + 1);
|
|
ret = get_revision_id_by_bdf(bdf, revision_id, sizeof(g_qos_param.revision_id));
|
|
// show pfc threshold as default if get revision_id error
|
|
- if (ret)
|
|
- strncpy(g_qos_param.revision_id, HIKP_IEP_REVISION,
|
|
- MAX_PCI_REVISION_LEN);
|
|
+ if (ret) {
|
|
+ strncpy(g_qos_param.revision_id, HIKP_IEP_REVISION, MAX_PCI_REVISION_LEN);
|
|
+ g_qos_param.revision_id[MAX_PCI_ID_LEN] = '\0';
|
|
+ }
|
|
|
|
printf("############## NIC QOS: %s info ############\n", qos_cmd->feature_name);
|
|
qos_cmd->show(&qos_data);
|
|
--
|
|
2.45.0.windows.1
|
|
|