From: Sami Kerola Date: Sat, 24 Jun 2017 16:01:22 +0000 (+0100) Subject: ldattach: simplify debugging function when vwarnx(3) is available X-Git-Tag: v2.31-rc1~195^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=31f85fce55523c1ca3650a227edc0c22f87cab60;p=thirdparty%2Futil-linux.git ldattach: simplify debugging function when vwarnx(3) is available The vwarnx(3) is probably not available in all libc implementations, in such cases use the earlier printout as a fallback. Signed-off-by: Sami Kerola --- diff --git a/configure.ac b/configure.ac index c76c2a0f39..38b968878a 100644 --- a/configure.ac +++ b/configure.ac @@ -428,6 +428,7 @@ AC_CHECK_FUNCS([ \ sysinfo \ timegm \ usleep \ + vwarnx \ warn \ warnx \ ]) diff --git a/sys-utils/ldattach.c b/sys-utils/ldattach.c index eb04b5e337..d33d685356 100644 --- a/sys-utils/ldattach.c +++ b/sys-utils/ldattach.c @@ -137,11 +137,15 @@ static void dbg(char *fmt, ...) if (debug == 0) return; fflush(NULL); - fprintf(stderr, "%s: ", program_invocation_short_name); va_start(args, fmt); +#ifdef HAVE_VWARNX + vwarnx(fmt, args); +#else + fprintf(stderr, "%s: ", program_invocation_short_name); vfprintf(stderr, fmt, args); - va_end(args); fprintf(stderr, "\n"); +#endif + va_end(args); fflush(NULL); return; } @@ -252,7 +256,7 @@ static int my_cfsetspeed(struct termios *ts, int speed) static void handler(int s) { - dbg("got SIG %i -> exiting\n", s); + dbg("got SIG %i -> exiting", s); exit(EXIT_SUCCESS); }