rasdaemon/0001-rasdaemon-use-standard-length-PATH_MAX-for-path-name.patch
Xiaofei Tan e5920d76da rasdaemon: Fix startup core dumped issue.
Add the following patch to fix startup core dumped issue.
0001-rasdaemon-use-standard-length-PATH_MAX-for-path-name.patch

Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
(cherry picked from commit c5e8cb9176935b30077e38e50a2b7e280903460e)
2022-08-29 17:32:46 +08:00

47 lines
1.3 KiB
Diff

From: Xiaofei Tan <tanxiaofei@huawei.com>
Date: Sat, 20 Aug 2022 09:49:25 +0000
Subject: [PATCH] rasdaemon: use standard length PATH_MAX for path name
Use standard length PATH_MAX for path name space allocation
to replace the macro MAX_PATH_LEN.
Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
---
ras-cpu-isolation.c | 6 +++---
ras-cpu-isolation.h | 1 -
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/ras-cpu-isolation.c b/ras-cpu-isolation.c
index ba5ccd1..24c07e9 100644
--- a/ras-cpu-isolation.c
+++ b/ras-cpu-isolation.c
@@ -80,11 +80,11 @@ static const char * const cpu_state[] = {
static int open_sys_file(unsigned int cpu, int __oflag, const char *format)
{
int fd;
- char path[MAX_PATH_LEN + 1] = "";
- char real_path[MAX_PATH_LEN + 1] = "";
+ char path[PATH_MAX] = "";
+ char real_path[PATH_MAX] = "";
snprintf(path, sizeof(path), format, cpu);
- if (strlen(path) > MAX_PATH_LEN || realpath(path, real_path) == NULL) {
+ if (strlen(path) > PATH_MAX || realpath(path, real_path) == NULL) {
log(TERM, LOG_ERR, "[%s]:open file: %s failed\n", __func__, path);
return -1;
}
diff --git a/ras-cpu-isolation.h b/ras-cpu-isolation.h
index 024a68b..5682106 100644
--- a/ras-cpu-isolation.h
+++ b/ras-cpu-isolation.h
@@ -17,7 +17,6 @@
#include "queue.h"
-#define MAX_PATH_LEN 100
#define MAX_BUF_LEN 1024
struct param {
--
2.17.1