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 <myungjoo.ham@samsung.com>
/**
* @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);