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>