From: Mauro Carvalho Chehab Date: Fri, 19 Jul 2024 07:29:51 +0000 (+0200) Subject: rasdaemon: cleanup coding style X-Git-Tag: v0.8.2~45 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a8d11d86830e334a28fef82bb77c567aacdae47a;p=users%2Fmchehab%2Frasdaemon.git rasdaemon: cleanup coding style 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 --- diff --git a/mce-amd-smca.c b/mce-amd-smca.c index 3e39e94..eaf3527 100644 --- a/mce-amd-smca.c +++ b/mce-amd-smca.c @@ -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 { diff --git a/mce-amd.c b/mce-amd.c index 4ab6329..c4a5dcf 100644 --- 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; } diff --git a/non-standard-ampere.c b/non-standard-ampere.c index 6f6e435..01f6391 100644 --- a/non-standard-ampere.c +++ b/non-standard-ampere.c @@ -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++]); diff --git a/non-standard-jaguarmicro.c b/non-standard-jaguarmicro.c index 391be9d..df763e7 100644 --- a/non-standard-jaguarmicro.c +++ b/non-standard-jaguarmicro.c @@ -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]; diff --git a/ras-cxl-handler.c b/ras-cxl-handler.c index e49c128..9f997e4 100644 --- a/ras-cxl-handler.c +++ b/ras-cxl-handler.c @@ -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 ", diff --git a/ras-events.c b/ras-events.c index a1eeb8e..83c7a37 100644 --- a/ras-events.c +++ b/ras-events.c @@ -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; } diff --git a/ras-mce-handler.c b/ras-mce-handler.c index fe49985..c9b17d3 100644 --- a/ras-mce-handler.c +++ b/ras-mce-handler.c @@ -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;