From 6f97b30a904407c1f1701d937d9258ca9175c6ab Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 29 Sep 2017 18:17:25 +0200 Subject: use %m printf specifier where appropriate function old new delta out 85 75 -10 udhcpd_main 1472 1461 -11 open_stdio_to_tty 98 85 -13 init_exec 245 232 -13 udhcpc_main 2763 2749 -14 do_cmd 4771 4755 -16 status_line_bold_errno 32 14 -18 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/7 up/down: 0/-95) Total: -95 bytes Signed-off-by: Denys Vlasenko --- include/libbb.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/libbb.h b/include/libbb.h index aff2825ac..daccf154a 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -162,6 +162,17 @@ #ifndef HAVE_XTABS # define XTABS TAB3 #endif +/* + * Use '%m' to append error string on platforms that support it, + * '%s' and strerror() on those that don't. + */ +#ifdef HAVE_PRINTF_PERCENTM +# define STRERROR_FMT "%m" +# define STRERROR_ERRNO /*nothing*/ +#else +# define STRERROR_FMT "%s" +# define STRERROR_ERRNO ,strerror(errno) +#endif /* Some libc's forget to declare these, do it ourself */ -- cgit v1.2.3