]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-netlink: always initialize return variable on success
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 24 Nov 2022 17:34:57 +0000 (02:34 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 26 Nov 2022 02:28:27 +0000 (11:28 +0900)
src/libsystemd/sd-netlink/netlink-socket.c

index 1da459c01489d933cb538e584ad137727e2c8b68..b5ed533db69ce82979d6972bfb21bfe4cd148e44 100644 (file)
@@ -200,8 +200,11 @@ static int socket_recv_message(int fd, struct iovec *iov, uint32_t *ret_mcast_gr
         if (n < 0) {
                 if (n == -ENOBUFS)
                         return log_debug_errno(n, "sd-netlink: kernel receive buffer overrun");
-                if (ERRNO_IS_TRANSIENT(n))
+                if (ERRNO_IS_TRANSIENT(n)) {
+                        if (ret_mcast_group)
+                                *ret_mcast_group = 0;
                         return 0;
+                }
                 return (int) n;
         }
 
@@ -216,6 +219,8 @@ static int socket_recv_message(int fd, struct iovec *iov, uint32_t *ret_mcast_gr
                                 return (int) n;
                 }
 
+                if (ret_mcast_group)
+                        *ret_mcast_group = 0;
                 return 0;
         }
 
@@ -242,7 +247,7 @@ int socket_read_message(sd_netlink *nl) {
         bool multi_part = false, done = false;
         size_t len, allocated;
         struct iovec iov = {};
-        uint32_t group = 0;
+        uint32_t group;
         unsigned i = 0;
         int r;