Skip to content

Commit

Permalink
migration: fix uninitialized variable warning in migrate_send_rp_req_…
Browse files Browse the repository at this point in the history
…pages()

After the WITH_QEMU_LOCK_GUARD macro is added, the compiler cannot identify
 that the statements in the macro must be executed. As a result, some variables
 assignment statements in the macro may be considered as unexecuted by the compiler.

When the -Wmaybe-uninitialized capability is enabled on GCC9,the compiler showed warning:
migration/migration.c: In function ‘migrate_send_rp_req_pages’:
migration/migration.c:384:8: warning: ‘received’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 384 |     if (received) {
     |        ^

Add a default value for 'received' to prevented the warning.

Reported-by: Euler Robot <[email protected]>
Signed-off-by: Chen Qun <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Dr. David Alan Gilbert <[email protected]>
  • Loading branch information
Kuhn-Chen authored and dagrh committed Nov 12, 2020
1 parent a1af605 commit a242928
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion migration/migration.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ int migrate_send_rp_req_pages(MigrationIncomingState *mis,
RAMBlock *rb, ram_addr_t start, uint64_t haddr)
{
void *aligned = (void *)(uintptr_t)(haddr & (-qemu_ram_pagesize(rb)));
bool received;
bool received = false;

WITH_QEMU_LOCK_GUARD(&mis->page_request_mutex) {
received = ramblock_recv_bitmap_test_byte_offset(rb, start);
Expand Down

0 comments on commit a242928

Please sign in to comment.