selog: fix coverity warnings 75/43875/2
authorMohammed Hawari <[email protected]>
Fri, 10 Oct 2025 08:03:34 +0000 (10:03 +0200)
committerDamjan Marion <[email protected]>
Mon, 13 Oct 2025 09:56:47 +0000 (09:56 +0000)
Change-Id: I2844a41114c122523619dfe289c14c6bebd97723
Type: fix
Signed-off-by: Mohammed Hawari <[email protected]>
src/plugins/selog/api.c
src/plugins/selog/selog_client/selog_client_example.c

index 32c1206..2ca249c 100644 (file)
@@ -22,6 +22,10 @@ vl_api_selog_get_shm_t_handler (vl_api_selog_get_shm_t *mp)
   u32 file_index;
 
   reg = vl_api_client_index_to_registration (mp->client_index);
+
+  if (!reg)
+    return;
+
   if ((file_index = vl_api_registration_file_index (reg)) == VL_API_INVALID_FI)
     rv = VNET_API_ERROR_UNIMPLEMENTED;
 
index 5ed8d4e..bb46782 100644 (file)
  */
 #include <selog/selog_client/selog_client.h>
 #include <stdio.h>
+#include <signal.h>
 #include <time.h>
 
+volatile sig_atomic_t stop;
+void
+interrupt_handler (int signum)
+{
+  stop = 1;
+}
 int
 main (int argc, char *argv[])
 {
@@ -30,7 +37,8 @@ main (int argc, char *argv[])
              selog_client_error_strings[-rv]);
       return rv;
     }
-  while (1)
+  signal (SIGINT, interrupt_handler);
+  while (!stop)
     {
       selog_event_t event;
       int rv = selog_client_poll_event (ctx, &event, 1);