[PATCH v2] migration: Fix order of function arguments

Philippe Mathieu-Daudé posted 1 patch 3 days, 19 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20251209195010.83219-1-philmd@linaro.org
Maintainers: Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>
migration/postcopy-ram.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
[PATCH v2] migration: Fix order of function arguments
Posted by Philippe Mathieu-Daudé 3 days, 19 hours ago
From: Stefan Weil <sw@weilnetz.de>

This fixes a compiler error when higher warning levels are enabled:

../migration/postcopy-ram.c: In function ‘postcopy_temp_pages_setup’:
../migration/postcopy-ram.c:1483:50: error: ‘g_malloc0_n’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
 1483 |     mis->postcopy_tmp_pages = g_malloc0_n(sizeof(PostcopyTmpPage), channels);
      |                                                  ^~~~~~~~~~~~~~~
../migration/postcopy-ram.c:1483:50: note: earlier argument should specify number of elements, later size of each element

Avoid also a related int/unsigned mismatch by fixing the type of
two local variables.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
[PMD: Replace g_malloc0_n() by g_new0()]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
Superseedes: <20251209125049.764095-1-sw@weilnetz.de>
---
 migration/postcopy-ram.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index 7c9fe61041f..715ef021a91 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -1467,7 +1467,8 @@ retry:
 static int postcopy_temp_pages_setup(MigrationIncomingState *mis)
 {
     PostcopyTmpPage *tmp_page;
-    int err, i, channels;
+    int err;
+    unsigned i, channels;
     void *temp_page;
 
     if (migrate_postcopy_preempt()) {
@@ -1479,7 +1480,7 @@ static int postcopy_temp_pages_setup(MigrationIncomingState *mis)
     }
 
     channels = mis->postcopy_channels;
-    mis->postcopy_tmp_pages = g_malloc0_n(sizeof(PostcopyTmpPage), channels);
+    mis->postcopy_tmp_pages = g_new0(PostcopyTmpPage, channels);
 
     for (i = 0; i < channels; i++) {
         tmp_page = &mis->postcopy_tmp_pages[i];
-- 
2.51.0


Re: [PATCH v2] migration: Fix order of function arguments
Posted by Peter Xu 3 days, 19 hours ago
On Tue, Dec 09, 2025 at 08:50:10PM +0100, Philippe Mathieu-Daudé wrote:
> From: Stefan Weil <sw@weilnetz.de>
> 
> This fixes a compiler error when higher warning levels are enabled:
> 
> ../migration/postcopy-ram.c: In function ‘postcopy_temp_pages_setup’:
> ../migration/postcopy-ram.c:1483:50: error: ‘g_malloc0_n’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
>  1483 |     mis->postcopy_tmp_pages = g_malloc0_n(sizeof(PostcopyTmpPage), channels);
>       |                                                  ^~~~~~~~~~~~~~~
> ../migration/postcopy-ram.c:1483:50: note: earlier argument should specify number of elements, later size of each element
> 
> Avoid also a related int/unsigned mismatch by fixing the type of
> two local variables.
> 
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> Reviewed-by: Laurent Vivier <laurent@vivier.eu>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> [PMD: Replace g_malloc0_n() by g_new0()]
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Acked-by: Peter Xu <peterx@redhat.com>

-- 
Peter Xu


Re: [PATCH v2] migration: Fix order of function arguments
Posted by Philippe Mathieu-Daudé 3 days, 19 hours ago
On 9/12/25 20:53, Peter Xu wrote:
> On Tue, Dec 09, 2025 at 08:50:10PM +0100, Philippe Mathieu-Daudé wrote:
>> From: Stefan Weil <sw@weilnetz.de>
>>
>> This fixes a compiler error when higher warning levels are enabled:
>>
>> ../migration/postcopy-ram.c: In function ‘postcopy_temp_pages_setup’:
>> ../migration/postcopy-ram.c:1483:50: error: ‘g_malloc0_n’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
>>   1483 |     mis->postcopy_tmp_pages = g_malloc0_n(sizeof(PostcopyTmpPage), channels);
>>        |                                                  ^~~~~~~~~~~~~~~
>> ../migration/postcopy-ram.c:1483:50: note: earlier argument should specify number of elements, later size of each element
>>
>> Avoid also a related int/unsigned mismatch by fixing the type of
>> two local variables.
>>
>> Signed-off-by: Stefan Weil <sw@weilnetz.de>
>> Reviewed-by: Laurent Vivier <laurent@vivier.eu>
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> [PMD: Replace g_malloc0_n() by g_new0()]
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> 
> Acked-by: Peter Xu <peterx@redhat.com>

Queued, thanks :)