Skip to content
  • Philippe Mathieu-Daudé's avatar
    90dc46d3
    block/qcow2-bitmap: Add missing cast to silent GCC error · 90dc46d3
    Philippe Mathieu-Daudé authored
    
    
    Commit d1258dd0 ("qcow2: autoloading dirty bitmaps") added the
    set_readonly_helper() GFunc handler, correctly casting the gpointer
    user_data in both the g_slist_foreach() caller and the handler.
    Few commits later (commit 1b6b0562), the handler is reused in
    qcow2_reopen_bitmaps_rw() but missing the gpointer cast, resulting
    in the following error when using Homebrew GCC 12.2.0:
    
      [2/658] Compiling C object libblock.fa.p/block_qcow2-bitmap.c.o
      ../../block/qcow2-bitmap.c: In function 'qcow2_reopen_bitmaps_rw':
      ../../block/qcow2-bitmap.c:1211:60: error: incompatible type for argument 3 of 'g_slist_foreach'
       1211 |     g_slist_foreach(ro_dirty_bitmaps, set_readonly_helper, false);
            |                                                            ^~~~~
            |                                                            |
            |                                                            _Bool
      In file included from /opt/homebrew/Cellar/glib/2.72.3_1/include/glib-2.0/glib/gmain.h:26,
                       from /opt/homebrew/Cellar/glib/2.72.3_1/include/glib-2.0/glib/giochannel.h:33,
                       from /opt/homebrew/Cellar/glib/2.72.3_1/include/glib-2.0/glib.h:54,
                       from /Users/philmd/source/qemu/include/glib-compat.h:32,
                       from /Users/philmd/source/qemu/include/qemu/osdep.h:144,
                       from ../../block/qcow2-bitmap.c:28:
      /opt/homebrew/Cellar/glib/2.72.3_1/include/glib-2.0/glib/gslist.h:127:61: note: expected 'gpointer' {aka 'void *'} but argument is of type '_Bool'
        127 |                                           gpointer          user_data);
            |                                           ~~~~~~~~~~~~~~~~~~^~~~~~~~~
      At top level:
      FAILED: libblock.fa.p/block_qcow2-bitmap.c.o
    
    Fix by adding the missing gpointer cast.
    
    Fixes: 1b6b0562 ("qcow2: support .bdrv_reopen_bitmaps_rw")
    Signed-off-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
    Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
    Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
    Message-Id: <20220919182755.51967-1-f4bug@amsat.org>
    Signed-off-by: default avatarLaurent Vivier <laurent@vivier.eu>
    90dc46d3
    block/qcow2-bitmap: Add missing cast to silent GCC error
    Philippe Mathieu-Daudé authored
    
    
    Commit d1258dd0 ("qcow2: autoloading dirty bitmaps") added the
    set_readonly_helper() GFunc handler, correctly casting the gpointer
    user_data in both the g_slist_foreach() caller and the handler.
    Few commits later (commit 1b6b0562), the handler is reused in
    qcow2_reopen_bitmaps_rw() but missing the gpointer cast, resulting
    in the following error when using Homebrew GCC 12.2.0:
    
      [2/658] Compiling C object libblock.fa.p/block_qcow2-bitmap.c.o
      ../../block/qcow2-bitmap.c: In function 'qcow2_reopen_bitmaps_rw':
      ../../block/qcow2-bitmap.c:1211:60: error: incompatible type for argument 3 of 'g_slist_foreach'
       1211 |     g_slist_foreach(ro_dirty_bitmaps, set_readonly_helper, false);
            |                                                            ^~~~~
            |                                                            |
            |                                                            _Bool
      In file included from /opt/homebrew/Cellar/glib/2.72.3_1/include/glib-2.0/glib/gmain.h:26,
                       from /opt/homebrew/Cellar/glib/2.72.3_1/include/glib-2.0/glib/giochannel.h:33,
                       from /opt/homebrew/Cellar/glib/2.72.3_1/include/glib-2.0/glib.h:54,
                       from /Users/philmd/source/qemu/include/glib-compat.h:32,
                       from /Users/philmd/source/qemu/include/qemu/osdep.h:144,
                       from ../../block/qcow2-bitmap.c:28:
      /opt/homebrew/Cellar/glib/2.72.3_1/include/glib-2.0/glib/gslist.h:127:61: note: expected 'gpointer' {aka 'void *'} but argument is of type '_Bool'
        127 |                                           gpointer          user_data);
            |                                           ~~~~~~~~~~~~~~~~~~^~~~~~~~~
      At top level:
      FAILED: libblock.fa.p/block_qcow2-bitmap.c.o
    
    Fix by adding the missing gpointer cast.
    
    Fixes: 1b6b0562 ("qcow2: support .bdrv_reopen_bitmaps_rw")
    Signed-off-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
    Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
    Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
    Message-Id: <20220919182755.51967-1-f4bug@amsat.org>
    Signed-off-by: default avatarLaurent Vivier <laurent@vivier.eu>
Loading