Skip to content

Commit

Permalink
Properly detect attribute format types (netdata#17685)
Browse files Browse the repository at this point in the history
  • Loading branch information
vkalintiris authored May 17, 2024
1 parent 7a6d0c9 commit 12b178c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,15 @@ int main() {
}
" HAVE_BUILTIN_ATOMICS)

check_c_source_compiles("
void my_printf(char const *s, ...) __attribute__((format(gnu_printf, 1, 2)));
int main() { return 0; }
" HAVE_FUNC_ATTRIBUTE_FORMAT_GNU_PRINTF FAIL_REGEX "warning:")

check_c_source_compiles("
void my_printf(char const *s, ...) __attribute__((format(printf, 1, 2)));
int main() { return 0; }
" HAVE_FUNC_ATTRIBUTE_FORMAT)
" HAVE_FUNC_ATTRIBUTE_FORMAT_PRINTF FAIL_REGEX "warning:")

check_c_source_compiles("
#include <stdio.h>
Expand Down
3 changes: 2 additions & 1 deletion packaging/cmake/config.cmake.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@
#cmakedefine HAVE_STRNDUP
#cmakedefine SSL_HAS_PENDING

#cmakedefine HAVE_FUNC_ATTRIBUTE_FORMAT
#cmakedefine HAVE_FUNC_ATTRIBUTE_FORMAT_GNU_PRINTF
#cmakedefine HAVE_FUNC_ATTRIBUTE_FORMAT_PRINTF
#cmakedefine HAVE_FUNC_ATTRIBUTE_MALLOC
#cmakedefine HAVE_FUNC_ATTRIBUTE_NOINLINE
#cmakedefine HAVE_FUNC_ATTRIBUTE_NORETURN
Expand Down
4 changes: 2 additions & 2 deletions src/collectors/log2journal/log2journal.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ static inline char *os_strndup( const char *s1, size_t n)
#define strndup(s, n) os_strndup(s, n)
#endif

#if defined(HAVE_FUNC_ATTRIBUTE_FORMAT) && !defined(COMPILED_FOR_MACOS)
#if defined(HAVE_FUNC_ATTRIBUTE_FORMAT_GNU_PRINTF)
#define PRINTFLIKE(f, a) __attribute__ ((format(gnu_printf, f, a)))
#elif defined(HAVE_FUNC_ATTRIBUTE_FORMAT)
#elif defined(HAVE_FUNC_ATTRIBUTE_FORMAT_PRINTF)
#define PRINTFLIKE(f, a) __attribute__ ((format(printf, f, a)))
#else
#define PRINTFLIKE(f, a)
Expand Down
4 changes: 2 additions & 2 deletions src/libnetdata/libnetdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@ typedef uint32_t uid_t;
#define MALLOCLIKE
#endif

#if defined(HAVE_FUNC_ATTRIBUTE_FORMAT) && !defined(COMPILED_FOR_MACOS)
#if defined(HAVE_FUNC_ATTRIBUTE_FORMAT_GNU_PRINTF)
#define PRINTFLIKE(f, a) __attribute__ ((format(gnu_printf, f, a)))
#elif defined(HAVE_FUNC_ATTRIBUTE_FORMAT)
#elif defined(HAVE_FUNC_ATTRIBUTE_FORMAT_PRINTF)
#define PRINTFLIKE(f, a) __attribute__ ((format(printf, f, a)))
#else
#define PRINTFLIKE(f, a)
Expand Down

0 comments on commit 12b178c

Please sign in to comment.