diff --git a/libc/include/fcntl.h b/libc/include/fcntl.h index de2e3e354..67fd59712 100644 --- a/libc/include/fcntl.h +++ b/libc/include/fcntl.h @@ -50,11 +50,8 @@ extern int fcntl(int fd, int command, ...); extern int creat(const char* path, mode_t mode); #if defined(__BIONIC_FORTIFY) - -extern void __creat_error() - __attribute__((__error__ ("called with O_CREAT, but missing mode"))); -extern void __too_many_args_error() - __attribute__((__error__ ("too many arguments"))); +__errordecl(__creat_error, "called with O_CREAT, but missing mode"); +__errordecl(__too_many_args_error, "too many arguments"); extern int __open_real(const char *pathname, int flags, ...) __asm__(__USER_LABEL_PREFIX__ "open"); extern int __open_2(const char *, int); diff --git a/libc/include/stdio.h b/libc/include/stdio.h index aca6d9ff0..154a86c27 100644 --- a/libc/include/stdio.h +++ b/libc/include/stdio.h @@ -486,10 +486,8 @@ int sprintf(char *dest, const char *format, ...) extern char *__fgets_real(char *, int, FILE *) __asm__(__USER_LABEL_PREFIX__ "fgets"); -extern void __fgets_too_big_error() - __attribute__((__error__("fgets called with size bigger than buffer"))); -extern void __fgets_too_small_error() - __attribute__((__error__("fgets called with size less than zero"))); +__errordecl(__fgets_too_big_error, "fgets called with size bigger than buffer"); +__errordecl(__fgets_too_small_error, "fgets called with size less than zero"); extern char *__fgets_chk(char *, int, FILE *, size_t); __BIONIC_FORTIFY_INLINE diff --git a/libc/include/string.h b/libc/include/string.h index 1691b16c0..3c9fc21c0 100644 --- a/libc/include/string.h +++ b/libc/include/string.h @@ -87,10 +87,8 @@ extern size_t strxfrm(char* __restrict, const char* __restrict, size_t); #if defined(__BIONIC_FORTIFY) -extern void __memcpy_dest_size_error() - __attribute__((__error__("memcpy called with size bigger than destination"))); -extern void __memcpy_src_size_error() - __attribute__((__error__("memcpy called with size bigger than source"))); +__errordecl(__memcpy_dest_size_error, "memcpy called with size bigger than destination"); +__errordecl(__memcpy_src_size_error, "memcpy called with size bigger than source"); __BIONIC_FORTIFY_INLINE void *memcpy (void* __restrict dest, const void* __restrict src, size_t copy_amount) { @@ -120,8 +118,7 @@ char *strcpy(char* __restrict dest, const char* __restrict src) { return __builtin___strcpy_chk(dest, src, __bos(dest)); } -extern void __strncpy_error() - __attribute__((__error__("strncpy called with size bigger than buffer"))); +__errordecl(__strncpy_error, "strncpy called with size bigger than buffer"); __BIONIC_FORTIFY_INLINE char *strncpy(char* __restrict dest, const char* __restrict src, size_t n) { @@ -149,8 +146,7 @@ void *memset (void *s, int c, size_t n) { extern size_t __strlcpy_real(char* __restrict, const char* __restrict, size_t) __asm__(__USER_LABEL_PREFIX__ "strlcpy"); -extern void __strlcpy_error() - __attribute__((__error__("strlcpy called with size bigger than buffer"))); +__errordecl(__strlcpy_error, "strlcpy called with size bigger than buffer"); extern size_t __strlcpy_chk(char *, const char *, size_t, size_t); __BIONIC_FORTIFY_INLINE @@ -179,8 +175,7 @@ size_t strlcpy(char* __restrict dest, const char* __restrict src, size_t size) { extern size_t __strlcat_real(char* __restrict, const char* __restrict, size_t) __asm__(__USER_LABEL_PREFIX__ "strlcat"); -extern void __strlcat_error() - __attribute__((__error__("strlcat called with size bigger than buffer"))); +__errordecl(__strlcat_error, "strlcat called with size bigger than buffer"); extern size_t __strlcat_chk(char* __restrict, const char* __restrict, size_t, size_t); diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h index c71035633..78513e313 100644 --- a/libc/include/sys/cdefs.h +++ b/libc/include/sys/cdefs.h @@ -330,6 +330,12 @@ #define __wur #endif +#if __GNUC_PREREQ__(4, 3) +#define __errordecl(name, msg) extern void name(void) __attribute__((__error__(msg))) +#else +#define __errordecl(name, msg) extern void name(void) +#endif + /* * Macros for manipulating "link sets". Link sets are arrays of pointers * to objects, which are gathered up by the linker. diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h index 4e8beb6a5..da49e1ae8 100644 --- a/libc/include/sys/stat.h +++ b/libc/include/sys/stat.h @@ -134,8 +134,7 @@ extern mode_t umask(mode_t); extern mode_t __umask_chk(mode_t); extern mode_t __umask_real(mode_t) __asm__(__USER_LABEL_PREFIX__ "umask"); -extern void __umask_error() - __attribute__((__error__("umask called with invalid mode"))); +__errordecl(__umask_error, "umask called with invalid mode"); __BIONIC_FORTIFY_INLINE mode_t umask(mode_t mode) {