]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
ldattach: simplify debugging function when vwarnx(3) is available
authorSami Kerola <kerolasa@iki.fi>
Sat, 24 Jun 2017 16:01:22 +0000 (17:01 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sat, 15 Jul 2017 21:02:53 +0000 (22:02 +0100)
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 <kerolasa@iki.fi>
configure.ac
sys-utils/ldattach.c

index c76c2a0f3904dcd39f36bd18c8dd8e260a9fac27..38b968878a7d13d32740d3d5638b057103ff50a9 100644 (file)
@@ -428,6 +428,7 @@ AC_CHECK_FUNCS([ \
        sysinfo \
        timegm \
        usleep \
+       vwarnx \
        warn \
        warnx \
 ])
index eb04b5e337395f890c587015dce548ce64a9e70d..d33d685356892e8441336ca5ea30ed324dbfbed5 100644 (file)
@@ -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);
 }