From a4e8b7e18f249fe5decdd2fe748a5068ffeaee57 Mon Sep 17 00:00:00 2001                            
From: Steve Grubb <ausearch.1@gmail.com>
Date: Mon, 20 Nov 2023 16:37:46 -0500
Subject: [PATCH] Fix new warnings for unused results

Reference:https://github.com/linux-audit/audit-userspace/commit/a4e8b7e18f249fe5decdd2fe748a5068ffeaee57
Conflict:audisp/plugins/ids/ids.c

---
 audisp/plugins/ids/ids.c              | 5 +++--
 audisp/plugins/ids/ids.h              | 2 +-
 audisp/plugins/statsd/audisp-statsd.c | 4 ++--
 lib/libaudit.c                        | 3 ++-
 lib/netlink.c                         | 3 ++-
 src/auditd.c                          | 3 ++-
 6 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/audisp/plugins/ids/ids.c b/audisp/plugins/ids/ids.c
index f9f312d..8fe3699 100644
--- a/audisp/plugins/ids/ids.c
+++ b/audisp/plugins/ids/ids.c
@@ -91,9 +91,10 @@ static void destroy_audit(void)
 	audit_close(audit_fd);
 }
 
-void log_audit_event(int type, const char *text, int res)
+int log_audit_event(int type, const char *text, int res)
 {
-	audit_log_user_message(audit_fd, type, text, NULL, NULL, NULL, res);
+	return audit_log_user_message(audit_fd, type, text,
+				      NULL, NULL, NULL, res);
 }
 
 
diff --git a/audisp/plugins/ids/ids.h b/audisp/plugins/ids/ids.h
index eb1d83c..2cf13b6 100644
--- a/audisp/plugins/ids/ids.h
+++ b/audisp/plugins/ids/ids.h
@@ -14,6 +14,6 @@
 extern int debug;
 extern void my_printf(const char *fmt, ...)
 	 __attribute__ (( format(printf, 1, 2) ));
-extern void log_audit_event(int type, const char *text, int res);
+extern int log_audit_event(int type, const char *text, int res);
 
 #endif
diff --git a/audisp/plugins/statsd/audisp-statsd.c b/audisp/plugins/statsd/audisp-statsd.c
index e562afa..934db5c 100644
--- a/audisp/plugins/statsd/audisp-statsd.c
+++ b/audisp/plugins/statsd/audisp-statsd.c
@@ -216,9 +216,9 @@ static void get_kernel_status(void)
 	struct audit_reply rep;
 
 	audit_request_status(audit_fd);
-	audit_get_reply(audit_fd, &rep, GET_REPLY_BLOCKING, 0);
+	int rc = audit_get_reply(audit_fd, &rep, GET_REPLY_BLOCKING, 0);
 
-	if (rep.type == AUDIT_GET) {
+	if (rc > 0 && rep.type == AUDIT_GET) {
 		// add info to global audit event struct
 		r.lost = rep.status->lost;
 		r.backlog = rep.status->backlog;
diff --git a/lib/libaudit.c b/lib/libaudit.c
index eda51e8..86c333c 100644
--- a/lib/libaudit.c
+++ b/lib/libaudit.c
@@ -467,7 +467,8 @@ int audit_set_pid(int fd, uint32_t pid, rep_wait_t wmode)
 		rc = poll(pfd, 1, 100);	/* .1 second */
 	} while (rc < 0 && errno == EINTR);
 
-	(void)audit_get_reply(fd, &rep, GET_REPLY_NONBLOCKING, 0);
+	if (audit_get_reply(fd, &rep, GET_REPLY_NONBLOCKING, 0))
+		; // intentionally empty
 	return 1;
 }
 
diff --git a/lib/netlink.c b/lib/netlink.c
index 4d0670a..9b438b8 100644
--- a/lib/netlink.c
+++ b/lib/netlink.c
@@ -300,7 +300,8 @@ retry:
 	else if (rc > 0 && rep.type == NLMSG_ERROR) {
 		int error = rep.error->error;
 		/* Eat the message */
-		(void)audit_get_reply(fd, &rep, GET_REPLY_NONBLOCKING, 0);
+		if (audit_get_reply(fd, &rep, GET_REPLY_NONBLOCKING, 0))
+			; // intentionally empty
 
 		/* NLMSG_ERROR can indicate success, only report nonzero */ 
 		if (error) {
diff --git a/src/auditd.c b/src/auditd.c
index 8ab2fe1..5cb4394 100644
--- a/src/auditd.c
+++ b/src/auditd.c
@@ -1152,7 +1152,8 @@ static void clean_exit(void)
 	audit_msg(LOG_INFO, "The audit daemon is exiting.");
 	if (fd >= 0) {
 		if (!opt_aggregate_only)
-			audit_set_pid(fd, 0, WAIT_NO);
+			if (audit_set_pid(fd, 0, WAIT_NO))
+				; // intentionally empty
 		audit_close(fd);
 	}
 	if (pidfile)
-- 
2.33.0

