From 2dc51f82eb1deca8f1e948d82538f2846f62950d Mon Sep 17 00:00:00 2001 From: "Peter S. Mazinger" Date: Thu, 8 Dec 2005 14:40:58 +0000 Subject: Reorder so that no prototype is needed. Is there a better way to get rid of gcc warning instead of adding the loop for err/errx? attribute_noreturn is not enough ;-( --- libc/misc/error/err.c | 52 +++++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 22 deletions(-) (limited to 'libc/misc/error') diff --git a/libc/misc/error/err.c b/libc/misc/error/err.c index 0d0637148..113c2d94f 100644 --- a/libc/misc/error/err.c +++ b/libc/misc/error/err.c @@ -49,62 +49,70 @@ static void vwarn_work(const char *format, va_list args, int showerr) __STDIO_AUTO_THREADUNLOCK(stderr); } -extern void warn(const char *format, ...) +void attribute_hidden __vwarn(const char *format, va_list args) +{ + vwarn_work(format, args, 1); +} +strong_alias(__vwarn,vwarn) + +void warn(const char *format, ...) { va_list args; va_start(args, format); - vwarn(format, args); + __vwarn(format, args); va_end(args); } -extern void vwarn(const char *format, va_list args) +void attribute_hidden __vwarnx(const char *format, va_list args) { - vwarn_work(format, args, 1); + vwarn_work(format, args, 0); } +strong_alias(__vwarnx,vwarnx) -extern void warnx(const char *format, ...) +void warnx(const char *format, ...) { va_list args; va_start(args, format); - vwarnx(format, args); + __vwarnx(format, args); va_end(args); } -extern void vwarnx(const char *format, va_list args) +void attribute_hidden __verr(int status, const char *format, va_list args) { - vwarn_work(format, args, 0); + __vwarn(format, args); + exit(status); } +strong_alias(__verr,verr) -extern void err(int status, const char *format, ...) +void attribute_noreturn err(int status, const char *format, ...) { va_list args; va_start(args, format); - verr(status, format, args); + __verr(status, format, args); /* This should get optimized away. We'll leave it now for safety. */ - va_end(args); + /* The loop is added only to keep gcc happy. */ + while(1) + va_end(args); } -extern void verr(int status, const char *format, va_list args) +void attribute_hidden __verrx(int status, const char *format, va_list args) { - vwarn(format, args); + __vwarnx(format, args); exit(status); } +strong_alias(__verrx,verrx) -extern void errx(int status, const char *format, ...) +void attribute_noreturn errx(int status, const char *format, ...) { va_list args; va_start(args, format); - verrx(status, format, args); + __verrx(status, format, args); /* This should get optimized away. We'll leave it now for safety. */ - va_end(args); -} - -extern void verrx(int status, const char *format, va_list args) -{ - vwarnx(format, args); - exit(status); + /* The loop is added only to keep gcc happy. */ + while(1) + va_end(args); } -- cgit v1.2.3