Skip to content

Commit

Permalink
migration: Add Error** argument to ram_state_init()
Browse files Browse the repository at this point in the history
Since the return value not exploited, follow the recommendations of
qapi/error.h and change it to a bool

Signed-off-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20240320064911.545001-13-clg@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
  • Loading branch information
legoater authored and xzpeter committed Apr 23, 2024
1 parent 639ec3f commit 16ecd25
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions migration/ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -2780,13 +2780,13 @@ static int xbzrle_init(void)
return -ENOMEM;
}

static int ram_state_init(RAMState **rsp)
static bool ram_state_init(RAMState **rsp, Error **errp)
{
*rsp = g_try_new0(RAMState, 1);

if (!*rsp) {
error_report("%s: Init ramstate fail", __func__);
return -1;
error_setg(errp, "%s: Init ramstate fail", __func__);
return false;
}

qemu_mutex_init(&(*rsp)->bitmap_mutex);
Expand All @@ -2802,7 +2802,7 @@ static int ram_state_init(RAMState **rsp)
(*rsp)->migration_dirty_pages = (*rsp)->ram_bytes_total >> TARGET_PAGE_BITS;
ram_state_reset(*rsp);

return 0;
return true;
}

static void ram_list_init_bitmaps(void)
Expand Down Expand Up @@ -2897,7 +2897,10 @@ static void ram_init_bitmaps(RAMState *rs)

static int ram_init_all(RAMState **rsp)
{
if (ram_state_init(rsp)) {
Error *local_err = NULL;

if (!ram_state_init(rsp, &local_err)) {
error_report_err(local_err);
return -1;
}

Expand Down Expand Up @@ -3624,7 +3627,11 @@ void ram_handle_zero(void *host, uint64_t size)

static void colo_init_ram_state(void)
{
ram_state_init(&ram_state);
Error *local_err = NULL;

if (!ram_state_init(&ram_state, &local_err)) {
error_report_err(local_err);
}
}

/*
Expand Down

0 comments on commit 16ecd25

Please sign in to comment.