Skip to content

Commit

Permalink
clang workaround of vsnprintf
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
myungjoo committed Apr 27, 2022
1 parent 15bed93 commit 4546d51
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions gst/nnstreamer/nnstreamer_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 4546d51

Please sign in to comment.