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>
(cherry picked from commit
2e4a3da35892bf53e49936532a3a04e4c6819cb3)
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9889
CI-Build: Simon Marchi <simon.marchi@efficios.com>
*name = NULL;
g_string_free(gs_name, TRUE);
} else {
- *name = gs_name->str;
- g_string_free(gs_name, FALSE);
+ *name = g_string_free(gs_name, FALSE);
}
} else {
g_string_free(gs_name, TRUE);
}
- *plugin = gs_plugin->str;
- *comp_cls = gs_comp_cls->str;
- g_string_free(gs_plugin, FALSE);
- g_string_free(gs_comp_cls, FALSE);
+ *plugin = g_string_free(gs_plugin, FALSE);
+ *comp_cls = g_string_free(gs_comp_cls, FALSE);
gs_name = NULL;
gs_plugin = NULL;
gs_comp_cls = NULL;
BT_ASSERT(begin);
BT_ASSERT(end);
- *begin = g_begin->str;
- *end = g_end->str;
- g_string_free(g_begin, FALSE);
- g_string_free(g_end, FALSE);
+ *begin = g_string_free(g_begin, FALSE);
+ *end = g_string_free(g_end, FALSE);
g_begin = NULL;
g_end = NULL;
goto end;