]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/socket-netlink: set output in socket_address_parse_netlink() only on success
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 5 Sep 2020 19:25:11 +0000 (21:25 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 9 Sep 2020 22:46:44 +0000 (00:46 +0200)
src/shared/socket-netlink.c

index 0ecbf7dee01659a7ba6955491a1cfbe1ec1da33c..76b68dfa1cde71025cf9ca471345699b3ffb3042 100644 (file)
@@ -220,10 +220,6 @@ int socket_address_parse_netlink(SocketAddress *a, const char *s) {
         assert(a);
         assert(s);
 
-        *a = (SocketAddress) {
-                .type = SOCK_RAW,
-        };
-
         r = extract_first_word(&s, &word, NULL, 0);
         if (r < 0)
                 return r;
@@ -240,12 +236,13 @@ int socket_address_parse_netlink(SocketAddress *a, const char *s) {
                         return r;
         }
 
-        a->sockaddr.nl.nl_family = AF_NETLINK;
-        a->sockaddr.nl.nl_groups = group;
-
-        a->type = SOCK_RAW;
-        a->size = sizeof(struct sockaddr_nl);
-        a->protocol = family;
+        *a = (SocketAddress) {
+                .type = SOCK_RAW,
+                .sockaddr.nl.nl_family = AF_NETLINK,
+                .sockaddr.nl.nl_groups = group,
+                .protocol = family,
+                .size = sizeof(struct sockaddr_nl),
+        };
 
         return 0;
 }