@samitouri / QOSamiQemu / commits / 731abcf418

system/physmem.c: remove useless assertion of block

It is useless to assert that block is not NULL because it is already dereferenced in the first line of the function. The assertion is also unnecessary because the function is called in only two places, and `block` can't be NULL in either of them: - In `migration/ram.c`, we have already dereferenced `block` in the code just before the call. - In `system/memory.c`, we assert `mr->ram_block` before passing it to the function. (We could split the declaration and initialization of oldsize, but then we would need to remove the const qualifier. As the assertion is useless anyway, removing the const qualifier seems worse.) Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Peter Xu <peterx@redhat.com> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

Sergei Heifetz committed Feb 8, 2026 at 15:39 UTC 731abcf418cba5a005fea6f06380c67cdb3b5b99
1 file changed -2
system/physmem.c
-2
@@ -2028,8 +2028,6 @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp)
2028 const ram_addr_t oldsize = block->used_length;
2029 const ram_addr_t unaligned_size = newsize;
2030
2031 - assert(block);
2032 -
2031 newsize = TARGET_PAGE_ALIGN(newsize);
2032 newsize = REAL_HOST_PAGE_ALIGN(newsize);
2033