summaryrefslogtreecommitdiffstats
path: root/sys-utils/ldattach.c
diff options
context:
space:
mode:
authorSami Kerola2017-06-24 18:01:22 +0200
committerSami Kerola2017-07-15 23:02:53 +0200
commit31f85fce55523c1ca3650a227edc0c22f87cab60 (patch)
tree3334ae05124c1781c685cf08516d8bba63ce8010 /sys-utils/ldattach.c
parentreset: remove script from the package (diff)
downloadkernel-qcow2-util-linux-31f85fce55523c1ca3650a227edc0c22f87cab60.tar.gz
kernel-qcow2-util-linux-31f85fce55523c1ca3650a227edc0c22f87cab60.tar.xz
kernel-qcow2-util-linux-31f85fce55523c1ca3650a227edc0c22f87cab60.zip
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 <kerolasa@iki.fi>
Diffstat (limited to 'sys-utils/ldattach.c')
-rw-r--r--sys-utils/ldattach.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sys-utils/ldattach.c b/sys-utils/ldattach.c
index eb04b5e33..d33d68535 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);
}