rasdaemon/0001-rasdaemon-Fix-the-issue-of-sprintf-data-type-mismatc.patch

56 lines
1.9 KiB
Diff
Raw Normal View History

From 44fa917e290255570772926a2a11fd5bee3af90c Mon Sep 17 00:00:00 2001
From: Xiaofei Tan <tanxiaofei@huawei.com>
Date: Mon, 11 Oct 2021 10:22:10 +0800
Subject: [PATCH 1/4] rasdaemon: Fix the issue of sprintf data type mismatch in
uuid_le()
The data type of sprintf called in the function uuid_le() is mismatch.
Arm64 compiler force it to unsigned char by default, and can work normally.
But if someone compile it with the option -fsigned-char, the function
can't work correctly.
Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
---
ras-extlog-handler.c | 2 +-
ras-non-standard-handler.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/ras-extlog-handler.c b/ras-extlog-handler.c
index 5fd3580..1834687 100644
--- a/ras-extlog-handler.c
+++ b/ras-extlog-handler.c
@@ -152,7 +152,7 @@ static char *uuid_le(const char *uu)
static const unsigned char le[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15};
for (i = 0; i < 16; i++) {
- p += sprintf(p, "%.2x", uu[le[i]]);
+ p += sprintf(p, "%.2x", (unsigned char) uu[le[i]]);
switch (i) {
case 3:
case 5:
diff --git a/ras-non-standard-handler.c b/ras-non-standard-handler.c
index 6ccf5bc..6d5a6f8 100644
--- a/ras-non-standard-handler.c
+++ b/ras-non-standard-handler.c
@@ -36,7 +36,7 @@ static char *uuid_le(const char *uu)
static const unsigned char le[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15};
for (i = 0; i < 16; i++) {
- p += sprintf(p, "%.2x", uu[le[i]]);
+ p += sprintf(p, "%.2x", (unsigned char) uu[le[i]]);
switch (i) {
case 3:
case 5:
@@ -61,7 +61,7 @@ static int uuid_le_cmp(const char *sec_type, const char *uuid2)
3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15};
for (i = 0; i < 16; i++)
- p += sprintf(p, "%.2x", sec_type[le[i]]);
+ p += sprintf(p, "%.2x", (unsigned char) sec_type[le[i]]);
*p = 0;
return strncmp(uuid1, uuid2, 32);
}
--
2.33.0