Util-Linux package development
 help / color / mirror / Atom feed
From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: Sami Kerola <kerolasa@iki.fi>
Subject: [PATCH 2/5] ldattach: simplify debugging function when vwarnx(3) is available
Date: Sat, 15 Jul 2017 22:20:43 +0100	[thread overview]
Message-ID: <20170715212046.1655-3-kerolasa@iki.fi> (raw)
In-Reply-To: <20170715212046.1655-1-kerolasa@iki.fi>

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         |  1 +
 sys-utils/ldattach.c | 10 +++++++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index c76c2a0f3..38b968878 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 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);
 }
 
-- 
2.13.3


  parent reply	other threads:[~2017-07-15 21:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-15 21:20 [PATCH 0/5] pull: five mutually unrelated changes Sami Kerola
2017-07-15 21:20 ` [PATCH 1/5] reset: remove script from the package Sami Kerola
2017-07-15 21:20 ` Sami Kerola [this message]
2017-07-15 21:20 ` [PATCH 3/5] docs: add optional option back to struct option Sami Kerola
2017-07-15 21:20 ` [PATCH 4/5] uuidparse: add bash-completion file Sami Kerola
2017-07-15 21:20 ` [PATCH 5/5] bash-completion: make completions to work when bash set -u is in use Sami Kerola
2017-07-15 22:45 ` [PATCH 0/5] pull: five mutually unrelated changes Bruce Dubbs
2017-07-16  9:08   ` Sami Kerola
2017-07-16 15:25     ` Bruce Dubbs
2017-07-17  9:28       ` Karel Zak
2017-07-17 10:04 ` Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170715212046.1655-3-kerolasa@iki.fi \
    --to=kerolasa@iki.fi \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox