util-linux.vger.kernel.org archive mirror
 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/3] textual: improve error messages
Date: Sun,  7 Dec 2014 10:13:03 +0000	[thread overview]
Message-ID: <1417947184-24178-2-git-send-email-kerolasa@iki.fi> (raw)
In-Reply-To: <1417947184-24178-1-git-send-email-kerolasa@iki.fi>

Use error printing facilities that add command name in front of the error
message, and add explanation that is part of existing translations.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 disk-utils/blockdev.c    |  2 +-
 disk-utils/mkfs.c        |  3 +--
 disk-utils/mkfs.cramfs.c |  2 +-
 text-utils/more.c        | 10 ++++------
 4 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/disk-utils/blockdev.c b/disk-utils/blockdev.c
index efaa0ea..43aaef6 100644
--- a/disk-utils/blockdev.c
+++ b/disk-utils/blockdev.c
@@ -365,7 +365,7 @@ static void do_commands(int fd, char **argv, int d)
 		}
 
 		if (res == -1) {
-			perror(bdcms[j].iocname);
+			warn(_("ioctl error on %s"), bdcms[j].iocname);
 			if (verbose)
 				printf(_("%s failed.\n"), _(bdcms[j].help));
 			exit(EXIT_FAILURE);
diff --git a/disk-utils/mkfs.c b/disk-utils/mkfs.c
index dbc938f..8ad6065 100644
--- a/disk-utils/mkfs.c
+++ b/disk-utils/mkfs.c
@@ -147,6 +147,5 @@ int main(int argc, char **argv)
 
 	/* Execute the program */
 	execvp(progname, argv + optind);
-	perror(progname);
-	return EXIT_FAILURE;
+	err(EXIT_FAILURE, _("failed to execute %s"), progname);
 }
diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c
index bae68ec..509b50b 100644
--- a/disk-utils/mkfs.cramfs.c
+++ b/disk-utils/mkfs.cramfs.c
@@ -328,7 +328,7 @@ static unsigned int parse_directory(struct entry *root_entry, const char *name,
 		memcpy(endpath, dirent->d_name, namelen + 1);
 
 		if (lstat(path, &st) < 0) {
-			perror(endpath);
+			warn(_("stat failed %s"), endpath);
 			warn_skip = 1;
 			continue;
 		}
diff --git a/text-utils/more.c b/text-utils/more.c
index a489953..8c0853c 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -591,7 +591,7 @@ FILE *checkf(register char *fs, int *clearfirst)
 		fflush(stdout);
 		if (clreol)
 			cleareol();
-		perror(fs);
+		warn(_("stat failed %s"), fs);
 		return ((FILE *)NULL);
 	}
 	if ((stbuf.st_mode & S_IFMT) == S_IFDIR) {
@@ -600,7 +600,7 @@ FILE *checkf(register char *fs, int *clearfirst)
 	}
 	if ((f = Fopen(fs, "r")) == NULL) {
 		fflush(stdout);
-		perror(fs);
+		warn(_("cannot open %s"), fs);
 		return ((FILE *)NULL);
 	}
 	if (magic(f, fs)) {
@@ -1781,10 +1781,8 @@ void initterm(void)
 			int tgrp;
 			/* Wait until we're in the foreground before we
 			 * save the terminal modes. */
-			if ((tgrp = tcgetpgrp(fileno(stdout))) < 0) {
-				perror("tcgetpgrp");
-				exit(EXIT_FAILURE);
-			}
+			if ((tgrp = tcgetpgrp(fileno(stdout))) < 0)
+				err(EXIT_FAILURE, "tcgetpgrp");
 			if (tgrp != getpgrp(0)) {
 				kill(0, SIGTTOU);
 				goto retry;
-- 
2.1.3


  reply	other threads:[~2014-12-07 10:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-07 10:13 [PATCH 1/3] login-utils: use libc error printing facility Sami Kerola
2014-12-07 10:13 ` Sami Kerola [this message]
2014-12-07 10:13 ` [PATCH 3/3] line: use util-linux conventions Sami Kerola
2014-12-09  8:22 ` [PATCH 1/3] login-utils: use libc error printing facility 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=1417947184-24178-2-git-send-email-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;
as well as URLs for NNTP newsgroup(s).