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.
Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
---
net/af-xdp.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/net/af-xdp.c b/net/af-xdp.c
index 14f302ea21..bb7a7d8e33 100644
--- a/net/af-xdp.c
+++ b/net/af-xdp.c
@@ -442,14 +442,14 @@ static NetClientInfo net_af_xdp_info = {
};
static int *parse_socket_fds(const char *sock_fds_str,
- int64_t n_expected, Error **errp)
+ unsigned n_expected, Error **errp)
{
gchar **substrings = g_strsplit(sock_fds_str, ":", -1);
- int64_t i, n_sock_fds = g_strv_length(substrings);
+ unsigned i, n_sock_fds = g_strv_length(substrings);
int *sock_fds = NULL;
if (n_sock_fds != n_expected) {
- error_setg(errp, "expected %"PRIi64" socket fds, got %"PRIi64,
+ error_setg(errp, "expected %u socket fds, got %u",
n_expected, n_sock_fds);
goto exit;
}
@@ -484,7 +484,7 @@ int net_init_af_xdp(const Netdev *netdev,
unsigned int ifindex;
uint32_t prog_id = 0;
g_autofree int *sock_fds = NULL;
- int64_t i, queues;
+ unsigned i, queues;
Error *err = NULL;
AFXDPState *s;
bool inhibit;
@@ -496,13 +496,14 @@ int net_init_af_xdp(const Netdev *netdev,
return -1;
}
- queues = opts->has_queues ? opts->queues : 1;
- if (queues < 1) {
+ if (opts->has_queues && (opts->queues < 0 || opts->queues > UINT_MAX)) {