[ovs-dev] [warnings 6/8] netdev-linux: Only call set_nonblocking() if socket creation succeeds.

Ethan Jackson ethan at nicira.com
Fri May 13 01:48:56 UTC 2011


Looks Good.

Out of curiosity, how did you notice this?  Some sort of static
analyzer, or just poking around the code?

Ethan

On Mon, May 2, 2011 at 12:58, Ben Pfaff <blp at nicira.com> wrote:
> ---
>  lib/netdev-linux.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
> index 384fdaf..1c5ddc5 100644
> --- a/lib/netdev-linux.c
> +++ b/lib/netdev-linux.c
> @@ -451,11 +451,12 @@ netdev_linux_init(void)
>             /* Create AF_PACKET socket. */
>             af_packet_sock = socket(AF_PACKET, SOCK_RAW, 0);
>             status = af_packet_sock >= 0 ? 0 : errno;
> -            if (status) {
> +            if (!status) {
> +                set_nonblocking(af_packet_sock);
> +            } else {
>                 VLOG_ERR("failed to create packet socket: %s",
>                          strerror(status));
>             }
> -            set_nonblocking(af_packet_sock);
>         }
>
>         /* Create rtnetlink socket. */
> --
> 1.7.4.4
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>



More information about the dev mailing list