Skip to content

misc: Correct -Wformat compiler warnings on 32bit architectures

Milan Crha requested to merge wip/wformat-warnings into main

This addresses these warning from 32bit architectures:

../src/gs-css.c:169:28: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘gsize’ {aka ‘unsigned int’} [-Wformat=]
  169 |                 g_warning ("ignoring parse error %lu:%lu: %s",
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  170 |                            start_location->lines + 1,
      |                            ~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                  |
      |                                                  gsize {aka unsigned int}

../src/gs-common.c: In function ‘gs_utils_widget_css_parsing_error_cb’:
../src/gs-common.c:336:20: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘gsize’ {aka ‘unsigned int’} [-Wformat=]
  336 |         g_warning ("CSS parse error %lu:%lu: %s",
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  337 |                    start_location->lines + 1,
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                          |
      |                                          gsize {aka unsigned int}

There are more warnings int he build logs, all about [-Winline, see for example: https://koji.fedoraproject.org/koji/taskinfo?taskID=88949988

one of them:

/usr/include/glib-2.0/glib/glib-autocleanups.h: In function ‘insert_details_widget’:
/usr/include/glib-2.0/glib/gmacros.h:1196:43: warning: inlining failed in call to ‘glib_autoptr_cleanup_GString.isra.0’: call is unlikely and code size would grow [-Winline]
 1196 | #define _GLIB_AUTOPTR_FUNC_NAME(TypeName) glib_autoptr_cleanup_##TypeName
      |                                           ^~~~~~~~~~~~~~~~~~~~~
../src/gs-common.c:480:28: note: called from here
  480 |         g_autoptr(GString) msg = NULL;
      |                            ^~~

I do not know how to address these, maybe turn off the -Winline?

Merge request reports