1391 lines
54 KiB
Diff
1391 lines
54 KiB
Diff
|
|
From faccc8979f5a6e458b02c7865b9e3316b9facfd1 Mon Sep 17 00:00:00 2001
|
||
|
|
From: veega2022 <zhuweijia@huawei.com>
|
||
|
|
Date: Wed, 8 Nov 2023 20:43:06 +0800
|
||
|
|
Subject: [PATCH] hikptool: Resolved some centralized code review comments.
|
||
|
|
|
||
|
|
1. The ret variable may be a random value.
|
||
|
|
2. The unsigned variable judgment branch is redundant judgment.
|
||
|
|
3. Fix Magic Numbers.
|
||
|
|
4. The print format does not match.
|
||
|
|
5. After the pointer is released, a null value is assigned to the pointer to prevent it from being used again.
|
||
|
|
6. Delete unused variables.
|
||
|
|
7. The uint64_t print issue is rectified and PRIx64/PRIu64 is used.
|
||
|
|
8. Add 'const' to constant array.
|
||
|
|
9. Modifying File Permissions.Eliminate software privilege escalation risks.
|
||
|
|
|
||
|
|
Signed-off-by: veega2022 <zhuweijia@huawei.com>
|
||
|
|
---
|
||
|
|
cxl/func_lib/cxl_func/cxl_feature.c | 16 +++----
|
||
|
|
cxl/usr_cmd/cmd_analysis/cxl_cmd_cpa.c | 2 +-
|
||
|
|
libhikptdev/src/rciep/hikpt_rciep.c | 22 ++++-----
|
||
|
|
libhikptdev/src/rciep/hikpt_rciep.h | 2 +
|
||
|
|
net/hikp_net_lib.c | 33 +++++++------
|
||
|
|
net/hikp_net_lib.h | 6 +--
|
||
|
|
net/nic/nic_dfx/hikp_nic_dfx.c | 1 -
|
||
|
|
net/nic/nic_fd/hikp_nic_fd.c | 48 +++++++++----------
|
||
|
|
net/nic/nic_fec/hikp_nic_fec.c | 7 +--
|
||
|
|
net/nic/nic_info/hikp_nic_info.c | 9 ++--
|
||
|
|
net/nic/nic_log/hikp_nic_log.c | 2 +-
|
||
|
|
net/nic/nic_ppp/hikp_nic_ppp.c | 27 +++++++----
|
||
|
|
net/nic/nic_qos/hikp_nic_qos.c | 9 ++--
|
||
|
|
net/nic/nic_queue/hikp_nic_queue.c | 3 +-
|
||
|
|
net/nic/nic_rss/hikp_nic_rss.c | 3 +-
|
||
|
|
.../roce_ext_common/hikp_roce_ext_common.c | 12 +++--
|
||
|
|
net/roce/roce_gmv/hikp_roce_gmv.c | 8 ++--
|
||
|
|
net/roce/roce_mdb/hikp_roce_mdb.c | 1 -
|
||
|
|
net/roce/roce_qmm/hikp_roce_qmm.c | 8 ++--
|
||
|
|
net/roce/roce_scc/hikp_roce_scc.c | 6 +--
|
||
|
|
net/roce/roce_timer/hikp_roce_timer.c | 2 +-
|
||
|
|
net/roce/roce_trp/hikp_roce_trp.c | 18 ++++---
|
||
|
|
net/roce/roce_tsp/hikp_roce_tsp.c | 7 +--
|
||
|
|
net/ub/ub_crd/hikp_ub_crd.c | 1 -
|
||
|
|
net/ub/ub_ppp/hikp_unic_ppp.c | 5 ++
|
||
|
|
ossl/ossl_user_linux.c | 1 -
|
||
|
|
pcie/func_lib/pcie_func/pcie_link_ltssm.c | 3 +-
|
||
|
|
pcie/func_lib/pcie_func/pcie_link_ltssm.h | 1 +
|
||
|
|
pcie/func_lib/pcie_func/pcie_reg_dump.c | 4 +-
|
||
|
|
pcie/func_lib/pcie_func/pcie_statistics.c | 4 +-
|
||
|
|
sas/sas_func/sas_read_dev.c | 2 -
|
||
|
|
sas/sas_func/sas_read_dqe.c | 4 +-
|
||
|
|
sas/user_cmd/cmd_code/sas_cmd_dqe.c | 1 -
|
||
|
|
sas/user_cmd/cmd_code/sas_cmd_dump.c | 1 -
|
||
|
|
serdes/hikp_serdes.c | 4 +-
|
||
|
|
socip/hikp_socip_dumpreg.c | 1 -
|
||
|
|
tool_lib/op_logs.c | 18 ++++---
|
||
|
|
tool_lib/tool_cmd.c | 1 -
|
||
|
|
tool_lib/tool_lib.c | 3 ++
|
||
|
|
39 files changed, 161 insertions(+), 145 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/cxl/func_lib/cxl_func/cxl_feature.c b/cxl/func_lib/cxl_func/cxl_feature.c
|
||
|
|
index 6de3f89..cd41b09 100644
|
||
|
|
--- a/cxl/func_lib/cxl_func/cxl_feature.c
|
||
|
|
+++ b/cxl/func_lib/cxl_func/cxl_feature.c
|
||
|
|
@@ -77,13 +77,9 @@ static void cxl_dl_fsm_str_get(struct cxl_fsm_state_str *fsm_str_table,
|
||
|
|
{
|
||
|
|
int i = 0;
|
||
|
|
|
||
|
|
- while (fsm_str_table[i].fsm_state >= 0) {
|
||
|
|
- if ((uint32_t)fsm_str_table[i].fsm_state != fsm_state) {
|
||
|
|
- i++;
|
||
|
|
- continue;
|
||
|
|
- }
|
||
|
|
- break;
|
||
|
|
- }
|
||
|
|
+ while (fsm_str_table[i].fsm_state >= 0 &&
|
||
|
|
+ (uint32_t)fsm_str_table[i].fsm_state != fsm_state)
|
||
|
|
+ i++;
|
||
|
|
|
||
|
|
*fsm_s = fsm_str_table[i].fsm_str;
|
||
|
|
}
|
||
|
|
@@ -95,7 +91,7 @@ static void cxl_dl_fsm_state_print(const struct cxl_data_unit *data, uint32_t da
|
||
|
|
struct cxl_fsm_state_str rrsm_state[] = {
|
||
|
|
{0x0, "retry_remote_normal"},
|
||
|
|
{0x1, "retry_llrack"},
|
||
|
|
- {-1, "unknow"}
|
||
|
|
+ {-1, "unknown"}
|
||
|
|
};
|
||
|
|
struct cxl_fsm_state_str lrsm_state[] = {
|
||
|
|
{0x1, "retry_local_normal"},
|
||
|
|
@@ -103,14 +99,14 @@ static void cxl_dl_fsm_state_print(const struct cxl_data_unit *data, uint32_t da
|
||
|
|
{0x4, "retry_phy_reinit"},
|
||
|
|
{0x8, "retry_local_idle"},
|
||
|
|
{0x10, "retry_abort"},
|
||
|
|
- {-1, "unknow"}
|
||
|
|
+ {-1, "unknown"}
|
||
|
|
};
|
||
|
|
struct cxl_fsm_state_str init_fsm_state[] = {
|
||
|
|
{0x1, "inactive"},
|
||
|
|
{0x2, "retry"},
|
||
|
|
{0x4, "param"},
|
||
|
|
{0x8, "active"},
|
||
|
|
- {-1, "unknow"}
|
||
|
|
+ {-1, "unknown"}
|
||
|
|
};
|
||
|
|
|
||
|
|
if (data_unit_len == 0) {
|
||
|
|
diff --git a/cxl/usr_cmd/cmd_analysis/cxl_cmd_cpa.c b/cxl/usr_cmd/cmd_analysis/cxl_cmd_cpa.c
|
||
|
|
index 2607705..2df9dc5 100644
|
||
|
|
--- a/cxl/usr_cmd/cmd_analysis/cxl_cmd_cpa.c
|
||
|
|
+++ b/cxl/usr_cmd/cmd_analysis/cxl_cmd_cpa.c
|
||
|
|
@@ -46,7 +46,7 @@ static int cxl_port_id_set(struct major_cmd_ctrl *self, const char *argv)
|
||
|
|
|
||
|
|
ret = string_toui(argv, &val);
|
||
|
|
if (ret) {
|
||
|
|
- printf("cpa set port id err %d\n", ret);
|
||
|
|
+ printf("cxl cpa set port id err %d\n", ret);
|
||
|
|
return ret;
|
||
|
|
}
|
||
|
|
g_cxl_cpa_cmd.port_id = val;
|
||
|
|
diff --git a/libhikptdev/src/rciep/hikpt_rciep.c b/libhikptdev/src/rciep/hikpt_rciep.c
|
||
|
|
index 5c7e82f..f673dd0 100644
|
||
|
|
--- a/libhikptdev/src/rciep/hikpt_rciep.c
|
||
|
|
+++ b/libhikptdev/src/rciep/hikpt_rciep.c
|
||
|
|
@@ -41,7 +41,7 @@ static int hikp_memcpy_io(void *dst, size_t dst_size, void const *src, size_t sr
|
||
|
|
if (dst_size < src_size)
|
||
|
|
return -EINVAL;
|
||
|
|
|
||
|
|
- for (i = 0; i < src_size / sizeof(uint32_t); i++)
|
||
|
|
+ for (i = 0; i < src_size / REP_DATA_BLK_SIZE; i++)
|
||
|
|
((uint32_t *)dst)[i] = ((uint32_t *)src)[i];
|
||
|
|
|
||
|
|
return 0;
|
||
|
|
@@ -148,13 +148,13 @@ static int hikp_rep_init(void const *req_data, uint32_t req_size,
|
||
|
|
printf("The request data is NULL.\n");
|
||
|
|
return -EINVAL;
|
||
|
|
}
|
||
|
|
- data_num = (req_size + (sizeof(uint32_t) - 1)) / sizeof(uint32_t);
|
||
|
|
+ data_num = (req_size + (REP_DATA_BLK_SIZE - 1)) / REP_DATA_BLK_SIZE;
|
||
|
|
if (data_num > HIKP_REQ_DATA_MAX) {
|
||
|
|
- printf("request data num(%u) exceeds max size(%u).\n", data_num, HIKP_REQ_DATA_MAX);
|
||
|
|
+ printf("request data num(%zu) exceeds max size(%u).\n", data_num, HIKP_REQ_DATA_MAX);
|
||
|
|
return -EINVAL;
|
||
|
|
}
|
||
|
|
if (data_num != 0) {
|
||
|
|
- *align_req_data = (uint32_t *)calloc(data_num, sizeof(uint32_t));
|
||
|
|
+ *align_req_data = (uint32_t *)calloc(data_num, REP_DATA_BLK_SIZE);
|
||
|
|
if (*align_req_data == NULL) {
|
||
|
|
printf("request memory malloc failed.\n");
|
||
|
|
return -ENOMEM;
|
||
|
|
@@ -175,12 +175,12 @@ static int hikp_req_first_round(uint32_t *req_data, uint32_t rep_num, uint32_t *
|
||
|
|
if (req_data == NULL)
|
||
|
|
return 0;
|
||
|
|
|
||
|
|
- src_size = rep_num * sizeof(uint32_t);
|
||
|
|
+ src_size = rep_num * REP_DATA_BLK_SIZE;
|
||
|
|
dst_size = sizeof(g_hikp_req->field.data);
|
||
|
|
hikp_memclr_io();
|
||
|
|
ret = hikp_memcpy_io((uint32_t *)(g_hikp_req->field.data), dst_size, req_data, src_size);
|
||
|
|
if (ret != 0) {
|
||
|
|
- printf("size error, dst_size:%u, src_size:%u.\n", dst_size, src_size);
|
||
|
|
+ printf("size error, dst_size:%zu, src_size:%zu.\n", dst_size, src_size);
|
||
|
|
return ret;
|
||
|
|
}
|
||
|
|
g_hikp_req->field.exe_round = 0;
|
||
|
|
@@ -209,7 +209,7 @@ static int hikp_multi_round_interact(struct hikp_cmd_ret **cmd_ret, uint32_t sta
|
||
|
|
}
|
||
|
|
|
||
|
|
p_cmd_ret = (struct hikp_cmd_ret *)malloc(sizeof(struct hikp_cmd_ret) +
|
||
|
|
- rsp_num * sizeof(uint32_t));
|
||
|
|
+ rsp_num * REP_DATA_BLK_SIZE);
|
||
|
|
if (p_cmd_ret == NULL) {
|
||
|
|
printf("response memory malloc fail.\n");
|
||
|
|
return -ENOMEM;
|
||
|
|
@@ -235,8 +235,8 @@ static int hikp_multi_round_interact(struct hikp_cmd_ret **cmd_ret, uint32_t sta
|
||
|
|
}
|
||
|
|
}
|
||
|
|
src_size = (i == cycle - 1) ?
|
||
|
|
- (rsp_num - (i * HIKP_RSP_DATA_MAX)) * sizeof(uint32_t) :
|
||
|
|
- HIKP_RSP_DATA_MAX * sizeof(uint32_t);
|
||
|
|
+ (rsp_num - (i * HIKP_RSP_DATA_MAX)) * REP_DATA_BLK_SIZE :
|
||
|
|
+ HIKP_RSP_DATA_MAX * REP_DATA_BLK_SIZE;
|
||
|
|
dst_size = src_size;
|
||
|
|
(void)hikp_memcpy_io(&(p_cmd_ret->rsp_data)[i * HIKP_RSP_DATA_MAX],
|
||
|
|
dst_size, (uint32_t *)(g_hikp_rsp->field.data), src_size);
|
||
|
|
@@ -258,7 +258,7 @@ struct hikp_cmd_ret *hikp_cmd_alloc(struct hikp_cmd_header *req_header,
|
||
|
|
{
|
||
|
|
struct hikp_cmd_ret *cmd_ret = NULL;
|
||
|
|
uint32_t *p_req_data = NULL;
|
||
|
|
- uint32_t rep_num, rsp_num;
|
||
|
|
+ uint32_t rep_num;
|
||
|
|
uint32_t cpl_status = HIKP_INIT_STAT;
|
||
|
|
int ret;
|
||
|
|
|
||
|
|
@@ -557,7 +557,7 @@ int hikp_dev_init(void)
|
||
|
|
goto out_unmap;
|
||
|
|
}
|
||
|
|
|
||
|
|
- len = (sizeof(union hikp_space_req) - sizeof(struct iep_doorbell)) / sizeof(uint32_t);
|
||
|
|
+ len = (sizeof(union hikp_space_req) - sizeof(struct iep_doorbell)) / REP_DATA_BLK_SIZE;
|
||
|
|
for (i = 0; i < len; i++)
|
||
|
|
g_hikp_req->dw[i] = 0;
|
||
|
|
|
||
|
|
diff --git a/libhikptdev/src/rciep/hikpt_rciep.h b/libhikptdev/src/rciep/hikpt_rciep.h
|
||
|
|
index dd08759..296d235 100644
|
||
|
|
--- a/libhikptdev/src/rciep/hikpt_rciep.h
|
||
|
|
+++ b/libhikptdev/src/rciep/hikpt_rciep.h
|
||
|
|
@@ -42,6 +42,8 @@
|
||
|
|
#define CPL_CHECK_GAP_US 1000
|
||
|
|
#define WAIT_CPL_MAX_MS 8000
|
||
|
|
|
||
|
|
+#define REP_DATA_BLK_SIZE sizeof(uint32_t)
|
||
|
|
+
|
||
|
|
enum {
|
||
|
|
HIKP_RESOURCE_DIR,
|
||
|
|
HIKP_CONFIG_DIR,
|
||
|
|
diff --git a/net/hikp_net_lib.c b/net/hikp_net_lib.c
|
||
|
|
index eba086e..8db4ad5 100644
|
||
|
|
--- a/net/hikp_net_lib.c
|
||
|
|
+++ b/net/hikp_net_lib.c
|
||
|
|
@@ -23,7 +23,7 @@
|
||
|
|
#include "tool_lib.h"
|
||
|
|
#include "hikptdev_plug.h"
|
||
|
|
|
||
|
|
-static int hikp_read_net_pci_info(const char *file_path, uint32_t len, char *content)
|
||
|
|
+static int hikp_read_net_pci_info(const char *file_path, char *content, size_t len)
|
||
|
|
{
|
||
|
|
char path[PATH_MAX + 1] = { 0 };
|
||
|
|
int ret;
|
||
|
|
@@ -32,7 +32,7 @@ static int hikp_read_net_pci_info(const char *file_path, uint32_t len, char *con
|
||
|
|
if (file_path == NULL || content == NULL)
|
||
|
|
return -EINVAL;
|
||
|
|
|
||
|
|
- if (len > MAX_PCI_ID_LEN)
|
||
|
|
+ if (len > MAX_PCI_ID_LEN + 1 || len < 1)
|
||
|
|
return -EINVAL;
|
||
|
|
|
||
|
|
if (strlen(file_path) > PATH_MAX || realpath(file_path, path) == NULL)
|
||
|
|
@@ -42,12 +42,12 @@ static int hikp_read_net_pci_info(const char *file_path, uint32_t len, char *con
|
||
|
|
if (fd < 0)
|
||
|
|
return -EPERM;
|
||
|
|
|
||
|
|
- ret = pread(fd, content, len, 0);
|
||
|
|
+ ret = pread(fd, content, len - 1, 0);
|
||
|
|
if (ret < 0) {
|
||
|
|
close(fd);
|
||
|
|
return -EIO;
|
||
|
|
}
|
||
|
|
- content[len] = '\0'; // The invoker ensures that the bounds are not crossed.
|
||
|
|
+ content[len - 1] = '\0'; // The invoker ensures that the bounds are not crossed.
|
||
|
|
close(fd);
|
||
|
|
|
||
|
|
return 0;
|
||
|
|
@@ -191,7 +191,7 @@ static int tool_get_bdf_by_dev_name(const char *name, struct tool_target *target
|
||
|
|
int tool_check_and_get_valid_bdf_id(const char *name, struct tool_target *target)
|
||
|
|
{
|
||
|
|
if (!name || !target)
|
||
|
|
- return 0;
|
||
|
|
+ return -EINVAL;
|
||
|
|
|
||
|
|
if (interface_is_bdf_id(name, target))
|
||
|
|
return 0;
|
||
|
|
@@ -211,11 +211,14 @@ bool is_dev_valid_and_special(int sockfd, struct tool_target *target)
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
-int get_revision_id_by_bdf(const struct bdf_t *bdf, char *revision_id)
|
||
|
|
+int get_revision_id_by_bdf(const struct bdf_t *bdf, char *revision_id, size_t id_len)
|
||
|
|
{
|
||
|
|
char revision_dir[MAX_BUS_PCI_DIR_LEN] = { 0 };
|
||
|
|
int ret;
|
||
|
|
|
||
|
|
+ if (id_len < MAX_PCI_ID_LEN + 1)
|
||
|
|
+ return -EINVAL;
|
||
|
|
+
|
||
|
|
ret = snprintf(revision_dir, sizeof(revision_dir), "%s%04x:%02x:%02x.%u%s",
|
||
|
|
HIKP_BUS_PCI_DEV_DIR, bdf->domain, bdf->bus_id, bdf->dev_id,
|
||
|
|
bdf->fun_id, HIKP_PCI_REVISION_DIR);
|
||
|
|
@@ -223,14 +226,14 @@ int get_revision_id_by_bdf(const struct bdf_t *bdf, char *revision_id)
|
||
|
|
HIKP_ERROR_PRINT("get revision dir fail.\n");
|
||
|
|
return -EIO;
|
||
|
|
}
|
||
|
|
- ret = hikp_read_net_pci_info((const char *)revision_dir, MAX_PCI_ID_LEN, revision_id);
|
||
|
|
+ ret = hikp_read_net_pci_info((const char *)revision_dir, revision_id, id_len);
|
||
|
|
if (ret != 0)
|
||
|
|
return ret;
|
||
|
|
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
-static int hikp_get_dir_name_of_device(const char *path, uint32_t len, char *dir_name)
|
||
|
|
+static int hikp_get_dir_name_of_device(const char *path, size_t len, char *dir_name)
|
||
|
|
{
|
||
|
|
struct dirent *ptr;
|
||
|
|
DIR *dir = NULL;
|
||
|
|
@@ -261,12 +264,12 @@ static int hikp_get_dir_name_of_device(const char *path, uint32_t len, char *dir
|
||
|
|
return closedir(dir);
|
||
|
|
}
|
||
|
|
|
||
|
|
-int get_dev_name_by_bdf(const struct bdf_t *bdf, char *dev_name)
|
||
|
|
+int get_dev_name_by_bdf(const struct bdf_t *bdf, char *dev_name, size_t name_len)
|
||
|
|
{
|
||
|
|
char dev_name_dir[MAX_BUS_PCI_DIR_LEN] = { 0 };
|
||
|
|
int ret;
|
||
|
|
|
||
|
|
- if (!dev_name || !bdf)
|
||
|
|
+ if (!dev_name || !bdf || name_len < IFNAMSIZ)
|
||
|
|
return -EINVAL;
|
||
|
|
|
||
|
|
/* if dev_name already has a value, we do not need to obtain it. */
|
||
|
|
@@ -283,7 +286,7 @@ int get_dev_name_by_bdf(const struct bdf_t *bdf, char *dev_name)
|
||
|
|
if (!is_dir_exist(dev_name_dir))
|
||
|
|
return -ENOENT;
|
||
|
|
|
||
|
|
- return hikp_get_dir_name_of_device(dev_name_dir, IFNAMSIZ, dev_name);
|
||
|
|
+ return hikp_get_dir_name_of_device(dev_name_dir, name_len, dev_name);
|
||
|
|
}
|
||
|
|
|
||
|
|
int get_vf_dev_info_by_pf_dev_name(const char *pf_dev_name,
|
||
|
|
@@ -352,7 +355,7 @@ int get_numvfs_by_bdf(const struct bdf_t *bdf, uint8_t *numvfs)
|
||
|
|
HIKP_ERROR_PRINT("get numvfs dir fail.\n");
|
||
|
|
return -EIO;
|
||
|
|
}
|
||
|
|
- ret = hikp_read_net_pci_info((const char *)numvfs_dir, MAX_PCI_ID_LEN, numvf);
|
||
|
|
+ ret = hikp_read_net_pci_info((const char *)numvfs_dir, numvf, MAX_PCI_ID_LEN + 1);
|
||
|
|
if (ret != 0)
|
||
|
|
return ret;
|
||
|
|
|
||
|
|
@@ -366,12 +369,12 @@ int get_numvfs_by_bdf(const struct bdf_t *bdf, uint8_t *numvfs)
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
-void hikp_ether_format_addr(char *buf, uint16_t size, const uint8_t *mac_addr)
|
||
|
|
+void hikp_ether_format_addr(char *buf, uint16_t size, const uint8_t *mac_addr, uint8_t mac_len)
|
||
|
|
{
|
||
|
|
int len;
|
||
|
|
|
||
|
|
- if (buf == NULL || mac_addr == NULL) {
|
||
|
|
- HIKP_WARN_PRINT("buf or mac_addr pointer is NULL.\n");
|
||
|
|
+ if (buf == NULL || mac_addr == NULL || mac_len != HIKP_NIC_ETH_MAC_ADDR_LEN) {
|
||
|
|
+ HIKP_WARN_PRINT("buf or mac_addr pointer is NULL, or len(%u) is invalid\n", mac_len);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
diff --git a/net/hikp_net_lib.h b/net/hikp_net_lib.h
|
||
|
|
index ad9e7e4..8a0958f 100644
|
||
|
|
--- a/net/hikp_net_lib.h
|
||
|
|
+++ b/net/hikp_net_lib.h
|
||
|
|
@@ -130,12 +130,12 @@ enum nic_get_ncsi_sub_cmd {
|
||
|
|
int hikp_net_creat_sock(void);
|
||
|
|
int tool_check_and_get_valid_bdf_id(const char *name, struct tool_target *target);
|
||
|
|
bool is_dev_valid_and_special(int sockfd, struct tool_target *target);
|
||
|
|
-int get_revision_id_by_bdf(const struct bdf_t *bdf, char *revision_id);
|
||
|
|
-int get_dev_name_by_bdf(const struct bdf_t *bdf, char *dev_name);
|
||
|
|
+int get_revision_id_by_bdf(const struct bdf_t *bdf, char *revision_id, size_t id_len);
|
||
|
|
+int get_dev_name_by_bdf(const struct bdf_t *bdf, char *dev_name, size_t name_len);
|
||
|
|
int get_numvfs_by_bdf(const struct bdf_t *bdf, uint8_t *numvfs);
|
||
|
|
int get_vf_dev_info_by_pf_dev_name(const char *pf_dev_name,
|
||
|
|
struct tool_target *vf_target, uint8_t vf_id);
|
||
|
|
int get_pf_dev_info_by_vf_dev_name(const char *vf_dev_name, struct tool_target *pf_target);
|
||
|
|
-void hikp_ether_format_addr(char *buf, uint16_t size, const uint8_t *mac_addr);
|
||
|
|
+void hikp_ether_format_addr(char *buf, uint16_t size, const uint8_t *mac_addr, uint8_t mac_len);
|
||
|
|
|
||
|
|
#endif
|
||
|
|
diff --git a/net/nic/nic_dfx/hikp_nic_dfx.c b/net/nic/nic_dfx/hikp_nic_dfx.c
|
||
|
|
index c734ce0..4095229 100644
|
||
|
|
--- a/net/nic/nic_dfx/hikp_nic_dfx.c
|
||
|
|
+++ b/net/nic/nic_dfx/hikp_nic_dfx.c
|
||
|
|
@@ -318,7 +318,6 @@ static void hikp_nic_dfx_cmd_execute(struct major_cmd_ctrl *self)
|
||
|
|
uint32_t max_dfx_size;
|
||
|
|
uint32_t version;
|
||
|
|
uint32_t i;
|
||
|
|
- int ret;
|
||
|
|
|
||
|
|
if (!(g_dfx_param.flag & MODULE_SET_FLAG)) {
|
||
|
|
self->err_no = -EINVAL;
|
||
|
|
diff --git a/net/nic/nic_fd/hikp_nic_fd.c b/net/nic/nic_fd/hikp_nic_fd.c
|
||
|
|
index 57bc94b..e699bf9 100644
|
||
|
|
--- a/net/nic/nic_fd/hikp_nic_fd.c
|
||
|
|
+++ b/net/nic/nic_fd/hikp_nic_fd.c
|
||
|
|
@@ -15,7 +15,7 @@
|
||
|
|
#include <string.h>
|
||
|
|
#include <sys/types.h>
|
||
|
|
#include <unistd.h>
|
||
|
|
-
|
||
|
|
+#include <inttypes.h>
|
||
|
|
#include "hikp_nic_fd.h"
|
||
|
|
|
||
|
|
struct key_info {
|
||
|
|
@@ -255,13 +255,13 @@ static void hikp_nic_print_tuple(const struct key_info *tuple_key,
|
||
|
|
case OUTER_SRC_MAC:
|
||
|
|
case INNER_DST_MAC:
|
||
|
|
case INNER_SRC_MAC:
|
||
|
|
- printf("\t %s[mask=0x%llx]: ", tuple_key->key_name, mask);
|
||
|
|
+ printf("\t %s[mask=0x%" PRIx64 "]: ", tuple_key->key_name, mask);
|
||
|
|
printf("%02x:%02x:%02x:%02x:%02x:%02x\n", *(tcam_y + 5), *(tcam_y + 4),
|
||
|
|
*(tcam_y + 3), *(tcam_y + 2), *(tcam_y + 1), *tcam_y);
|
||
|
|
break;
|
||
|
|
case OUTER_ETH_TYPE:
|
||
|
|
case INNER_ETH_TYPE:
|
||
|
|
- printf("\t %s[mask=0x%llx]: ", tuple_key->key_name, mask);
|
||
|
|
+ printf("\t %s[mask=0x%" PRIx64 "]: ", tuple_key->key_name, mask);
|
||
|
|
printf("0x%x\n", *(uint16_t *)tcam_y);
|
||
|
|
break;
|
||
|
|
case OUTER_VLAN_TAG_FST:
|
||
|
|
@@ -276,7 +276,7 @@ static void hikp_nic_print_tuple(const struct key_info *tuple_key,
|
||
|
|
case OUTER_DST_PORT:
|
||
|
|
case INNER_SRC_PORT:
|
||
|
|
case INNER_DST_PORT:
|
||
|
|
- printf("\t %s[mask=0x%llx]: ", tuple_key->key_name, mask);
|
||
|
|
+ printf("\t %s[mask=0x%" PRIx64 "]: ", tuple_key->key_name, mask);
|
||
|
|
printf("%u\n", *(uint16_t *)tcam_y);
|
||
|
|
break;
|
||
|
|
case OUTER_IP_TOS:
|
||
|
|
@@ -284,25 +284,25 @@ static void hikp_nic_print_tuple(const struct key_info *tuple_key,
|
||
|
|
case OUTER_IP_PROTO:
|
||
|
|
case INNER_IP_PROTO:
|
||
|
|
case OUTER_TUN_FLOW_ID:
|
||
|
|
- printf("\t %s[mask=0x%llx]: ", tuple_key->key_name, mask);
|
||
|
|
+ printf("\t %s[mask=0x%" PRIx64 "]: ", tuple_key->key_name, mask);
|
||
|
|
printf("0x%x\n", *tcam_y);
|
||
|
|
break;
|
||
|
|
case OUTER_SRC_IP:
|
||
|
|
case OUTER_DST_IP:
|
||
|
|
case INNER_SRC_IP:
|
||
|
|
case INNER_DST_IP:
|
||
|
|
- printf("\t %s[mask=0x%llx]: ", tuple_key->key_name, mask);
|
||
|
|
+ printf("\t %s[mask=0x%" PRIx64 "]: ", tuple_key->key_name, mask);
|
||
|
|
printf("%u.%u.%u.%u\n", *(tcam_y + 3), *(tcam_y + 2), *(tcam_y + 1), *tcam_y);
|
||
|
|
break;
|
||
|
|
case OUTER_L4_RSV:
|
||
|
|
case INNER_L4_RSV:
|
||
|
|
- printf("\t %s[mask=0x%llx]: ", tuple_key->key_name, mask);
|
||
|
|
+ printf("\t %s[mask=0x%" PRIx64 "]: ", tuple_key->key_name, mask);
|
||
|
|
printf("%u\n", *(uint32_t *)tcam_y);
|
||
|
|
break;
|
||
|
|
case OUTER_TUN_VNI:
|
||
|
|
for (i = 0; i < HIKP_NIC_FD_TUN_VNI_LEN; i++)
|
||
|
|
tun_vni |= (((uint32_t)*(tcam_y + i)) << (i * HIKP_BITS_PER_BYTE));
|
||
|
|
- printf("\t %s[mask=0x%llx]: ", tuple_key->key_name, mask);
|
||
|
|
+ printf("\t %s[mask=0x%" PRIx64 "]: ", tuple_key->key_name, mask);
|
||
|
|
printf("0x%x\n", tun_vni);
|
||
|
|
break;
|
||
|
|
default:
|
||
|
|
@@ -407,12 +407,12 @@ static void hikp_nic_fd_print_meta_data(struct nic_fd_rule_info *rule)
|
||
|
|
meta_bytes = HIKP_DIV_ROUND_UP(active_meta_width, HIKP_BITS_PER_BYTE);
|
||
|
|
meta_data_region = active_tcam_size - meta_bytes;
|
||
|
|
if (meta_bytes > sizeof(meta_data)) {
|
||
|
|
- printf("meta data copy size error, data size: 0x%x, max size: 0x%x\n",
|
||
|
|
+ printf("meta data copy size error, data size: %u, max size: %zu\n",
|
||
|
|
meta_bytes, sizeof(meta_data));
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
memcpy(&meta_data, &key_y[meta_data_region], meta_bytes);
|
||
|
|
- printf("\t meta_data[meta_data=0x%llx]:\n", meta_data);
|
||
|
|
+ printf("\t meta_data[meta_data=0x%" PRIx64 "]:\n", meta_data);
|
||
|
|
cur_pos = meta_bytes * HIKP_BITS_PER_BYTE;
|
||
|
|
end = cur_pos - 1;
|
||
|
|
for (i = MAX_META_DATA - 1; i >= 0; i--) {
|
||
|
|
@@ -470,7 +470,7 @@ static void hikp_nic_fd_print_ad_data(struct nic_fd_rule_info *rule)
|
||
|
|
uint64_t ad_data;
|
||
|
|
|
||
|
|
ad_data = (uint64_t)rule->ad_data_h << NIC_FD_AD_DATA_S | rule->ad_data_l;
|
||
|
|
- printf("\n\tAction[ad data: 0x%llx]:\n", ad_data);
|
||
|
|
+ printf("\n\tAction[ad data: 0x%" PRIx64 "]:\n", ad_data);
|
||
|
|
|
||
|
|
hikp_nic_parse_ad_data(rule, &action);
|
||
|
|
|
||
|
|
@@ -544,7 +544,7 @@ static void hikp_nic_show_fd_counter(const void *data)
|
||
|
|
printf(" idx | hit_cnt\n");
|
||
|
|
for (i = 0; i < counter[stage_no].counter_size; i++) {
|
||
|
|
entry = &counter[stage_no].entry[i];
|
||
|
|
- printf(" %3u | %llu\n", entry->idx, entry->value);
|
||
|
|
+ printf(" %3u | %" PRIu64 "\n", entry->idx, entry->value);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@@ -554,7 +554,6 @@ static int hikp_nic_fd_get_blk(struct hikp_cmd_header *req_header,
|
||
|
|
{
|
||
|
|
struct hikp_cmd_ret *cmd_ret;
|
||
|
|
struct nic_fd_rsp *rsp;
|
||
|
|
- uint16_t idx;
|
||
|
|
int ret = 0;
|
||
|
|
|
||
|
|
cmd_ret = hikp_cmd_alloc(req_header, req_data, sizeof(*req_data));
|
||
|
|
@@ -792,10 +791,13 @@ static void hikp_nic_fd_data_free(union nic_fd_feature_info *fd_data)
|
||
|
|
const struct fd_feature_cmd *fd_cmd;
|
||
|
|
|
||
|
|
fd_cmd = &g_fd_feature_cmd[g_fd_param.feature_idx];
|
||
|
|
- if (strcmp(fd_cmd->feature_name, NIC_FD_RULES_NAME) == 0)
|
||
|
|
+ if (strcmp(fd_cmd->feature_name, NIC_FD_RULES_NAME) == 0) {
|
||
|
|
free(fd_data->rules[stage_no].rule);
|
||
|
|
- else if (strcmp(fd_cmd->feature_name, NIC_FD_COUNTER_NAME) == 0)
|
||
|
|
+ fd_data->rules[stage_no].rule = NULL;
|
||
|
|
+ } else if (strcmp(fd_cmd->feature_name, NIC_FD_COUNTER_NAME) == 0) {
|
||
|
|
free(fd_data->counter[stage_no].entry);
|
||
|
|
+ fd_data->counter[stage_no].entry = NULL;
|
||
|
|
+ }
|
||
|
|
|
||
|
|
free(fd_data);
|
||
|
|
}
|
||
|
|
@@ -859,31 +861,27 @@ static int hikp_nic_fd_check_input_param(struct major_cmd_ctrl *self,
|
||
|
|
|
||
|
|
if (bdf->dev_id != 0) {
|
||
|
|
snprintf(self->err_str, sizeof(self->err_str), "VF does not support query!");
|
||
|
|
- self->err_no = -EINVAL;
|
||
|
|
- return self->err_no;
|
||
|
|
+ return -EINVAL;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (fd_param->feature_idx == -1) {
|
||
|
|
hikp_nic_fd_cmd_help(self, NULL);
|
||
|
|
snprintf(self->err_str, sizeof(self->err_str), "-du/--dump parameter error!");
|
||
|
|
- self->err_no = -EINVAL;
|
||
|
|
- return self->err_no;
|
||
|
|
+ return -EINVAL;
|
||
|
|
}
|
||
|
|
|
||
|
|
fd_cmd = &g_fd_feature_cmd[g_fd_param.feature_idx];
|
||
|
|
if (fd_param->stage_no == -1 && fd_cmd->sub_cmd_code != NIC_FD_HW_INFO_DUMP) {
|
||
|
|
snprintf(self->err_str, sizeof(self->err_str),
|
||
|
|
"please input '-st/--stage' parameter.");
|
||
|
|
- self->err_no = -EINVAL;
|
||
|
|
- return self->err_no;
|
||
|
|
+ return -EINVAL;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (fd_cmd->sub_cmd_code == NIC_FD_HW_INFO_DUMP &&
|
||
|
|
(fd_param->id != -1 || fd_param->stage_no != -1)) {
|
||
|
|
snprintf(self->err_str, sizeof(self->err_str),
|
||
|
|
"no need '-id/--index' and '-st/--stage' parameter.");
|
||
|
|
- self->err_no = -EINVAL;
|
||
|
|
- return self->err_no;
|
||
|
|
+ return -EINVAL;
|
||
|
|
}
|
||
|
|
|
||
|
|
return 0;
|
||
|
|
@@ -899,8 +897,10 @@ static void hikp_nic_fd_cmd_execute(struct major_cmd_ctrl *self)
|
||
|
|
int ret;
|
||
|
|
|
||
|
|
ret = hikp_nic_fd_check_input_param(self, &g_fd_param);
|
||
|
|
- if (ret != 0)
|
||
|
|
+ if (ret != 0) {
|
||
|
|
+ self->err_no = ret;
|
||
|
|
return;
|
||
|
|
+ }
|
||
|
|
|
||
|
|
ret = hikp_nic_get_fd_hw_info(bdf, &g_fd_hw_info);
|
||
|
|
if (ret != 0) {
|
||
|
|
diff --git a/net/nic/nic_fec/hikp_nic_fec.c b/net/nic/nic_fec/hikp_nic_fec.c
|
||
|
|
index 5d9025c..342b3eb 100644
|
||
|
|
--- a/net/nic/nic_fec/hikp_nic_fec.c
|
||
|
|
+++ b/net/nic/nic_fec/hikp_nic_fec.c
|
||
|
|
@@ -15,7 +15,7 @@
|
||
|
|
#include <string.h>
|
||
|
|
#include <sys/types.h>
|
||
|
|
#include <unistd.h>
|
||
|
|
-
|
||
|
|
+#include <inttypes.h>
|
||
|
|
#include "hikp_nic_fec.h"
|
||
|
|
|
||
|
|
static struct tool_target g_fec_target;
|
||
|
|
@@ -40,6 +40,7 @@ static int hikp_nic_fec_err_query(const struct bdf_t *bdf, struct nic_fec_err_in
|
||
|
|
rsp = (struct nic_fec_rsp *)cmd_ret->rsp_data;
|
||
|
|
*info = *(struct nic_fec_err_info *)rsp->data;
|
||
|
|
free(cmd_ret);
|
||
|
|
+ cmd_ret = NULL;
|
||
|
|
|
||
|
|
if (info->fec_mode >= NIC_FEC_MODE_BUTT) {
|
||
|
|
HIKP_ERROR_PRINT("unknown fec mode: %u\n", info->fec_mode);
|
||
|
|
@@ -71,7 +72,7 @@ static void hikp_nic_fec_err_show_basefec(const struct nic_fec_err_info *info)
|
||
|
|
for (total = 0, i = 0; i < lane_num; i++)
|
||
|
|
total += info->basefec.lane_corr_block_cnt[i];
|
||
|
|
|
||
|
|
- printf(" corrected_blocks: %llu\n", total);
|
||
|
|
+ printf(" corrected_blocks: %" PRIu64 "\n", total);
|
||
|
|
for (i = 0; i < lane_num; i++)
|
||
|
|
printf(" Lane %u: %u\n", i, info->basefec.lane_corr_block_cnt[i]);
|
||
|
|
|
||
|
|
@@ -79,7 +80,7 @@ static void hikp_nic_fec_err_show_basefec(const struct nic_fec_err_info *info)
|
||
|
|
for (total = 0, i = 0; i < lane_num; i++)
|
||
|
|
total += info->basefec.lane_uncorr_block_cnt[i];
|
||
|
|
|
||
|
|
- printf(" uncorrectable_blocks: %llu\n", total);
|
||
|
|
+ printf(" uncorrectable_blocks: %" PRIu64 "\n", total);
|
||
|
|
for (i = 0; i < lane_num; i++)
|
||
|
|
printf(" Lane %u: %u\n", i, info->basefec.lane_uncorr_block_cnt[i]);
|
||
|
|
}
|
||
|
|
diff --git a/net/nic/nic_info/hikp_nic_info.c b/net/nic/nic_info/hikp_nic_info.c
|
||
|
|
index d84ca18..cd78bc7 100644
|
||
|
|
--- a/net/nic/nic_info/hikp_nic_info.c
|
||
|
|
+++ b/net/nic/nic_info/hikp_nic_info.c
|
||
|
|
@@ -79,7 +79,8 @@ static int hikp_nic_get_curr_die_info(void)
|
||
|
|
free(cmd_ret);
|
||
|
|
cmd_ret = NULL;
|
||
|
|
|
||
|
|
- ret = get_revision_id_by_bdf(&g_info_param.target.bdf, g_info_param.revision_id);
|
||
|
|
+ ret = get_revision_id_by_bdf(&g_info_param.target.bdf, g_info_param.revision_id,
|
||
|
|
+ sizeof(g_info_param.revision_id));
|
||
|
|
if (ret != 0) {
|
||
|
|
HIKP_ERROR_PRINT("Getting revision fail.\n");
|
||
|
|
return ret;
|
||
|
|
@@ -87,7 +88,8 @@ static int hikp_nic_get_curr_die_info(void)
|
||
|
|
ret = get_numvfs_by_bdf(&g_info_param.target.bdf, &g_info_param.numvfs);
|
||
|
|
if (ret != 0)
|
||
|
|
HIKP_ERROR_PRINT("Getting numvfs fail, ret = %d.\n", ret);
|
||
|
|
- ret = get_dev_name_by_bdf(&g_info_param.target.bdf, g_info_param.target.dev_name);
|
||
|
|
+ ret = get_dev_name_by_bdf(&g_info_param.target.bdf, g_info_param.target.dev_name,
|
||
|
|
+ sizeof(g_info_param.target.dev_name));
|
||
|
|
if ((ret != 0) && (ret != -ENOENT)) {
|
||
|
|
HIKP_ERROR_PRINT("Getting dev name fail.\n");
|
||
|
|
return ret;
|
||
|
|
@@ -258,7 +260,8 @@ static void hikp_nic_info_print_cur_vf(const struct bdf_t *bdf)
|
||
|
|
printf("Current function is vf:\n");
|
||
|
|
printf("\t%-16s %04x:%02x:%02x.%u\n", "vf bdf id:",
|
||
|
|
bdf->domain, bdf->bus_id, bdf->dev_id, bdf->fun_id);
|
||
|
|
- ret = get_dev_name_by_bdf(&g_info_param.target.bdf, g_info_param.target.dev_name);
|
||
|
|
+ ret = get_dev_name_by_bdf(&g_info_param.target.bdf, g_info_param.target.dev_name,
|
||
|
|
+ sizeof(g_info_param.target.dev_name));
|
||
|
|
if ((ret != 0) && (ret != -ENOENT)) {
|
||
|
|
HIKP_ERROR_PRINT("Getting dev name fail.\n");
|
||
|
|
return;
|
||
|
|
diff --git a/net/nic/nic_log/hikp_nic_log.c b/net/nic/nic_log/hikp_nic_log.c
|
||
|
|
index 5cafe4e..893aef1 100644
|
||
|
|
--- a/net/nic/nic_log/hikp_nic_log.c
|
||
|
|
+++ b/net/nic/nic_log/hikp_nic_log.c
|
||
|
|
@@ -113,7 +113,7 @@ static int hikp_nic_get_first_blk_info(uint32_t *total_blk_num,
|
||
|
|
}
|
||
|
|
*log_data = (uint8_t *)calloc(1, log_size);
|
||
|
|
if (*log_data == NULL) {
|
||
|
|
- HIKP_ERROR_PRINT("malloc log memory 0x%x failed.", log_size);
|
||
|
|
+ HIKP_ERROR_PRINT("calloc log memory 0x%x failed.", log_size);
|
||
|
|
ret = -ENOMEM;
|
||
|
|
goto err_out;
|
||
|
|
}
|
||
|
|
diff --git a/net/nic/nic_ppp/hikp_nic_ppp.c b/net/nic/nic_ppp/hikp_nic_ppp.c
|
||
|
|
index b71fc48..7968ac3 100644
|
||
|
|
--- a/net/nic/nic_ppp/hikp_nic_ppp.c
|
||
|
|
+++ b/net/nic/nic_ppp/hikp_nic_ppp.c
|
||
|
|
@@ -95,7 +95,7 @@ static uint16_t hikp_nic_ppp_get_abs_func_id(const struct bdf_t *bdf, int relati
|
||
|
|
static void hikp_nic_ppp_get_func_name(char *buf, uint8_t len, uint8_t id)
|
||
|
|
{
|
||
|
|
if (id > 0)
|
||
|
|
- snprintf(buf, len, "vf%d", id - 1);
|
||
|
|
+ snprintf(buf, len, "vf%u", id - 1);
|
||
|
|
else
|
||
|
|
snprintf(buf, len, "pf");
|
||
|
|
}
|
||
|
|
@@ -145,7 +145,8 @@ static void hikp_nic_ppp_show_key_mem(struct nic_mac_tbl *tbl, bool is_key_mem)
|
||
|
|
uc_entry = &uc_tbl->entry[idx];
|
||
|
|
if (uc_entry->idx < g_ppp_hw_res.max_key_mem_size || !is_key_mem) {
|
||
|
|
hikp_ether_format_addr(mac_str,
|
||
|
|
- HIKP_NIC_ETH_ADDR_FMT_SIZE, uc_entry->mac_addr);
|
||
|
|
+ HIKP_NIC_ETH_ADDR_FMT_SIZE, uc_entry->mac_addr,
|
||
|
|
+ HIKP_NIC_ETH_MAC_ADDR_LEN);
|
||
|
|
printf("%04u | %01u | %s | ", uc_entry->idx, uc_entry->valid, mac_str);
|
||
|
|
printf("%04u | %u | %01u | ",
|
||
|
|
uc_entry->vlan_id, uc_entry->vmdq1, uc_entry->mac_en);
|
||
|
|
@@ -161,7 +162,8 @@ static void hikp_nic_ppp_show_key_mem(struct nic_mac_tbl *tbl, bool is_key_mem)
|
||
|
|
mc_entry = &mc_tbl->entry[idx];
|
||
|
|
if (mc_entry->idx < g_ppp_hw_res.max_key_mem_size || !is_key_mem) {
|
||
|
|
hikp_ether_format_addr(mac_str,
|
||
|
|
- HIKP_NIC_ETH_ADDR_FMT_SIZE, mc_entry->mac_addr);
|
||
|
|
+ HIKP_NIC_ETH_ADDR_FMT_SIZE, mc_entry->mac_addr,
|
||
|
|
+ HIKP_NIC_ETH_MAC_ADDR_LEN);
|
||
|
|
printf("%04u | %s | ", mc_entry->idx, mac_str);
|
||
|
|
printf("%08x:%08x:%08x:%08x:%08x:%08x:%08x:%08x",
|
||
|
|
mc_entry->function_bitmap[7], mc_entry->function_bitmap[6],
|
||
|
|
@@ -191,7 +193,7 @@ static void hikp_nic_ppp_show_func_uc_mac_addr(struct mac_vlan_uc_tbl *uc_tbl,
|
||
|
|
vf_id = hikp_get_field(uc_entry->e_vport, HIKP_NIC_VF_ID_MASK, HIKP_NIC_VF_ID_S);
|
||
|
|
if (bdf->fun_id == pf_id && vf_id == func_id) {
|
||
|
|
hikp_ether_format_addr(mac_str, HIKP_NIC_ETH_ADDR_FMT_SIZE,
|
||
|
|
- uc_entry->mac_addr);
|
||
|
|
+ uc_entry->mac_addr, HIKP_NIC_ETH_MAC_ADDR_LEN);
|
||
|
|
printf("\t%s\n", mac_str);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
@@ -205,7 +207,7 @@ static void hikp_nic_ppp_show_func_mc_mac_addr(struct mac_vlan_mc_tbl *mc_tbl,
|
||
|
|
uint16_t abs_func_id;
|
||
|
|
uint8_t offset;
|
||
|
|
uint8_t idx;
|
||
|
|
- uint8_t i;
|
||
|
|
+ uint32_t i;
|
||
|
|
|
||
|
|
abs_func_id = hikp_nic_ppp_get_abs_func_id(bdf, func_id);
|
||
|
|
idx = abs_func_id / HIKP_NIC_PPP_FUNC_BITMAP_SIZE;
|
||
|
|
@@ -218,7 +220,7 @@ static void hikp_nic_ppp_show_func_mc_mac_addr(struct mac_vlan_mc_tbl *mc_tbl,
|
||
|
|
|
||
|
|
if (hikp_get_bit(mc_entry->function_bitmap[idx], offset) != 0) {
|
||
|
|
hikp_ether_format_addr(mac_str, HIKP_NIC_ETH_ADDR_FMT_SIZE,
|
||
|
|
- mc_entry->mac_addr);
|
||
|
|
+ mc_entry->mac_addr, HIKP_NIC_ETH_MAC_ADDR_LEN);
|
||
|
|
printf("\t%s\n", mac_str);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
@@ -401,7 +403,8 @@ static void hikp_nic_ppp_show_manager_tbl(const void *data)
|
||
|
|
"| i_map | i_dir | e_type | pf_id | vf_id | q_id | drop\n");
|
||
|
|
for (i = 0; i < tbl->entry_size; i++) {
|
||
|
|
entry = &tbl->entry[i];
|
||
|
|
- hikp_ether_format_addr(mac_str, HIKP_NIC_ETH_ADDR_FMT_SIZE, entry->mac_addr);
|
||
|
|
+ hikp_ether_format_addr(mac_str, HIKP_NIC_ETH_ADDR_FMT_SIZE, entry->mac_addr,
|
||
|
|
+ HIKP_NIC_ETH_MAC_ADDR_LEN);
|
||
|
|
printf(" %02u | %s | %u ", entry->entry_no, mac_str, entry->mac_mask);
|
||
|
|
printf("| %04x | %u | %04u | %u ",
|
||
|
|
entry->ether_type, entry->ether_mask, entry->vlan_id, entry->vlan_mask);
|
||
|
|
@@ -489,7 +492,7 @@ static int hikp_nic_ppp_get_blk(struct hikp_cmd_header *req_header,
|
||
|
|
rsp = (struct nic_ppp_rsp *)cmd_ret->rsp_data;
|
||
|
|
if (rsp->rsp_head.cur_blk_size > buf_len) {
|
||
|
|
HIKP_ERROR_PRINT("nic_ppp block context copy size error, "
|
||
|
|
- "buffer size=%u, data size=%u.\n",
|
||
|
|
+ "buffer size=%zu, data size=%u.\n",
|
||
|
|
buf_len, rsp->rsp_head.cur_blk_size);
|
||
|
|
ret = -EINVAL;
|
||
|
|
goto out;
|
||
|
|
@@ -791,6 +794,7 @@ static int hikp_nic_ppp_alloc_mac_tbl_entry(struct nic_mac_tbl *mac_tbl,
|
||
|
|
if (mac_tbl->mc_tbl.entry == NULL) {
|
||
|
|
HIKP_ERROR_PRINT("Fail to alloc mc_entry memory.\n");
|
||
|
|
free(mac_tbl->uc_tbl.entry);
|
||
|
|
+ mac_tbl->uc_tbl.entry = NULL;
|
||
|
|
return -ENOMEM;
|
||
|
|
}
|
||
|
|
|
||
|
|
@@ -813,6 +817,7 @@ static int hikp_nic_ppp_alloc_vlan_tbl_entry(struct nic_vlan_tbl *vlan_tbl,
|
||
|
|
if (vlan_tbl->vf_vlan_tbl.entry == NULL) {
|
||
|
|
HIKP_ERROR_PRINT("Fail to alloc vf_vlan_tbl_entry memory.\n");
|
||
|
|
free(vlan_tbl->port_vlan_tbl.entry);
|
||
|
|
+ vlan_tbl->port_vlan_tbl.entry = NULL;
|
||
|
|
return -ENOMEM;
|
||
|
|
}
|
||
|
|
|
||
|
|
@@ -872,16 +877,22 @@ static void hikp_nic_ppp_data_free(union nic_ppp_feature_info *ppp_data)
|
||
|
|
if (strcmp(ppp_cmd->feature_name, NIC_PPP_MAC_TBL_NAME) == 0) {
|
||
|
|
mac_tbl = &ppp_data->mac_tbl;
|
||
|
|
free(mac_tbl->uc_tbl.entry);
|
||
|
|
+ mac_tbl->uc_tbl.entry = NULL;
|
||
|
|
free(mac_tbl->mc_tbl.entry);
|
||
|
|
+ mac_tbl->mc_tbl.entry = NULL;
|
||
|
|
} else if (strcmp(ppp_cmd->feature_name, NIC_PPP_VLAN_TBL_NAME) == 0) {
|
||
|
|
vlan_tbl = &ppp_data->vlan_tbl;
|
||
|
|
free(vlan_tbl->vf_vlan_tbl.entry);
|
||
|
|
+ vlan_tbl->vf_vlan_tbl.entry = NULL;
|
||
|
|
free(vlan_tbl->port_vlan_tbl.entry);
|
||
|
|
+ vlan_tbl->port_vlan_tbl.entry = NULL;
|
||
|
|
} else if (strcmp(ppp_cmd->feature_name, NIC_PPP_MNG_TBL_NAME) == 0) {
|
||
|
|
mng_tbl = &ppp_data->mng_tbl;
|
||
|
|
free(mng_tbl->entry);
|
||
|
|
+ mng_tbl->entry = NULL;
|
||
|
|
}
|
||
|
|
free(ppp_data);
|
||
|
|
+ ppp_data = NULL;
|
||
|
|
}
|
||
|
|
|
||
|
|
static int hikp_nic_ppp_check_optional_param(struct major_cmd_ctrl *self,
|
||
|
|
diff --git a/net/nic/nic_qos/hikp_nic_qos.c b/net/nic/nic_qos/hikp_nic_qos.c
|
||
|
|
index e3f0e9c..a09b4f1 100644
|
||
|
|
--- a/net/nic/nic_qos/hikp_nic_qos.c
|
||
|
|
+++ b/net/nic/nic_qos/hikp_nic_qos.c
|
||
|
|
@@ -98,12 +98,12 @@ static void hikp_nic_qos_show_dcb_info(const void *data)
|
||
|
|
printf("PFC configuration\n");
|
||
|
|
printf(" PFC enable:");
|
||
|
|
for (up = 0; up < HIKP_NIC_MAX_USER_PRIO_NUM; up++)
|
||
|
|
- printf(" %d", HI_BIT(up) & pfc->pfc_en ? 1 : 0);
|
||
|
|
+ printf(" %u", HI_BIT(up) & pfc->pfc_en ? 1 : 0);
|
||
|
|
|
||
|
|
printf("\n");
|
||
|
|
printf(" TC enable:");
|
||
|
|
for (tc_no = 0; tc_no < HIKP_NIC_MAX_TC_NUM; tc_no++)
|
||
|
|
- printf(" %d", HI_BIT(tc_no) & pfc->hw_tc_map ? 1 : 0);
|
||
|
|
+ printf(" %u", HI_BIT(tc_no) & pfc->hw_tc_map ? 1 : 0);
|
||
|
|
|
||
|
|
printf("\n");
|
||
|
|
printf("ETS configuration\n");
|
||
|
|
@@ -176,7 +176,7 @@ static int hikp_nic_qos_get_blk(struct hikp_cmd_header *req_header,
|
||
|
|
rsp = (struct nic_qos_rsp *)cmd_ret->rsp_data;
|
||
|
|
if (rsp->rsp_head.cur_blk_size > buf_len) {
|
||
|
|
HIKP_ERROR_PRINT("nic_qos block-%u copy size error, "
|
||
|
|
- "buffer size=%u, data size=%u.\n",
|
||
|
|
+ "buffer size=%zu, data size=%u.\n",
|
||
|
|
req_data->block_id, buf_len, rsp->rsp_head.cur_blk_size);
|
||
|
|
ret = -EINVAL;
|
||
|
|
goto out;
|
||
|
|
@@ -198,7 +198,6 @@ static int hikp_nic_query_qos_feature(struct hikp_cmd_header *req_header, const
|
||
|
|
size_t buf_len = sizeof(*data);
|
||
|
|
uint32_t total_blk_size;
|
||
|
|
uint8_t total_blk_num;
|
||
|
|
- uint8_t blk_num = 0;
|
||
|
|
uint8_t blk_id = 0;
|
||
|
|
int ret;
|
||
|
|
|
||
|
|
@@ -272,7 +271,7 @@ 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);
|
||
|
|
+ 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,
|
||
|
|
diff --git a/net/nic/nic_queue/hikp_nic_queue.c b/net/nic/nic_queue/hikp_nic_queue.c
|
||
|
|
index f229e09..fa3b9d3 100644
|
||
|
|
--- a/net/nic/nic_queue/hikp_nic_queue.c
|
||
|
|
+++ b/net/nic/nic_queue/hikp_nic_queue.c
|
||
|
|
@@ -248,7 +248,7 @@ static int hikp_nic_queue_get_blk(struct hikp_cmd_header *req_header,
|
||
|
|
rsp = (struct nic_queue_rsp *)cmd_ret->rsp_data;
|
||
|
|
if (rsp->rsp_head.cur_blk_size > buf_len) {
|
||
|
|
HIKP_ERROR_PRINT("nic_queue block-%u copy size error, "
|
||
|
|
- "buffer size=%u, data size=%u.\n",
|
||
|
|
+ "buffer size=%zu, data size=%u.\n",
|
||
|
|
req_data->block_id, buf_len, rsp->rsp_head.cur_blk_size);
|
||
|
|
ret = -EINVAL;
|
||
|
|
goto out;
|
||
|
|
@@ -340,7 +340,6 @@ static bool hikp_nic_queue_check_feature_para_vaild(const struct queue_feature_c
|
||
|
|
|
||
|
|
static void hikp_nic_queue_cmd_execute(struct major_cmd_ctrl *self)
|
||
|
|
{
|
||
|
|
- struct bdf_t *bdf = &g_queue_param.target.bdf;
|
||
|
|
const struct queue_feature_cmd *queue_cmd;
|
||
|
|
union nic_queue_feature_info *queue_data;
|
||
|
|
struct hikp_cmd_header req_header = {0};
|
||
|
|
diff --git a/net/nic/nic_rss/hikp_nic_rss.c b/net/nic/nic_rss/hikp_nic_rss.c
|
||
|
|
index 5e4d261..ff1cfd2 100644
|
||
|
|
--- a/net/nic/nic_rss/hikp_nic_rss.c
|
||
|
|
+++ b/net/nic/nic_rss/hikp_nic_rss.c
|
||
|
|
@@ -366,7 +366,7 @@ static int hikp_nic_rss_get_blk(struct hikp_cmd_header *req_header,
|
||
|
|
rsp = (struct nic_rss_rsp *)cmd_ret->rsp_data;
|
||
|
|
if (rsp->rsp_head.cur_blk_size > buf_len) {
|
||
|
|
HIKP_ERROR_PRINT("nic_rss block-%u copy size error, "
|
||
|
|
- "buffer size=%u, data size=%u.\n",
|
||
|
|
+ "buffer size=%zu, data size=%u.\n",
|
||
|
|
req_data->block_id, buf_len, rsp->rsp_head.cur_blk_size);
|
||
|
|
ret = -EINVAL;
|
||
|
|
goto out;
|
||
|
|
@@ -388,7 +388,6 @@ static int hikp_nic_query_rss_feature(struct hikp_cmd_header *req_header, const
|
||
|
|
size_t buf_len = sizeof(*data);
|
||
|
|
uint32_t total_blk_size;
|
||
|
|
uint8_t total_blk_num;
|
||
|
|
- uint8_t blk_num = 0;
|
||
|
|
uint8_t blk_id = 0;
|
||
|
|
int ret;
|
||
|
|
|
||
|
|
diff --git a/net/roce/roce_ext_common/hikp_roce_ext_common.c b/net/roce/roce_ext_common/hikp_roce_ext_common.c
|
||
|
|
index d5ae64a..3a0c1ae 100644
|
||
|
|
--- a/net/roce/roce_ext_common/hikp_roce_ext_common.c
|
||
|
|
+++ b/net/roce/roce_ext_common/hikp_roce_ext_common.c
|
||
|
|
@@ -15,11 +15,15 @@
|
||
|
|
|
||
|
|
static void hikp_roce_ext_reg_data_free(struct reg_data *reg)
|
||
|
|
{
|
||
|
|
- if (reg->offset)
|
||
|
|
+ if (reg->offset) {
|
||
|
|
free(reg->offset);
|
||
|
|
+ reg->offset = NULL;
|
||
|
|
+ }
|
||
|
|
|
||
|
|
- if (reg->data)
|
||
|
|
+ if (reg->data) {
|
||
|
|
free(reg->data);
|
||
|
|
+ reg->data = NULL;
|
||
|
|
+ }
|
||
|
|
}
|
||
|
|
|
||
|
|
static void hikp_roce_ext_cmd_ret_free(struct hikp_cmd_ret *cmd_ret)
|
||
|
|
@@ -118,7 +122,7 @@ static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type,
|
||
|
|
reg->offset = (uint32_t *)calloc(res_head->total_block_num, sizeof(uint32_t));
|
||
|
|
reg->data = (uint32_t *)calloc(res_head->total_block_num, sizeof(uint32_t));
|
||
|
|
if ((reg->offset == NULL) || (reg->data == NULL)) {
|
||
|
|
- printf("hikptool roce_%s alloc log memmory 0x%x failed!\n",
|
||
|
|
+ printf("hikptool roce_%s alloc log memmory 0x%zx failed!\n",
|
||
|
|
cmd_name, max_size);
|
||
|
|
ret = -ENOMEM;
|
||
|
|
hikp_roce_ext_reg_data_free(reg);
|
||
|
|
@@ -128,7 +132,7 @@ static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type,
|
||
|
|
|
||
|
|
cur_size = res_head->cur_block_num * sizeof(uint32_t);
|
||
|
|
if (cur_size > max_size) {
|
||
|
|
- printf("hikptool roce_%s log data copy size error, data size: 0x%x, max size: 0x%x\n",
|
||
|
|
+ printf("hikptool roce_%s log data copy size error, data size: 0x%zx, max size: 0x%zx\n",
|
||
|
|
cmd_name, cur_size, max_size);
|
||
|
|
ret = -EINVAL;
|
||
|
|
hikp_roce_ext_reg_data_free(reg);
|
||
|
|
diff --git a/net/roce/roce_gmv/hikp_roce_gmv.c b/net/roce/roce_gmv/hikp_roce_gmv.c
|
||
|
|
index d65dc82..36ba665 100644
|
||
|
|
--- a/net/roce/roce_gmv/hikp_roce_gmv.c
|
||
|
|
+++ b/net/roce/roce_gmv/hikp_roce_gmv.c
|
||
|
|
@@ -44,16 +44,16 @@ static int hikp_roce_gmv_target(struct major_cmd_ctrl *self, const char *argv)
|
||
|
|
static int hikp_roce_gmv_idxget(struct major_cmd_ctrl *self, const char *argv)
|
||
|
|
{
|
||
|
|
char *endptr = NULL;
|
||
|
|
- int index;
|
||
|
|
+ uint64_t index;
|
||
|
|
|
||
|
|
- index = strtol(argv, &endptr, 0);
|
||
|
|
+ index = strtoul(argv, &endptr, 0);
|
||
|
|
if ((endptr <= argv) || (*endptr != '\0') ||
|
||
|
|
- (index < 0) || (index >= ROCE_MAX_HIKPTOOL_GMV)) {
|
||
|
|
+ (index >= ROCE_MAX_HIKPTOOL_GMV)) {
|
||
|
|
snprintf(self->err_str, sizeof(self->err_str), "Invalid gmv_index.");
|
||
|
|
self->err_no = -EINVAL;
|
||
|
|
return -EINVAL;
|
||
|
|
}
|
||
|
|
- g_roce_gmv_param.gmv_index = index;
|
||
|
|
+ g_roce_gmv_param.gmv_index = (uint32_t)index;
|
||
|
|
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
diff --git a/net/roce/roce_mdb/hikp_roce_mdb.c b/net/roce/roce_mdb/hikp_roce_mdb.c
|
||
|
|
index 04af817..374f100 100644
|
||
|
|
--- a/net/roce/roce_mdb/hikp_roce_mdb.c
|
||
|
|
+++ b/net/roce/roce_mdb/hikp_roce_mdb.c
|
||
|
|
@@ -89,7 +89,6 @@ static void hikp_roce_mdb_execute_origin(struct major_cmd_ctrl *self)
|
||
|
|
struct roce_mdb_rsp_data *mdb_rsp = NULL;
|
||
|
|
struct hikp_cmd_ret *cmd_ret = NULL;
|
||
|
|
uint32_t reg_num;
|
||
|
|
- int ret;
|
||
|
|
|
||
|
|
self->err_no = hikp_roce_mdb_get_data(&cmd_ret, 0);
|
||
|
|
if (self->err_no) {
|
||
|
|
diff --git a/net/roce/roce_qmm/hikp_roce_qmm.c b/net/roce/roce_qmm/hikp_roce_qmm.c
|
||
|
|
index d127264..e440b82 100644
|
||
|
|
--- a/net/roce/roce_qmm/hikp_roce_qmm.c
|
||
|
|
+++ b/net/roce/roce_qmm/hikp_roce_qmm.c
|
||
|
|
@@ -45,16 +45,16 @@ static int hikp_roce_qmm_target(struct major_cmd_ctrl *self, const char *argv)
|
||
|
|
static int hikp_roce_qmm_bank_get(struct major_cmd_ctrl *self, const char *argv)
|
||
|
|
{
|
||
|
|
char *endptr = NULL;
|
||
|
|
- int bank_num;
|
||
|
|
+ uint64_t bank_num;
|
||
|
|
|
||
|
|
- bank_num = strtol(argv, &endptr, 0);
|
||
|
|
- if ((endptr <= argv) || (*endptr != '\0') || bank_num > QMM_BANK_NUM || bank_num < 0) {
|
||
|
|
+ bank_num = strtoul(argv, &endptr, 0);
|
||
|
|
+ if ((endptr <= argv) || (*endptr != '\0') || bank_num > QMM_BANK_NUM) {
|
||
|
|
snprintf(self->err_str, sizeof(self->err_str), "Invalid bank number!\n");
|
||
|
|
self->err_no = -EINVAL;
|
||
|
|
return -EINVAL;
|
||
|
|
}
|
||
|
|
|
||
|
|
- g_roce_qmm_param.bank_id = bank_num;
|
||
|
|
+ g_roce_qmm_param.bank_id = (uint32_t)bank_num;
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
diff --git a/net/roce/roce_scc/hikp_roce_scc.c b/net/roce/roce_scc/hikp_roce_scc.c
|
||
|
|
index e8e166d..fe08873 100644
|
||
|
|
--- a/net/roce/roce_scc/hikp_roce_scc.c
|
||
|
|
+++ b/net/roce/roce_scc/hikp_roce_scc.c
|
||
|
|
@@ -150,7 +150,7 @@ static int hikp_roce_scc_get_total_data_num(struct roce_scc_head *res_head,
|
||
|
|
*offset = (uint32_t *)calloc(1, max_size);
|
||
|
|
*data = (uint32_t *)calloc(1, max_size);
|
||
|
|
if ((*offset == NULL) || (*data == NULL)) {
|
||
|
|
- printf("hikptool roce_scc alloc log memmory 0x%x failed\n", max_size);
|
||
|
|
+ printf("hikptool roce_scc alloc log memmory 0x%zx failed\n", max_size);
|
||
|
|
ret = -ENOMEM;
|
||
|
|
goto get_data_error;
|
||
|
|
}
|
||
|
|
@@ -158,7 +158,7 @@ static int hikp_roce_scc_get_total_data_num(struct roce_scc_head *res_head,
|
||
|
|
cur_size = roce_scc_res->head.cur_block_num * sizeof(uint32_t);
|
||
|
|
if (cur_size > max_size) {
|
||
|
|
printf("hikptool roce_scc log data copy size error, "
|
||
|
|
- "data size: 0x%x, max size: 0x%x\n", cur_size, max_size);
|
||
|
|
+ "data size: 0x%zx, max size: 0x%zx\n", cur_size, max_size);
|
||
|
|
ret = -EINVAL;
|
||
|
|
goto get_data_error;
|
||
|
|
}
|
||
|
|
@@ -194,7 +194,7 @@ static int hikp_roce_scc_get_next_data(struct roce_scc_head *res_head,
|
||
|
|
if (cur_size > data_size) {
|
||
|
|
hikp_roce_scc_cmd_ret_free(&cmd_ret);
|
||
|
|
printf("hikptool roce_scc next log data copy size error, "
|
||
|
|
- "data size: 0x%x, max size: 0x%x\n", cur_size, data_size);
|
||
|
|
+ "data size: 0x%zx, max size: 0x%zx\n", cur_size, data_size);
|
||
|
|
return -EINVAL;
|
||
|
|
}
|
||
|
|
memcpy(*offset, roce_scc_res->reg_data.offset, cur_size);
|
||
|
|
diff --git a/net/roce/roce_timer/hikp_roce_timer.c b/net/roce/roce_timer/hikp_roce_timer.c
|
||
|
|
index a78d383..05ad3e1 100644
|
||
|
|
--- a/net/roce/roce_timer/hikp_roce_timer.c
|
||
|
|
+++ b/net/roce/roce_timer/hikp_roce_timer.c
|
||
|
|
@@ -149,7 +149,7 @@ static void hikp_roce_timer_execute(struct major_cmd_ctrl *self)
|
||
|
|
int (*func[])(struct major_cmd_ctrl *self) = {
|
||
|
|
hikp_roce_timer_show_cqc, hikp_roce_timer_show_qpc
|
||
|
|
};
|
||
|
|
- char *function[] = {"show cqc", "show qpc"};
|
||
|
|
+ const char *function[] = {"show cqc", "show qpc"};
|
||
|
|
int i = 0;
|
||
|
|
int ret;
|
||
|
|
|
||
|
|
diff --git a/net/roce/roce_trp/hikp_roce_trp.c b/net/roce/roce_trp/hikp_roce_trp.c
|
||
|
|
index 4591a47..fad3317 100644
|
||
|
|
--- a/net/roce/roce_trp/hikp_roce_trp.c
|
||
|
|
+++ b/net/roce/roce_trp/hikp_roce_trp.c
|
||
|
|
@@ -85,20 +85,17 @@ static int hikp_roce_trp_bank_get(struct major_cmd_ctrl *self, const char *argv)
|
||
|
|
|
||
|
|
static int hikp_roce_trp_bank_check(void)
|
||
|
|
{
|
||
|
|
- uint32_t temp;
|
||
|
|
-
|
||
|
|
- temp = g_roce_trp_param_t.bank_id;
|
||
|
|
switch (g_roce_trp_param_t.sub_cmd) {
|
||
|
|
case (COMMON):
|
||
|
|
- if (temp > TRP_MAX_BANK_NUM || temp < 0)
|
||
|
|
+ if (g_roce_trp_param_t.bank_id > TRP_MAX_BANK_NUM)
|
||
|
|
return -EINVAL;
|
||
|
|
break;
|
||
|
|
case (PAYL):
|
||
|
|
- if (temp > PAYL_MAX_BANK_NUM || temp < 0)
|
||
|
|
+ if (g_roce_trp_param_t.bank_id > PAYL_MAX_BANK_NUM)
|
||
|
|
return -EINVAL;
|
||
|
|
break;
|
||
|
|
case (GEN_AC):
|
||
|
|
- if (temp > GAC_MAX_BANK_NUM || temp < 0)
|
||
|
|
+ if (g_roce_trp_param_t.bank_id > GAC_MAX_BANK_NUM)
|
||
|
|
return -EINVAL;
|
||
|
|
break;
|
||
|
|
default:
|
||
|
|
@@ -173,7 +170,8 @@ static int hikp_roce_trp_get_total_data_num(struct roce_trp_head *res_head,
|
||
|
|
*offset = (uint32_t *)calloc(1, max_size);
|
||
|
|
*data = (uint32_t *)calloc(1, max_size);
|
||
|
|
if ((*offset == NULL) || (*data == NULL)) {
|
||
|
|
- printf("hikptool roce_trp alloc log memmory 0x%x failed\n", max_size);
|
||
|
|
+ printf("hikptool roce_trp alloc log memmory 0x%zx failed\n", max_size);
|
||
|
|
+ hikp_roce_trp_reg_data_free(offset, data);
|
||
|
|
ret = -ENOMEM;
|
||
|
|
goto get_data_error;
|
||
|
|
}
|
||
|
|
@@ -181,7 +179,8 @@ static int hikp_roce_trp_get_total_data_num(struct roce_trp_head *res_head,
|
||
|
|
cur_size = roce_trp_res->head.cur_block_num * sizeof(uint32_t);
|
||
|
|
if (cur_size > max_size) {
|
||
|
|
printf("hikptool roce_trp log data copy size error, "
|
||
|
|
- "data size: 0x%x, max size: 0x%x\n", cur_size, max_size);
|
||
|
|
+ "data size: 0x%zx, max size: 0x%zx\n", cur_size, max_size);
|
||
|
|
+ hikp_roce_trp_reg_data_free(offset, data);
|
||
|
|
ret = -EINVAL;
|
||
|
|
goto get_data_error;
|
||
|
|
}
|
||
|
|
@@ -218,7 +217,7 @@ static int hikp_roce_trp_get_next_data(struct roce_trp_head *res_head,
|
||
|
|
if (cur_size > data_size) {
|
||
|
|
hikp_roce_trp_cmd_ret_free(&cmd_ret);
|
||
|
|
printf("hikptool roce_trp next log data copy size error, "
|
||
|
|
- "data size: 0x%x, max size: 0x%x\n", cur_size, data_size);
|
||
|
|
+ "data size: 0x%zx, max size: 0x%zx\n", cur_size, data_size);
|
||
|
|
return -EINVAL;
|
||
|
|
}
|
||
|
|
memcpy(*offset, roce_trp_res->reg_data.offset, cur_size);
|
||
|
|
@@ -268,7 +267,6 @@ static void hikp_roce_trp_execute(struct major_cmd_ctrl *self)
|
||
|
|
if (self->err_no) {
|
||
|
|
snprintf(self->err_str, sizeof(self->err_str),
|
||
|
|
"get the first roce_trp block dfx fail.");
|
||
|
|
- hikp_roce_trp_reg_data_free(&offset, &data);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
total_block_num = res_head.total_block_num;
|
||
|
|
diff --git a/net/roce/roce_tsp/hikp_roce_tsp.c b/net/roce/roce_tsp/hikp_roce_tsp.c
|
||
|
|
index 9469e4d..5bb2649 100644
|
||
|
|
--- a/net/roce/roce_tsp/hikp_roce_tsp.c
|
||
|
|
+++ b/net/roce/roce_tsp/hikp_roce_tsp.c
|
||
|
|
@@ -84,16 +84,13 @@ static int hikp_roce_tsp_bank_get(struct major_cmd_ctrl *self, const char *argv)
|
||
|
|
|
||
|
|
static int hikp_roce_tsp_bank_check(void)
|
||
|
|
{
|
||
|
|
- uint32_t temp;
|
||
|
|
-
|
||
|
|
- temp = g_roce_tsp_param_t.bank_id;
|
||
|
|
switch (g_roce_tsp_param_t.sub_cmd_code) {
|
||
|
|
case (COMMON):
|
||
|
|
- if ((temp > MAX_TSP_BANK_NUM) || temp < 0)
|
||
|
|
+ if (g_roce_tsp_param_t.bank_id > MAX_TSP_BANK_NUM)
|
||
|
|
return -EINVAL;
|
||
|
|
break;
|
||
|
|
case (TGP_TMP):
|
||
|
|
- if ((temp > MAX_TGP_TMP_BANK_NUM) || temp < 0)
|
||
|
|
+ if (g_roce_tsp_param_t.bank_id > MAX_TGP_TMP_BANK_NUM)
|
||
|
|
return -EINVAL;
|
||
|
|
break;
|
||
|
|
default:
|
||
|
|
diff --git a/net/ub/ub_crd/hikp_ub_crd.c b/net/ub/ub_crd/hikp_ub_crd.c
|
||
|
|
index e207ea2..0e47b5b 100644
|
||
|
|
--- a/net/ub/ub_crd/hikp_ub_crd.c
|
||
|
|
+++ b/net/ub/ub_crd/hikp_ub_crd.c
|
||
|
|
@@ -64,7 +64,6 @@ static int hikp_ub_query_crd(void)
|
||
|
|
struct hikp_cmd_ret *cmd_ret = NULL;
|
||
|
|
struct ub_crd_rsp *crd_rsp = NULL;
|
||
|
|
int offset;
|
||
|
|
- int ret;
|
||
|
|
|
||
|
|
char const *init_crds[][2] = {
|
||
|
|
{"CFG_REMOTE_ICRD", "CFG_REMOTE_LCRD"},
|
||
|
|
diff --git a/net/ub/ub_ppp/hikp_unic_ppp.c b/net/ub/ub_ppp/hikp_unic_ppp.c
|
||
|
|
index ccba4e0..bf0c026 100644
|
||
|
|
--- a/net/ub/ub_ppp/hikp_unic_ppp.c
|
||
|
|
+++ b/net/ub/ub_ppp/hikp_unic_ppp.c
|
||
|
|
@@ -191,6 +191,7 @@ static int hikp_unic_ppp_alloc_guid_tbl_entry(const struct hikp_unic_ppp_hw_reso
|
||
|
|
if (guid_tbl->mc_tbl.entry == NULL) {
|
||
|
|
HIKP_ERROR_PRINT("fail to alloc mc_guid_entry_table memory.\n");
|
||
|
|
free(guid_tbl->uc_tbl.entry);
|
||
|
|
+ guid_tbl->uc_tbl.entry = NULL;
|
||
|
|
return -ENOMEM;
|
||
|
|
}
|
||
|
|
|
||
|
|
@@ -399,13 +400,17 @@ static void hikp_unic_ppp_data_free(union unic_ppp_feature_info *unic_ppp_data)
|
||
|
|
if (g_unic_ppp_param.feature_idx == UNIC_PPP_IP_FEATURE_IDX) {
|
||
|
|
ip_tbl = &unic_ppp_data->ip_tbl;
|
||
|
|
free(ip_tbl->entry);
|
||
|
|
+ ip_tbl->entry = NULL;
|
||
|
|
} else if (g_unic_ppp_param.feature_idx == UNIC_PPP_GUID_FEATURE_IDX) {
|
||
|
|
guid_tbl = &unic_ppp_data->guid_tbl;
|
||
|
|
free(guid_tbl->uc_tbl.entry);
|
||
|
|
+ guid_tbl->uc_tbl.entry = NULL;
|
||
|
|
free(guid_tbl->mc_tbl.entry);
|
||
|
|
+ guid_tbl->mc_tbl.entry = NULL;
|
||
|
|
}
|
||
|
|
|
||
|
|
free(unic_ppp_data);
|
||
|
|
+ unic_ppp_data = NULL;
|
||
|
|
}
|
||
|
|
|
||
|
|
static void hikp_unic_ppp_cmd_execute(struct major_cmd_ctrl *self)
|
||
|
|
diff --git a/ossl/ossl_user_linux.c b/ossl/ossl_user_linux.c
|
||
|
|
index 8266a19..9dee61c 100644
|
||
|
|
--- a/ossl/ossl_user_linux.c
|
||
|
|
+++ b/ossl/ossl_user_linux.c
|
||
|
|
@@ -47,7 +47,6 @@ int uda_realpath(const char *file_dir, char *format_dir)
|
||
|
|
|
||
|
|
int uda_fcntl(const char *lock_file, uint32_t operation, int *fd)
|
||
|
|
{
|
||
|
|
- uint32_t f_opt = 0;
|
||
|
|
int fd_t = 0;
|
||
|
|
int ret;
|
||
|
|
|
||
|
|
diff --git a/pcie/func_lib/pcie_func/pcie_link_ltssm.c b/pcie/func_lib/pcie_func/pcie_link_ltssm.c
|
||
|
|
index 9697529..66226e0 100644
|
||
|
|
--- a/pcie/func_lib/pcie_func/pcie_link_ltssm.c
|
||
|
|
+++ b/pcie/func_lib/pcie_func/pcie_link_ltssm.c
|
||
|
|
@@ -213,7 +213,7 @@ static int pcie_print_ltssm_trace(const uint64_t *ltssm_input, uint32_t ltssm_nu
|
||
|
|
(uint32_t)ltssm_val.bits.any_change_pipe_req,
|
||
|
|
(uint32_t)ltssm_val.bits.rxl0s_st,
|
||
|
|
(uint32_t)ltssm_val.bits.train_bit_map1,
|
||
|
|
- (((uint32_t)ltssm_val.bits.rxl0s_st) << 2) |
|
||
|
|
+ (((uint32_t)ltssm_val.bits.rxl0s_st) << GEN5_BIT_OFFEST) |
|
||
|
|
((uint32_t)ltssm_val.bits.mac_rate),
|
||
|
|
(uint32_t)ltssm_val.bits.duration_counter,
|
||
|
|
(uint32_t)ltssm_val.bits.ltssm_state,
|
||
|
|
@@ -271,7 +271,6 @@ int pcie_ltssm_trace_clear(uint32_t port_id)
|
||
|
|
|
||
|
|
int pcie_ltssm_link_status_get(uint32_t port_id)
|
||
|
|
{
|
||
|
|
- uint32_t i;
|
||
|
|
union pcie_link_info reg_val;
|
||
|
|
struct hikp_cmd_header req_header;
|
||
|
|
struct hikp_cmd_ret *cmd_ret;
|
||
|
|
diff --git a/pcie/func_lib/pcie_func/pcie_link_ltssm.h b/pcie/func_lib/pcie_func/pcie_link_ltssm.h
|
||
|
|
index 8f3502b..cc51501 100644
|
||
|
|
--- a/pcie/func_lib/pcie_func/pcie_link_ltssm.h
|
||
|
|
+++ b/pcie/func_lib/pcie_func/pcie_link_ltssm.h
|
||
|
|
@@ -19,6 +19,7 @@
|
||
|
|
#define TRACE_STR_NUM 0x20
|
||
|
|
#define TRACER_DEPTH 65
|
||
|
|
#define PM_TRACE_STR_NUM 0x28
|
||
|
|
+#define GEN5_BIT_OFFEST 2
|
||
|
|
|
||
|
|
struct pcie_ltssm_num_string {
|
||
|
|
int ltssm;
|
||
|
|
diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.c b/pcie/func_lib/pcie_func/pcie_reg_dump.c
|
||
|
|
index aac3843..b8c2241 100644
|
||
|
|
--- a/pcie/func_lib/pcie_func/pcie_reg_dump.c
|
||
|
|
+++ b/pcie/func_lib/pcie_func/pcie_reg_dump.c
|
||
|
|
@@ -405,7 +405,7 @@ static int pcie_create_dumpreg_log_file(uint32_t port_id, uint32_t dump_level)
|
||
|
|
|
||
|
|
(void)remove((const char *)file_name);
|
||
|
|
/* Add write permission to the file */
|
||
|
|
- fd_file = open(file_name, O_RDWR | O_SYNC | O_CREAT, 0640);
|
||
|
|
+ fd_file = open(file_name, O_RDWR | O_SYNC | O_CREAT, 0600);
|
||
|
|
if (fd_file < 0) {
|
||
|
|
Err("PCIe DUMPREG", "open %s failed.\n", file_name);
|
||
|
|
return -EPERM;
|
||
|
|
@@ -419,7 +419,7 @@ static int pcie_close_dumpreg_log_file(void)
|
||
|
|
{
|
||
|
|
int ret;
|
||
|
|
|
||
|
|
- ret = fchmod(g_pcie_dumpreg_fd, 0440);
|
||
|
|
+ ret = fchmod(g_pcie_dumpreg_fd, 0400);
|
||
|
|
close(g_pcie_dumpreg_fd);
|
||
|
|
/* Revoke write permission of file */
|
||
|
|
g_pcie_dumpreg_fd = -1;
|
||
|
|
diff --git a/pcie/func_lib/pcie_func/pcie_statistics.c b/pcie/func_lib/pcie_func/pcie_statistics.c
|
||
|
|
index 40e5645..ed42cec 100644
|
||
|
|
--- a/pcie/func_lib/pcie_func/pcie_statistics.c
|
||
|
|
+++ b/pcie/func_lib/pcie_func/pcie_statistics.c
|
||
|
|
@@ -63,7 +63,7 @@ static int port_distribution_rsp_data_check(const struct hikp_cmd_ret *cmd_ret,
|
||
|
|
}
|
||
|
|
|
||
|
|
static int pcie_portid_serdes_relation(const struct pcie_macro_info *macro_info,
|
||
|
|
- uint32_t macro_num, uint32_t ndie_id)
|
||
|
|
+ uint32_t macro_num, uint32_t ndie_id)
|
||
|
|
{
|
||
|
|
uint32_t i, j;
|
||
|
|
|
||
|
|
@@ -90,7 +90,7 @@ int pcie_port_distribution_get(uint32_t chip_id)
|
||
|
|
struct hikp_cmd_header req_header;
|
||
|
|
struct hikp_cmd_ret *cmd_ret;
|
||
|
|
struct pcie_info_req_para req_data = { 0 };
|
||
|
|
- uint32_t src_size, dst_size, pair_num;
|
||
|
|
+ uint32_t pair_num;
|
||
|
|
struct pcie_port_info *port_info;
|
||
|
|
uint32_t i;
|
||
|
|
int ret;
|
||
|
|
diff --git a/sas/sas_func/sas_read_dev.c b/sas/sas_func/sas_read_dev.c
|
||
|
|
index 3a3db07..670e2d4 100644
|
||
|
|
--- a/sas/sas_func/sas_read_dev.c
|
||
|
|
+++ b/sas/sas_func/sas_read_dev.c
|
||
|
|
@@ -78,8 +78,6 @@ static void print_dev_link(const uint32_t *reg_save, uint32_t reg_num)
|
||
|
|
|
||
|
|
static void sas_print_dev(const uint32_t *reg_save, uint32_t reg_num, uint32_t cmd_type)
|
||
|
|
{
|
||
|
|
- uint32_t i;
|
||
|
|
-
|
||
|
|
if (reg_num == 0) {
|
||
|
|
printf("SAS device is failed\n");
|
||
|
|
return;
|
||
|
|
diff --git a/sas/sas_func/sas_read_dqe.c b/sas/sas_func/sas_read_dqe.c
|
||
|
|
index dbd30f3..7d49c0a 100644
|
||
|
|
--- a/sas/sas_func/sas_read_dqe.c
|
||
|
|
+++ b/sas/sas_func/sas_read_dqe.c
|
||
|
|
@@ -57,7 +57,7 @@ static void print_dqe_info(const void *reg_save, uint32_t reg_num)
|
||
|
|
printf("TLR_Ctrl: %u\n", dqe->dw0.TLR_Ctrl);
|
||
|
|
printf("Phy_ID: %u\n", dqe->dw0.Phy_ID);
|
||
|
|
printf("Force_Phy: %u\n", dqe->dw0.Force_Phy);
|
||
|
|
- printf("PORT: 0x%llx\n", dqe->dw0.PORT);
|
||
|
|
+ printf("PORT: 0x%x\n", dqe->dw0.PORT);
|
||
|
|
printf("PRI: %u\n", dqe->dw0.PRI);
|
||
|
|
printf("CMD: %u\n", dqe->dw0.CMD);
|
||
|
|
|
||
|
|
@@ -68,7 +68,7 @@ static void print_dqe_info(const void *reg_save, uint32_t reg_num)
|
||
|
|
printf("Reset: %u\n", dqe->dw1.Reset);
|
||
|
|
printf("PIR_Present: %u\n", dqe->dw1.PIR_Present);
|
||
|
|
printf("Enable_Transport_Layer_Retry: %u\n", dqe->dw1.Enable_Transport_Layer_Retry);
|
||
|
|
- printf("Verify_Data_Transfer_Length: 0x%llx\n", dqe->dw1.Verify_Data_Transfer_Length);
|
||
|
|
+ printf("Verify_Data_Transfer_Length: 0x%x\n", dqe->dw1.Verify_Data_Transfer_Length);
|
||
|
|
printf("Frame_Type: %u\n", dqe->dw1.Frame_Type);
|
||
|
|
printf("Device_ID: %u\n", dqe->dw1.Device_ID);
|
||
|
|
|
||
|
|
diff --git a/sas/user_cmd/cmd_code/sas_cmd_dqe.c b/sas/user_cmd/cmd_code/sas_cmd_dqe.c
|
||
|
|
index 4a9547a..26bf0eb 100644
|
||
|
|
--- a/sas/user_cmd/cmd_code/sas_cmd_dqe.c
|
||
|
|
+++ b/sas/user_cmd/cmd_code/sas_cmd_dqe.c
|
||
|
|
@@ -44,7 +44,6 @@ static int sas_dqe_info(struct major_cmd_ctrl *self, const char *argv)
|
||
|
|
static int sas_set_queue_id(struct major_cmd_ctrl *self, const char *argv)
|
||
|
|
{
|
||
|
|
int ret;
|
||
|
|
- uint32_t val = 0;
|
||
|
|
|
||
|
|
ret = sas_set_que_id(self, argv);
|
||
|
|
if (ret || sas_get_que_id() >= SAS_QUEUE_NUM) {
|
||
|
|
diff --git a/sas/user_cmd/cmd_code/sas_cmd_dump.c b/sas/user_cmd/cmd_code/sas_cmd_dump.c
|
||
|
|
index 4f2cfea..e7dedf0 100644
|
||
|
|
--- a/sas/user_cmd/cmd_code/sas_cmd_dump.c
|
||
|
|
+++ b/sas/user_cmd/cmd_code/sas_cmd_dump.c
|
||
|
|
@@ -42,7 +42,6 @@ static int sas_dump_global(struct major_cmd_ctrl *self, const char *argv)
|
||
|
|
static int sas_dump_phyx(struct major_cmd_ctrl *self, char const *argv)
|
||
|
|
{
|
||
|
|
int ret;
|
||
|
|
- uint32_t val = 0;
|
||
|
|
|
||
|
|
(void)sas_set_cmd_type(DUMP_PHYX);
|
||
|
|
ret = sas_set_phy_id(self, argv);
|
||
|
|
diff --git a/serdes/hikp_serdes.c b/serdes/hikp_serdes.c
|
||
|
|
index 320ded2..4afcb9b 100644
|
||
|
|
--- a/serdes/hikp_serdes.c
|
||
|
|
+++ b/serdes/hikp_serdes.c
|
||
|
|
@@ -322,7 +322,7 @@ static void hikp_serdes_info_cmd_execute(struct major_cmd_ctrl *self)
|
||
|
|
SERDES_OUTPUT_MAX_SIZE) {
|
||
|
|
self->err_no = -EINVAL;
|
||
|
|
snprintf(self->err_str, sizeof(self->err_str),
|
||
|
|
- "serdes_info rsp_data data copy size error, data size:0x%x max size:0x%x.",
|
||
|
|
+ "serdes_info rsp_data data copy size error, data size:0x%zx max size:0x%x.",
|
||
|
|
(cmd_ret->rsp_data_num * sizeof(uint32_t) - out_out_header_size),
|
||
|
|
SERDES_OUTPUT_MAX_SIZE);
|
||
|
|
goto err_out;
|
||
|
|
@@ -480,7 +480,7 @@ static void hikp_serdes_dump_cmd_execute(struct major_cmd_ctrl *self)
|
||
|
|
SERDES_OUTPUT_MAX_SIZE) {
|
||
|
|
self->err_no = -EINVAL;
|
||
|
|
snprintf(self->err_str, sizeof(self->err_str),
|
||
|
|
- "serdes_dump rsp_data data copy size error, data size:0x%x max size:0x%x.",
|
||
|
|
+ "serdes_dump rsp_data data copy size error, data size:0x%zx max size:0x%x.",
|
||
|
|
(cmd_ret->rsp_data_num * sizeof(uint32_t) - out_out_header_size),
|
||
|
|
SERDES_OUTPUT_MAX_SIZE);
|
||
|
|
goto err_out;
|
||
|
|
diff --git a/socip/hikp_socip_dumpreg.c b/socip/hikp_socip_dumpreg.c
|
||
|
|
index 0153dd9..7b11523 100644
|
||
|
|
--- a/socip/hikp_socip_dumpreg.c
|
||
|
|
+++ b/socip/hikp_socip_dumpreg.c
|
||
|
|
@@ -108,7 +108,6 @@ static bool check_socip_dumpreg_param(void)
|
||
|
|
static void dump_reg_info(const uint32_t *reg_data, uint32_t data_num)
|
||
|
|
{
|
||
|
|
#define ONE_LINE_PRINT_DATA_NUM 4
|
||
|
|
- struct dump_reg_param_t *param = &g_dump_reg_param[0];
|
||
|
|
uint32_t i;
|
||
|
|
|
||
|
|
for (i = 0; i < data_num; i++) {
|
||
|
|
diff --git a/tool_lib/op_logs.c b/tool_lib/op_logs.c
|
||
|
|
index d91ddb0..f57f5fd 100644
|
||
|
|
--- a/tool_lib/op_logs.c
|
||
|
|
+++ b/tool_lib/op_logs.c
|
||
|
|
@@ -29,7 +29,6 @@ static void op_log_write(const char *log_data)
|
||
|
|
{
|
||
|
|
size_t w_size;
|
||
|
|
FILE *fd;
|
||
|
|
- int ret;
|
||
|
|
|
||
|
|
if (strlen(g_op_log) == 0)
|
||
|
|
return;
|
||
|
|
@@ -108,8 +107,6 @@ static int op_log_add_time_to_log(char *log_base, int *offset, uint32_t flag)
|
||
|
|
struct timeval tv;
|
||
|
|
struct tm ptm;
|
||
|
|
int len = 0;
|
||
|
|
- long usec;
|
||
|
|
- long sec;
|
||
|
|
int ret;
|
||
|
|
|
||
|
|
(void)gettimeofday(&tv, NULL);
|
||
|
|
@@ -118,12 +115,18 @@ static int op_log_add_time_to_log(char *log_base, int *offset, uint32_t flag)
|
||
|
|
g_tv = tv;
|
||
|
|
len = (int)strftime(log_base + *offset, (OP_LOG_FILE_W_MAXSIZE + 1 - *offset),
|
||
|
|
OP_LOG_TIME_TEMP, &ptm);
|
||
|
|
+ if ((*offset + len) >= (OP_LOG_FILE_W_MAXSIZE + 1))
|
||
|
|
+ return -ENOMEM;
|
||
|
|
+
|
||
|
|
ret = snprintf(log_base + *offset + len,
|
||
|
|
(OP_LOG_FILE_W_MAXSIZE + 1 - *offset - len), OP_LOG_SEC_TIME_TEMP,
|
||
|
|
tv.tv_sec + tv.tv_usec / OP_LOG_SEC_AND_MICROSEC_TRANS);
|
||
|
|
- } else if (flag == LOG_FLAG_ONLY_TIME) {
|
||
|
|
+ } else {
|
||
|
|
len = (int)strftime(log_base + *offset, (OP_LOG_FILE_W_MAXSIZE + 1 - *offset),
|
||
|
|
OP_LOG_RESULT_TIME_TEMP, &ptm);
|
||
|
|
+ if ((*offset + len) >= (OP_LOG_FILE_W_MAXSIZE + 1))
|
||
|
|
+ return -ENOMEM;
|
||
|
|
+
|
||
|
|
ret = snprintf(log_base + *offset + len,
|
||
|
|
(OP_LOG_FILE_W_MAXSIZE + 1 - *offset - len),
|
||
|
|
OP_LOG_SEC_TIME_TEMP,
|
||
|
|
@@ -157,7 +160,6 @@ static int op_log_file_rollback(const char *op_log_backup, const char *log_dir)
|
||
|
|
char rollback_log[OP_LOG_FILE_W_MAXSIZE + 1] = {0};
|
||
|
|
int offset = 0;
|
||
|
|
int ret;
|
||
|
|
- int len;
|
||
|
|
|
||
|
|
ret = file_rollback(g_op_log, op_log_backup, OP_LOG_FILE_MAX_SIZE);
|
||
|
|
if (ret) {
|
||
|
|
@@ -280,10 +282,14 @@ void op_log_record_input(const int argc, const char **argv)
|
||
|
|
|
||
|
|
arg = input_str;
|
||
|
|
for (i = 0; i < argc; i++) {
|
||
|
|
- snprintf(arg, (sizeof(input_str) - (arg - input_str)), "%s ", argv[i]);
|
||
|
|
+ ret = snprintf(arg, (sizeof(input_str) - (arg - input_str)), "%s ", argv[i]);
|
||
|
|
+ if (ret < 0 || ret >= (sizeof(input_str) - (arg - input_str)))
|
||
|
|
+ return;
|
||
|
|
+
|
||
|
|
arg = arg + strlen(argv[i]) + 1;
|
||
|
|
}
|
||
|
|
input_str[strlen(input_str) - 1] = 0;
|
||
|
|
+
|
||
|
|
arr_size = HIKP_ARRAY_SIZE(log_info);
|
||
|
|
for (i = 0; i < arr_size; i++) {
|
||
|
|
ret = snprintf(g_input_buf + offset, (OP_LOG_FILE_W_MAXSIZE + 1 - offset),
|
||
|
|
diff --git a/tool_lib/tool_cmd.c b/tool_lib/tool_cmd.c
|
||
|
|
index 43a3b61..db54f0f 100644
|
||
|
|
--- a/tool_lib/tool_cmd.c
|
||
|
|
+++ b/tool_lib/tool_cmd.c
|
||
|
|
@@ -186,7 +186,6 @@ void command_parse_and_excute(const int argc, const char **argv)
|
||
|
|
{
|
||
|
|
struct major_cmd_ctrl *major_cmd = get_major_cmd();
|
||
|
|
int lock_fd;
|
||
|
|
- int check;
|
||
|
|
int ret;
|
||
|
|
|
||
|
|
major_cmd->err_no = check_command_length(argc, argv);
|
||
|
|
diff --git a/tool_lib/tool_lib.c b/tool_lib/tool_lib.c
|
||
|
|
index ad4bb68..180418f 100644
|
||
|
|
--- a/tool_lib/tool_lib.c
|
||
|
|
+++ b/tool_lib/tool_lib.c
|
||
|
|
@@ -337,6 +337,9 @@ bool tool_can_print(uint32_t interval, uint32_t burst, uint32_t *print_num, uint
|
||
|
|
{
|
||
|
|
uint64_t cur_time;
|
||
|
|
|
||
|
|
+ if (!print_num || !last_time)
|
||
|
|
+ return false;
|
||
|
|
+
|
||
|
|
cur_time = (uint64_t)time(NULL);
|
||
|
|
if ((*last_time + interval) == cur_time)
|
||
|
|
*print_num = 0;
|
||
|
|
--
|
||
|
|
2.42.0.windows.2
|
||
|
|
|