diff mbox series

rasdaemon: don't emit error syslog when exiting normally

Message ID 20240419212151.GA98667@visor (mailing list archive)
State New
Headers show
Series rasdaemon: don't emit error syslog when exiting normally | expand

Commit Message

Ivan Delalande April 19, 2024, 9:21 p.m. UTC
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 mbox series

Patch

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)