configure: enable -Wsuggest-attribute=format
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 20 Aug 2021 19:19:42 +0000 (15:19 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 9 Dec 2021 19:49:05 +0000 (14:49 -0500)
commitd22ad5f818289bb10faa814c2ecef071ec0c2c67
tree5b1f1017e9932197c5faf47790714ae1f9e69c14
parent9f4a25d35d037cbb5d8aeb50f9e8fa10748a4d14
configure: enable -Wsuggest-attribute=format

Enable this warning, which suggests adding format attributes to some
functions, to help with format string validation.  Fix the warnings it
generates by using the new ATTR_FORMAT_PRINTF macro.

There is only one spot we can't fix, that is in modprobe.c.  The
compiler suggests we add an attribute to the kmod_set_log_fn
declaration, which we can't do, since it's not our code:

    /home/simark/src/lttng-tools/src/bin/lttng-sessiond/modprobe.c: In function ‘setup_kmod_ctx’:
    /home/simark/src/lttng-tools/src/bin/lttng-sessiond/modprobe.c:286:31: error: argument 2 of ‘kmod_set_log_fn’ might be a candidate for a format attribute [-Werror=suggest-attribute=format]
      286 |         kmod_set_log_fn(*ctx, log_kmod, NULL);
          |                               ^~~~~~~~

I don't see any other choice but to explicitly ignore that spot.

Introduce some macros to abstract how to ignore specific diagnostics.
This is useful since not all compilers support the same diagnostic
flags.  For example, telling clang to ignore -Wsuggest-attribute=format
would give an error.

Change-Id: I71278d7e2cdc66d4bbc59bd966469d0b427e963d
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
configure.ac
src/bin/lttng-sessiond/modprobe.cpp
src/bin/lttng-sessiond/ust-metadata.cpp
src/common/config/session-config.cpp
src/common/macros.h
tests/utils/testapp/gen-ns-events/gen-ns-events.cpp
tests/utils/testapp/gen-ust-events-ns/gen-ust-events-ns.cpp
tests/utils/xml-utils/validate_xml.cpp
This page took 0.030928 seconds and 4 git commands to generate.