From 4caa73563aca1c46d8da55b800a369d15e3e638c Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Wed, 22 Apr 2026 00:17:21 +0200 Subject: [PATCH] qmp-client: widen next_fdset_id to uint64_t The fdset id is a monotonic counter; an unsigned int is more than wide enough today, but uint64_t matches the type of other QMP-internal counters (e.g. job ids) and avoids any worry about wraparound on long-running hosts. Update the storage in struct QmpClient, the qmp_client_next_fdset_id() return type, and the corresponding caller in qmp_fdset_add(), switching the sprintf format from %u to PRIu64. No behavioural change. Signed-off-by: Christian Brauner (Amutable) --- src/shared/qmp-client.c | 4 ++-- src/shared/qmp-client.h | 2 +- src/vmspawn/vmspawn-qmp.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/shared/qmp-client.c b/src/shared/qmp-client.c index ad8f8bb24a..41b0c6dd57 100644 --- a/src/shared/qmp-client.c +++ b/src/shared/qmp-client.c @@ -45,7 +45,7 @@ struct QmpClient { qmp_disconnect_callback_t disconnect_callback; void *disconnect_userdata; - unsigned next_fdset_id; /* monotonic fdset-id allocator for add-fd */ + uint64_t next_fdset_id; /* monotonic fdset-id allocator for add-fd */ QmpClientState state; sd_json_variant *current; /* most recently parsed message, pending dispatch */ @@ -893,7 +893,7 @@ sd_event* qmp_client_get_event(QmpClient *c) { return json_stream_get_event(&c->stream); } -unsigned qmp_client_next_fdset_id(QmpClient *c) { +uint64_t qmp_client_next_fdset_id(QmpClient *c) { assert(c); return c->next_fdset_id++; } diff --git a/src/shared/qmp-client.h b/src/shared/qmp-client.h index 8f78473128..7dcd53355d 100644 --- a/src/shared/qmp-client.h +++ b/src/shared/qmp-client.h @@ -82,7 +82,7 @@ void qmp_client_bind_event(QmpClient *c, qmp_event_callback_t callback, void *us void qmp_client_bind_disconnect(QmpClient *c, qmp_disconnect_callback_t callback, void *userdata); int qmp_client_set_description(QmpClient *c, const char *description); sd_event* qmp_client_get_event(QmpClient *c); -unsigned qmp_client_next_fdset_id(QmpClient *client); +uint64_t qmp_client_next_fdset_id(QmpClient *client); DECLARE_TRIVIAL_REF_UNREF_FUNC(QmpClient, qmp_client); DEFINE_TRIVIAL_CLEANUP_FUNC(QmpClient *, qmp_client_unref); diff --git a/src/vmspawn/vmspawn-qmp.c b/src/vmspawn/vmspawn-qmp.c index d467d68a89..6c1277f082 100644 --- a/src/vmspawn/vmspawn-qmp.c +++ b/src/vmspawn/vmspawn-qmp.c @@ -128,7 +128,7 @@ static int qmp_fdset_add(QmpClient *qmp, int fd_consume, char **ret_path) { _cleanup_(sd_json_variant_unrefp) sd_json_variant *args = NULL; _cleanup_close_ int fd = fd_consume; _cleanup_free_ char *path = NULL; - unsigned id; + uint64_t id; int r; assert(qmp); @@ -141,7 +141,7 @@ static int qmp_fdset_add(QmpClient *qmp, int fd_consume, char **ret_path) { if (r < 0) return r; - if (asprintf(&path, "/dev/fdset/%u", id) < 0) + if (asprintf(&path, "/dev/fdset/%" PRIu64, id) < 0) return -ENOMEM; r = qmp_client_invoke(qmp, /* ret_slot= */ NULL, "add-fd", QMP_CLIENT_ARGS_FD(args, TAKE_FD(fd)),