From 19928db4d89b645ca6be921f49098432533d0c3c Mon Sep 17 00:00:00 2001 From: luckky Date: Fri, 24 Jan 2025 09:53:09 +0800 Subject: [PATCH] fix some refactor bug --- src/sentryPlugins/hbm_online_repair/hbm-ras-events.c | 11 ++++++----- .../hbm_online_repair/hbm_online_repair.c | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/sentryPlugins/hbm_online_repair/hbm-ras-events.c b/src/sentryPlugins/hbm_online_repair/hbm-ras-events.c index 54ebb27..b859afb 100644 --- a/src/sentryPlugins/hbm_online_repair/hbm-ras-events.c +++ b/src/sentryPlugins/hbm_online_repair/hbm-ras-events.c @@ -25,6 +25,8 @@ #include "hbm-ras-handler.h" #include "logger.h" +#define SIG_LIST_LEN 4 + static int get_debugfs_dir(char *debugfs_dir, size_t len) { FILE *fp = fopen("/proc/mounts", "r"); @@ -265,9 +267,8 @@ static int read_ras_event_all_cpus(struct ras_events* ras, unsigned n_cpus) } sigemptyset(&mask); - int sig_list_len = 4; - int sig_list[sig_list_len] = {SIGINT, SIGTERM, SIGHUP, SIGQUIT}; - for (i = 0; i < sig_list_len; i++) { + int sig_list[SIG_LIST_LEN] = {SIGINT, SIGTERM, SIGHUP, SIGQUIT}; + for (i = 0; i < SIG_LIST_LEN; i++) { sigaddset(&mask, sig_list[i]); } if (sigprocmask(SIG_BLOCK, &mask, NULL) == -1) @@ -296,7 +297,7 @@ static int read_ras_event_all_cpus(struct ras_events* ras, unsigned n_cpus) continue; } - for (i = 0; i < sig_list_len; i++) { + for (i = 0; i < SIG_LIST_LEN; i++) { if (fdsiginfo.ssi_signo == sig_list[i]) { log(LOG_INFO, "Received signal=%d\n", fdsiginfo.ssi_signo); goto error; @@ -441,7 +442,7 @@ static int add_event_handler(struct ras_events *ras, struct tep_handle *pevent, int handle_ras_events(struct ras_events *ras) { - int rc, i; + int rc; unsigned cpus; struct tep_handle *pevent; diff --git a/src/sentryPlugins/hbm_online_repair/hbm_online_repair.c b/src/sentryPlugins/hbm_online_repair/hbm_online_repair.c index c843835..c6de011 100644 --- a/src/sentryPlugins/hbm_online_repair/hbm_online_repair.c +++ b/src/sentryPlugins/hbm_online_repair/hbm_online_repair.c @@ -78,7 +78,7 @@ int handle_driver(char* driver_name, bool load) snprintf(command, DRIVER_COMMAND_LEN, "%s %s 2>&1", load ? "modprobe" : "rmmod", driver_name); ret = execute_command(command); - log(ret < 0 ? LOG_ERROR : LOG_DEBUG, "%s %s %s\n", load ? "load" : "unload", driver_name, ret < 0 ? "failed" : "success"); + log((ret < 0 ? LOG_ERROR : LOG_DEBUG), "%s %s %s\n", load ? "load" : "unload", driver_name, ret < 0 ? "failed" : "success"); return ret; } -- Gitee