On 03.02.26 22:10, Chaney, Ben wrote:
In for-loop in net_init_af_xdp, we do nc->queue_index = i,
where is is int64_t for 0 to queues-1, and nc->queue_index is
unsigned int.
Also in parse_socket_fds, g_strv_length() returns guint which
is equivalent to unsigned int.
Let's simply use unsigned int type for queues, and update
the check appropriately.
I have some concerns about this patch queues is generally signed,
so negative values can be used for error handling.
Right, and because of it, in "net: introduce net_parse_fds()" I
change this UINT_MAX limit to INT_MAX.
We should
probably be consistent with this.
I wanted make it int, but decided, that I don't want to argue against
If you're using "int" or "long", odds are good that there's a better type.
If a variable is counting something, it should be declared with an
unsigned type.
of docs/devel/style.rst :)
Still, in tap.c, queues variable is int in net_init_tap(), exactly to handle
errors. Still, where possible I use unsigned for it. Don't know what is better.
No problem to change all "queues" to be int, up to Jason.
- queues = opts->has_queues ? opts->queues : 1;
- if (queues < 1) {
+ if (opts->has_queues && (opts->queues < 0 || opts->queues > UINT_MAX)) {
error_setg(errp, "invalid number of queues (%" PRIi64 ") for '%s'",
- queues, opts->ifname);
+ opts->queues, opts->ifname);
return -1;
}
Perhaps the condition here should be opts->queues > MAX_TAP_QUEUES
instead of UINT_MAX
Thanks,
Ben
--
Best regards,
Vladimir