diff mbox series

[4/5] libselinux/man: add format attribute for set_matchpathcon_printf(3)

Message ID 20240429163122.63181-4-cgoettsche@seltendoof.de (mailing list archive)
State Accepted
Commit d370cbfc8528
Delegated to: Petr Lautrbach
Headers show
Series [1/5] libselinux/man: correct file extension of man pages | expand

Commit Message

Christian Göttsche April 29, 2024, 4:31 p.m. UTC
From: Christian Göttsche <cgzones@googlemail.com>

The parameter for set_matchpathcon_printf(3) is a function pointer that
takes a format string with variable arguments.  Add a GNU printf
function attribute, if supported, to enable compilers checking for
format string inconsistencies.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libselinux/include/selinux/selinux.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libselinux/include/selinux/selinux.h b/libselinux/include/selinux/selinux.h
index a0948853..83ea871c 100644
--- a/libselinux/include/selinux/selinux.h
+++ b/libselinux/include/selinux/selinux.h
@@ -443,7 +443,11 @@  extern void selinux_flush_class_cache(void);
 /* Set the function used by matchpathcon_init when displaying
    errors about the file_contexts configuration.  If not set,
    then this defaults to fprintf(stderr, fmt, ...). */
-extern void set_matchpathcon_printf(void (*f) (const char *fmt, ...));
+extern void set_matchpathcon_printf(void
+#ifdef __GNUC__
+   __attribute__ ((format(printf, 1, 2)))
+#endif
+   (*f) (const char *fmt, ...));
 
 /* Set the function used by matchpathcon_init when checking the
    validity of a context in the file contexts configuration.  If not set,