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) <brauner@kernel.org>
This commit is contained in:
@@ -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++;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)),
|
||||
|
||||
Reference in New Issue
Block a user