On 8/20/24 15: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 <[email protected]>
> ---
>  lib/netlink-socket.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/netlink-socket.c b/lib/netlink-socket.c
> index 5cb1fc89a..737e49cfc 100644
> --- a/lib/netlink-socket.c
> +++ b/lib/netlink-socket.c
> @@ -233,6 +233,7 @@ nl_sock_create(int protocol, struct nl_sock **sockp)
>  
>      /* Obtain pid assigned by kernel. */
>      local_size = sizeof local;
> +    local.nl_family = AF_UNSPEC;

It feels strange to do that.  Just memset-ing the whole structure to 0 might
be a better choice.

>      if (getsockname(sock->fd, (struct sockaddr *) &local, &local_size) < 0) {
>          VLOG_ERR("getsockname: %s", ovs_strerror(errno));
>          goto error;

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to