cli: use return value of g_string_free
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 3 Apr 2023 01:09:56 +0000 (21:09 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 3 Apr 2023 16:47:10 +0000 (12:47 -0400)
commit2e4a3da35892bf53e49936532a3a04e4c6819cb3
tree7aadb89916b8d93e6d747be61845f300b65f2db7
parent3df7eb98213adf68b7ef59a91ac41c541f6ed67a
cli: use return value of g_string_free

When building against glib 2.76, I see:

      CC       babeltrace2-cfg-cli-args.o
    In file included from /usr/include/glib-2.0/glib/giochannel.h:36,
                     from /usr/include/glib-2.0/glib.h:56,
                     from /home/simark/src/babeltrace/src/common/assert.h:12,
                     from /home/simark/src/babeltrace/src/logging/log.h:27,
                     from /home/simark/src/babeltrace/src/cli/logging.h:11,
                     from /home/simark/src/babeltrace/src/cli/babeltrace2-cfg-cli-args.c:10:
    /home/simark/src/babeltrace/src/cli/babeltrace2-cfg-cli-args.c: In function ‘plugin_comp_cls_names’:
    /usr/include/glib-2.0/glib/gstring.h:72:5: error: ignoring return value of ‘g_string_free_and_steal’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
       68 |   (__builtin_constant_p (free_segment) ?        \
          |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       69 |     ((free_segment) ?                           \
          |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       70 |       (g_string_free) ((str), (free_segment)) : \
          |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       71 |       g_string_free_and_steal (str))            \
          |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       72 |     :                                           \
          |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       73 |     (g_string_free) ((str), (free_segment)))
          |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/simark/src/babeltrace/src/cli/babeltrace2-cfg-cli-args.c:136:25: note: in expansion of macro ‘g_string_free’
      136 |                         g_string_free(gs_name, FALSE);
          |                         ^~~~~~~~~~~~~

glib made g_string_free warn about unused results in this commit:

  https://gitlab.gnome.org/GNOME/glib/-/commit/c3d07a625a407b56432f4b8c60295fd32ee1ee2b

Fix that by changing our code to get the released value from the return
value of g_string_free, rather than doing it in two steps..  No
functional changes intended.

Change-Id: I62f4002d0487165b7c9d33f471937185f3bc0f82
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9728
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/cli/babeltrace2-cfg-cli-args.c
This page took 0.025554 seconds and 4 git commands to generate.