mirror of
https://github.com/opnsense/src.git
synced 2026-02-03 20:49:35 -05:00
cdefs.h: Introduce __nonstring attribute
This attribute can be used to annotate char arrays that are not supposed to be terminated with a NUL char and is needed to silence clang's new -Wunterminated-string-initialization warning. The name matches linuxkpi. Reviewed by: emaste, jhb MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D52565 (cherry picked from commit 802c6d5d61d15494a54a386dc2ffbcfefc68c8ab)
This commit is contained in:
parent
46f807c0c8
commit
28f6788fec
2 changed files with 15 additions and 0 deletions
|
|
@ -521,6 +521,13 @@
|
|||
#define __printf0like(fmtarg, firstvararg)
|
||||
#endif
|
||||
|
||||
/* To silence warnings about null terminator not fitting into an array. */
|
||||
#if __has_attribute(__nonstring__)
|
||||
#define __nonstring __attribute__((__nonstring__))
|
||||
#else
|
||||
#define __nonstring
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define __strong_reference(sym,aliassym) \
|
||||
extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))
|
||||
|
|
|
|||
|
|
@ -100,6 +100,14 @@
|
|||
__attribute__((__format__(__printf0__, fmtarg, firstvararg)))
|
||||
#endif
|
||||
|
||||
#ifndef __nonstring
|
||||
#if __has_attribute(__nonstring__)
|
||||
#define __nonstring __attribute__((__nonstring__))
|
||||
#else
|
||||
#define __nonstring
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __predict_true
|
||||
#define __predict_true(exp) __builtin_expect((exp), 1)
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue