From 4546d517e1485b03a934897bad0b8347c5cda5d1 Mon Sep 17 00:00:00 2001 From: MyungJoo Ham Date: Wed, 13 Apr 2022 18:52:54 +0900 Subject: [PATCH] clang workaround of vsnprintf With clang in macos: /Users/runner/work/nnstreamer/nnstreamer/gst/nnstreamer/nnstreamer_log.c:97:48: error: format string is not a string literal [-Werror,-Wformat-nonliteral] vsnprintf (errmsg, _NNSTREAMER_ERROR_LENGTH, fmt, arg_ptr); ^~~ /Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h:75:63: note: expanded from macro 'vsnprintf' __builtin___vsnprintf_chk (str, len, 0, __darwin_obsz(str), format, ap) ^~~~~~ 1 error generated. Add a workaround from https://stackoverflow.com/questions/20167124/vsprintf-and-vsnprintf-wformat-nonliteral-warning-on-clang-5-0 Note: gst-indent is applying indentation very strangely with __attribute__ Signed-off-by: MyungJoo Ham --- gst/nnstreamer/nnstreamer_log.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gst/nnstreamer/nnstreamer_log.c b/gst/nnstreamer/nnstreamer_log.c index eaab4bd..436fcba 100644 --- a/gst/nnstreamer/nnstreamer_log.c +++ b/gst/nnstreamer/nnstreamer_log.c @@ -87,9 +87,12 @@ _nnstreamer_error (void) /** * @brief overwrites the error message buffer with the new message. */ -void -_nnstreamer_error_write (const char *fmt, ...) +__attribute__((__format__ (__printf__, 1, 2))) + void _nnstreamer_error_write (const char *fmt, ...) { + /** The attribute is for clang workaround in macos: + https://stackoverflow.com/questions/20167124/vsprintf-and-vsnprintf-wformat-nonliteral-warning-on-clang-5-0 + */ va_list arg_ptr; G_LOCK (errlock); -- 2.7.4