qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH-for-10.2 v2] migration: Replace g_malloc0_n by g_new0 (fixes compiler warning)
@ 2025-12-09 21:00 Stefan Weil via
  2025-12-09 21:05 ` Stefan Weil via
  2025-12-10 15:05 ` Richard Henderson
  0 siblings, 2 replies; 3+ messages in thread
From: Stefan Weil via @ 2025-12-09 21:00 UTC (permalink / raw)
  To: Peter Xu, Fabiano Rosas, Laurent Vivier,
	Philippe Mathieu-Daudé, Daniel P . Berrangé
  Cc: qemu-devel, qemu-trivial, Stefan Weil

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>
---

v2: Replace g_malloc0_n by g_new0.

Thanks for all comments and reviews.

Stefan


 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 3f98dcb6fd..8bef0192aa 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.47.3



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH-for-10.2 v2] migration: Replace g_malloc0_n by g_new0 (fixes compiler warning)
  2025-12-09 21:00 [PATCH-for-10.2 v2] migration: Replace g_malloc0_n by g_new0 (fixes compiler warning) Stefan Weil via
@ 2025-12-09 21:05 ` Stefan Weil via
  2025-12-10 15:05 ` Richard Henderson
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Weil via @ 2025-12-09 21:05 UTC (permalink / raw)
  To: Peter Xu, Fabiano Rosas, Laurent Vivier,
	Philippe Mathieu-Daudé, Daniel P . Berrangé
  Cc: qemu-devel, qemu-trivial

Am 09.12.25 um 22:00 schrieb Stefan Weil:

> 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>
> ---
>
> v2: Replace g_malloc0_n by g_new0.
>
> Thanks for all comments and reviews.
>
> Stefan


This patch is no longer needed (already queued from Philippe's e-mail), 
so just ignore it.

Thanks, Stefan W.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH-for-10.2 v2] migration: Replace g_malloc0_n by g_new0 (fixes compiler warning)
  2025-12-09 21:00 [PATCH-for-10.2 v2] migration: Replace g_malloc0_n by g_new0 (fixes compiler warning) Stefan Weil via
  2025-12-09 21:05 ` Stefan Weil via
@ 2025-12-10 15:05 ` Richard Henderson
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Henderson @ 2025-12-10 15:05 UTC (permalink / raw)
  To: Stefan Weil, Peter Xu, Fabiano Rosas, Laurent Vivier,
	Philippe Mathieu-Daudé, Daniel P . Berrangé
  Cc: qemu-devel, qemu-trivial

On 12/9/25 15:00, Stefan Weil via wrote:
> 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: Richard Henderson <richard.henderson@linaro.org>

r~

> ---
> 
> v2: Replace g_malloc0_n by g_new0.
> 
> Thanks for all comments and reviews.
> 
> Stefan
> 
> 
>   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 3f98dcb6fd..8bef0192aa 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];



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-12-10 15:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-09 21:00 [PATCH-for-10.2 v2] migration: Replace g_malloc0_n by g_new0 (fixes compiler warning) Stefan Weil via
2025-12-09 21:05 ` Stefan Weil via
2025-12-10 15:05 ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).