]> www.infradead.org Git - users/mchehab/rasdaemon.git/commitdiff
rasdaemon: fix issue of signed and unsigned integer comparison and remove redundant...
authorXiaofei Tan <tanxiaofei@huawei.com>
Tue, 30 May 2023 10:44:12 +0000 (11:44 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Mon, 23 Oct 2023 08:49:39 +0000 (10:49 +0200)
1. The return value of ARRAY_SIZE() is unsigned integer. It isn't right to
compare it with a signed integer. This patch fix them.

2. Remove redundant header file and adjust the header files sequence.

Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
Signed-off-by: Shiju Jose <shiju.jose@huawei.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
non-standard-hisi_hip08.c
non-standard-hisilicon.c
ras-diskerror-handler.c
ras-memory-failure-handler.c

index 4ef47ea6b962e3b7d22468027729ea774ceb1058..61f12eb1c18f4b078c88d34272a6cf653d743b76 100644 (file)
@@ -1029,7 +1029,7 @@ static struct ras_ns_ev_decoder hip08_ns_ev_decoder[] = {
 
 static void __attribute__((constructor)) hip08_init(void)
 {
-       int i;
+       unsigned int i;
 
        for (i = 0; i < ARRAY_SIZE(hip08_ns_ev_decoder); i++)
                register_ns_ev_decoder(&hip08_ns_ev_decoder[i]);
index 2b00ed6f34160b75ff22be9f54ec522278552308..721821eed59ea49101f84fc948d0533dcb4bb61a 100644 (file)
@@ -366,13 +366,13 @@ static int decode_hisi_common_section(struct ras_events *ras,
        trace_seq_printf(s, "%s\n", hevent.error_msg);
 
        if (err->val_bits & BIT(HISI_COMMON_VALID_REG_ARRAY_SIZE) && err->reg_array_size > 0) {
-               int i;
+               unsigned int i;
 
                trace_seq_printf(s, "Register Dump:\n");
                for (i = 0; i < err->reg_array_size / sizeof(uint32_t); i++) {
-                       trace_seq_printf(s, "reg%02d=0x%08x\n", i,
+                       trace_seq_printf(s, "reg%02u=0x%08x\n", i,
                                         err->reg_array[i]);
-                       HISI_SNPRINTF(hevent.reg_msg, "reg%02d=0x%08x",
+                       HISI_SNPRINTF(hevent.reg_msg, "reg%02u=0x%08x",
                                      i, err->reg_array[i]);
                }
        }
@@ -398,7 +398,7 @@ static struct ras_ns_ev_decoder hisi_section_ns_ev_decoder[]  = {
 
 static void __attribute__((constructor)) hisi_ns_init(void)
 {
-       int i;
+       unsigned int i;
 
        for (i = 0; i < ARRAY_SIZE(hisi_section_ns_ev_decoder); i++)
                register_ns_ev_decoder(&hisi_section_ns_ev_decoder[i]);
index 38d0a36c239784e88481d2cab8d503c10676997b..638cb4d9902ad7097d592a18a364eb8e1fb7d4c7 100644 (file)
@@ -52,7 +52,7 @@ static const struct {
 
 static const char *get_blk_error(int err)
 {
-       int i;
+       unsigned int i;
 
        for (i = 0; i < ARRAY_SIZE(blk_errors); i++)
                if (blk_errors[i].error == err)
index 72c65deab16ba3723342dc11cf0693f50e53f95b..c74541f4dca3e865b6caa5830cd75347a90247c8 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <traceevent/kbuffer.h>
-#include "ras-memory-failure-handler.h"
 #include "ras-record.h"
 #include "ras-logger.h"
 #include "ras-report.h"
+#include "ras-memory-failure-handler.h"
 
 /* Memory failure - various types of pages */
 enum mf_action_page_type {
@@ -99,7 +98,7 @@ static const struct {
 
 static const char *get_page_type(int page_type)
 {
-       int i;
+       unsigned int i;
 
        for (i = 0; i < ARRAY_SIZE(mf_page_type); i++)
                if (mf_page_type[i].type == page_type)
@@ -110,7 +109,7 @@ static const char *get_page_type(int page_type)
 
 static const char *get_action_result(int result)
 {
-       int i;
+       unsigned int i;
 
        for (i = 0; i < ARRAY_SIZE(mf_action_result); i++)
                if (mf_action_result[i].result == result)