> +static int tap_parse_fds_and_queues(const NetdevTapOptions *tap, int **fds,
> +                                    Error **errp)
> +{
> +    unsigned queues;
> +
> +    if (tap->has_queues + !!tap->helper + !!tap->fds + !!tap->fd > 1) {
> +        error_setg(errp, "queues=, helper=, fds= and fd= are mutual 
> exclusive");
> +        return -1;
> +    }
> +
> +    if (tap->has_queues) {
> +        if (tap->queues > INT_MAX) {
> +            error_setg(errp, "queues exceeds maximum %d", INT_MAX);
> +            return -1;
> +        }
> +        queues = tap->queues;
> +        *fds = NULL;
> +    } else if (tap->fd || tap->fds) {
> +        queues = net_parse_fds(tap->fd ?: tap->fds, fds,
> +                               tap->fd ? 1 : 0, errp);
> +        if (!*fds) {
> +            return -1;
> +        }
> +    } else if (tap->helper) {
> +        int fd = net_bridge_run_helper(tap->helper,
> +                                       tap->br ?: DEFAULT_BRIDGE_INTERFACE,
> +                                       errp);
> +        if (fd < 0) {
> +            return -1;
> +        }
> +
> +        queues = 1;
> +        *fds = g_new(int, 1);
> +        **fds = fd;
> +    }
> +
> +    if (*fds && !unblock_fds(*fds, queues, errp)) {
> +        net_free_fds(*fds, queues);
> +        return -1;
> +    }
> +
> +    return queues;
> +}

This causes a build error in my environment:

../net/tap.c: In function 'net_init_tap':
../net/tap.c:901:12: error: 'queues' may be used uninitialized in this function 
[-Werror=maybe-uninitialized]
  901 |     return queues;
      |            ^~~~~~
../net/tap.c:863:14: note: 'queues' was declared here
  863 |     unsigned queues;
      |              ^~~~~~

Looking at the code is seems like it would be possible for queues to be unset
If !has_queues && !tap->fd && !tap->fds && !tap->helper

Can we default to queues = 1, or if that isn't appropriate add an else block 
that prints an error and returns -1?

Thanks,
        Ben

Reply via email to