libc: Introduce __errordecl()
Define __errordecl and replace __attribute__((__error__("foo"))) with __errordecl. Make sure __errordecl is a no-op on clang, as it generates a compile time warning. Change-Id: Ifa1a2d3afd6881de9d479fc2adac6737871a2949
This commit is contained in:
parent
977a33137d
commit
b24c0637d0
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user