[PATCH] rasdaemon: Fix the issue of sprintf data type mismatch in uuid_le()

The data type of sprintf called in the function uuid_le() is not 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 | 2 +- 2 files changed, 2 insertions(+), 2 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..879f394 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: -- 2.33.0
participants (1)
-
Xiaofei Tan