All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ivan Delalande <colona@arista.com>
To: mchehab@kernel.org, linux-edac@vger.kernel.org
Subject: [PATCH] rasdaemon: don't emit error syslog when exiting normally
Date: Fri, 19 Apr 2024 14:21:51 -0700	[thread overview]
Message-ID: <20240419212151.GA98667@visor> (raw)

Tidy up read_ras_event_all_cpus exit path so that it returns 0 when
exiting normally after receiving a signal. It would return -1 and make
the caller emit "Huh! something got wrong. Aborting." in this case.

Also add missing error message for ras_mc_event_opendb and fix the
grammar a bit in the message above.

Fixes: a7b6a0464fba ("rasdaemon: add signal handling for the cleanup")
Signed-off-by: Ivan Delalande <colona@arista.com>
---
 ras-events.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/ras-events.c b/ras-events.c
index a097238..200163a 100644
--- a/ras-events.c
+++ b/ras-events.c
@@ -430,7 +430,7 @@ static int read_ras_event_all_cpus(struct pthread_data *pdata,
 	sigset_t mask;
 	int warnonce[n_cpus];
 	char pipe_raw[PATH_MAX];
-	int legacy_kernel = 0;
+	int rc = 0;
 #if 0
 	int need_sleep = 0;
 #endif
@@ -473,6 +473,7 @@ static int read_ras_event_all_cpus(struct pthread_data *pdata,
 		fds[i].fd = open_trace(pdata[0].ras, pipe_raw, O_RDONLY);
 		if (fds[i].fd < 0) {
 			log(TERM, LOG_ERR, "Can't open trace_pipe_raw\n");
+			rc = -1;
 			goto error;
 		}
 	}
@@ -488,13 +489,17 @@ static int read_ras_event_all_cpus(struct pthread_data *pdata,
 	fds[n_cpus].fd = signalfd(-1, &mask, 0);
 	if (fds[n_cpus].fd < 0) {
 		log(TERM, LOG_WARNING, "signalfd\n");
+		rc = -1;
 		goto error;
 	}
 
 	log(TERM, LOG_INFO, "Listening to events for cpus 0 to %d\n", n_cpus - 1);
 	if (pdata[0].ras->record_events) {
-		if (ras_mc_event_opendb(pdata[0].cpu, pdata[0].ras))
+		if (ras_mc_event_opendb(pdata[0].cpu, pdata[0].ras)) {
+			log(TERM, LOG_ERR, "Can't open database\n");
+			rc = -1;
 			goto error;
+		}
 #ifdef HAVE_NON_STANDARD
 		if (ras_ns_add_vendor_tables(pdata[0].ras))
 			log(TERM, LOG_ERR, "Can't add vendor table\n");
@@ -577,7 +582,7 @@ static int read_ras_event_all_cpus(struct pthread_data *pdata,
 		 */
 		if (count_nready == n_cpus) {
 			/* Should only happen with legacy kernels */
-			legacy_kernel = 1;
+			rc = -255;
 			break;
 		}
 #endif
@@ -605,10 +610,7 @@ error:
 			close(fds[i].fd);
 	}
 
-	if (legacy_kernel)
-		return -255;
-	else
-		return -1;
+	return rc;
 }
 
 static int read_ras_event(int fd,
@@ -1162,7 +1164,8 @@ int handle_ras_events(int record_events)
 		pthread_mutex_destroy(&ras->db_lock);
 	}
 
-	log(SYSLOG, LOG_INFO, "Huh! something got wrong. Aborting.\n");
+	if (rc)
+		log(SYSLOG, LOG_INFO, "Huh! something went wrong. Aborting.\n");
 
 err:
 	if (data)
-- 
2.34.1

                 reply	other threads:[~2024-04-19 21:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240419212151.GA98667@visor \
    --to=colona@arista.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.