]> www.infradead.org Git - users/mchehab/rasdaemon.git/commitdiff
rasdaemon: cleanup coding style
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Fri, 19 Jul 2024 07:29:51 +0000 (09:29 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Fri, 19 Jul 2024 07:31:54 +0000 (09:31 +0200)
Solve a series of coding style warnings:

mce-amd.c:132: WARNING:RETURN_VOID: void function return statements are not generally useful
mce-amd-smca.c:984: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'm->family == 0x19'
non-standard-ampere.c:743: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'err->subtype == 0x01'
non-standard-ampere.c:743: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'err->subtype == 0x02'
non-standard-jaguarmicro.c:382: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'mod_id >= tbl_size'
non-standard-jaguarmicro.c:382: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around '!module'
non-standard-jaguarmicro.c:425: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'sub_id >= tbl_size'
non-standard-jaguarmicro.c:425: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around '!sub_module'
ras-cxl-handler.c:408: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'i > 0'
ras-cxl-handler.c:705: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'i > 0'
ras-mce-handler.c:251: WARNING:USE_NEGATIVE_ERRNO: return of an errno should typically be negative (ie: return -ENOMEM)

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
mce-amd-smca.c
mce-amd.c
non-standard-ampere.c
non-standard-jaguarmicro.c
ras-cxl-handler.c
ras-events.c
ras-mce-handler.c

index 3e39e94c82fbf67615b10387bdbe82b170cbba5b..eaf35279f055ad88ddbd5eec38ac7254f4e58002 100644 (file)
@@ -981,7 +981,7 @@ void decode_smca_error(struct mce_event *e, struct mce_priv *m)
                             xec);
 
        if ((bank_type == SMCA_UMC || bank_type == SMCA_UMC_QUIRK) && xec == 0) {
-               if ((m->family == 0x19) && (m->model >= 0x90 && m->model <= 0x9f)) {
+               if (m->family == 0x19 && (m->model >= 0x90 && m->model <= 0x9f)) {
                        /* MCA_IPID[InstanceIdHi] give the AMD Node Die ID */
                        mce_snprintf(e->mc_location, "memory_die_id=%d", mcatype_instancehi / 4);
                } else {
index 4ab6329795c4f79e34ebff2f2411fa0f401543f8..c4a5dcf6f4a6cb00014d2daeec676edaa307d7ba 100644 (file)
--- a/mce-amd.c
+++ b/mce-amd.c
@@ -128,5 +128,4 @@ void decode_amd_errcode(struct mce_event *e)
                             "Bus Error '%s, %s, mem-tx: %s, level: %s'",
                             PP_MSG(ec), TO_MSG(ec),
                             R4_MSG(ec), LL_MSG(ec));
-       return;
 }
index 6f6e435a6b8e60d8993284d5b2d7beaa8d5e55d8..01f63911a0ebec39a9fd029f479ac28c84b74c37 100644 (file)
@@ -740,8 +740,7 @@ void decode_amp_payload0_err_regs(struct ras_ns_ev_decoder *ev_decoder,
        p += snprintf(p, end - p, " 0x%x\n", INSTANCE(err->instance));
 
        //display socket number
-       if ((TYPE(err->type) == 0) &&
-           ((err->subtype == 0x01) || (err->subtype == 0x02))) {
+       if (!TYPE(err->type) && (err->subtype == 0x01 || err->subtype == 0x02)) {
                core_num = INSTANCE(err->instance) * 2 + err->subtype - 1;
                p += snprintf(p, end - p, " %s",
                              disp_payload1_err_reg_name[i++]);
index 391be9d26c4264169f2e54ef49cc606ca4ae10ad..df763e7a07c279ea7713fcdc78d4997d98711381 100644 (file)
@@ -379,7 +379,7 @@ static const char *get_jm_module_desc(uint8_t subsys_id, uint8_t mod_id)
                break;
        }
 
-       if ((!module) || (mod_id >= tbl_size))
+       if (!module || mod_id >= tbl_size)
                return "unknown";
 
        return module[mod_id];
@@ -422,7 +422,7 @@ static const char *get_jm_submod_desc(uint8_t subsys_id, uint8_t mod_id, uint8_t
                tbl_size = 0;
        }
 
-       if ((!sub_module) || (sub_id >= tbl_size))
+       if (!sub_module || sub_id >= tbl_size)
                return "unknown";
 
        return sub_module[sub_id];
index e49c1282498547adbe1187a3b934085ef9fab471..9f997e4fd3cbe7acd43d75389e6b4b41236c091b 100644 (file)
@@ -405,7 +405,7 @@ int ras_cxl_aer_ue_event_handler(struct trace_seq *s,
        for (i = 0; i < CXL_HEADERLOG_SIZE_U32; i++) {
                if (trace_seq_printf(s, "%08x ", ev.header_log[i]) <= 0)
                        break;
-               if ((i > 0) && ((i % 20) == 0))
+               if (i > 0 && ((i % 20) == 0))
                        if (trace_seq_printf(s, "\n") <= 0)
                                break;
                /* Convert header log data to the big-endian format because
@@ -702,7 +702,7 @@ int ras_cxl_generic_event_handler(struct trace_seq *s,
        if (trace_seq_printf(s, "\ndata:\n  %08x: ", i) <= 0)
                return -1;
        for (i = 0; i < CXL_EVENT_RECORD_DATA_LENGTH; i += 4) {
-               if ((i > 0) && ((i % 16) == 0))
+               if (i > 0 && ((i % 16) == 0))
                        if (trace_seq_printf(s, "\n  %08x: ", i) <= 0)
                                break;
                if (trace_seq_printf(s, "%02x%02x%02x%02x ",
index a1eeb8e6e046cf0d0d4539a7d1b2d9514b9e33b3..83c7a3798664a4f35ab3fc5c16fd73de06e02997 100644 (file)
@@ -126,10 +126,13 @@ static int open_trace(struct ras_events *ras, char *name, int flags)
                return rc;
 
        rc = open(fname, flags);
-       if (rc)
+       if (rc < 0) {
+               rc = -errno;
+
                return -errno;
+       }
 
-       return 0;
+       return rc;
 }
 
 static int get_tracing_dir(struct ras_events *ras)
@@ -829,17 +832,24 @@ static int add_event_handler(struct ras_events *ras, struct tep_handle *pevent,
 
        fd = open_trace(ras, fname, O_RDONLY);
        if (fd < 0) {
-               log(TERM, LOG_ERR,
-                   "Can't get %s:%s traces. Perhaps this feature is not supported on your system.\n",
-                   group, event);
-               return -errno;
+               if (fd == -ENOENT) {
+                       log(TERM, LOG_ERR,
+                           "Feature %s:%s not supported on your system.\n",
+                           group, event);
+                       return EVENT_DISABLED;
+               }
+
+               log(TERM, LOG_ERR, "Can't get %s:%s traces: %s\n",
+                   group, event, strerror(-fd));
+
+               return fd;
        }
 
        page = malloc(page_size);
        if (!page) {
+               rc = -errno;
                log(TERM, LOG_ERR, "Can't allocate page to read %s:%s format\n",
                    group, event);
-               rc = -errno;
                close(fd);
                return rc;
        }
@@ -939,10 +949,8 @@ int handle_ras_events(int record_events)
        }
 
        rc = select_tracing_timestamp(ras);
-       if (rc < 0) {
-               log(TERM, LOG_ERR, "Can't select a timestamp for tracing\n");
-               goto err;
-       }
+       if (rc < 0)
+               log(TERM, LOG_ERR, "Can't select a timestamp for tracing. Using default\n");
 
        pevent = tep_alloc();
        if (!pevent) {
@@ -975,7 +983,7 @@ int handle_ras_events(int record_events)
                               ras_aer_event_handler, NULL, AER_EVENT);
        if (!rc)
                num_events++;
-       else if (rc != EVENT_DISABLED)
+       else if (rc != EVENT_DISABLED && rc != ENOENT)
                log(ALL, LOG_ERR, "Can't get traces from %s:%s\n",
                    "ras", "aer_event");
 #endif
@@ -1154,7 +1162,7 @@ int handle_ras_events(int record_events)
 
        if (!num_events) {
                log(ALL, LOG_INFO,
-                   "Failed to trace all supported RAS events. Aborting.\n");
+                   "Failed to trace any supported RAS events. Aborting.\n");
                rc = -EINVAL;
                goto err;
        }
index fe499851850a8e983d3069158b3db7829ab86884..c9b17d377e6c5d50ad3b881fde16872b07dd5373 100644 (file)
@@ -248,7 +248,7 @@ int register_mce_handler(struct ras_events *ras, unsigned int ncpus)
        ras->mce_priv = calloc(1, sizeof(struct mce_priv));
        if (!ras->mce_priv) {
                log(ALL, LOG_INFO, "Can't allocate memory MCE data\n");
-               return ENOMEM;
+               return -ENOMEM;
        }
 
        mce = ras->mce_priv;