diff mbox series

[ovs-dev,v3,4/8] netlink-socket: Initialize socket family.

Message ID 20240909045505.236657-5-mkp@redhat.com
State Accepted, archived
Commit cfc8321da150a1a41368a648221a7d2a2e6262c2
Delegated to: Eelco Chaudron
Headers show
Series Address clang analyze warnings. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed

Commit Message

Mike Pattrick Sept. 9, 2024, 4:55 a.m. UTC
The Clang analyzer will alert on the use of uninitialized variable local
despite the fact that this should be set by a syscall.

To suppress the warning, this variable is now initialized.

Signed-off-by: Mike Pattrick <mkp@redhat.com>
---
 lib/netlink-socket.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Eelco Chaudron Sept. 10, 2024, 9:56 a.m. UTC | #1
On 9 Sep 2024, at 6:55, Mike Pattrick wrote:

> The Clang analyzer will alert on the use of uninitialized variable local
> despite the fact that this should be set by a syscall.
>
> To suppress the warning, this variable is now initialized.
>
> Signed-off-by: Mike Pattrick <mkp@redhat.com>

Thanks for sending out the v3, the changes look good to me.

Cheers,

Eelco

Acked-by: Eelco Chaudron <echaudro@redhat.com>
Simon Horman Sept. 11, 2024, 9:25 a.m. UTC | #2
On Mon, Sep 09, 2024 at 12:55:01AM -0400, Mike Pattrick wrote:
> The Clang analyzer will alert on the use of uninitialized variable local
> despite the fact that this should be set by a syscall.
> 
> To suppress the warning, this variable is now initialized.
> 
> Signed-off-by: Mike Pattrick <mkp@redhat.com>

Acked-by: Simon Horman <horms@ovn.org>
diff mbox series

Patch

diff --git a/lib/netlink-socket.c b/lib/netlink-socket.c
index 5cb1fc89a..976ed15e8 100644
--- a/lib/netlink-socket.c
+++ b/lib/netlink-socket.c
@@ -232,6 +232,7 @@  nl_sock_create(int protocol, struct nl_sock **sockp)
     }
 
     /* Obtain pid assigned by kernel. */
+    memset(&local, 0, sizeof local);
     local_size = sizeof local;
     if (getsockname(sock->fd, (struct sockaddr *) &local, &local_size) < 0) {
         VLOG_ERR("getsockname: %s", ovs_strerror(errno));