[patches] standardizing the error messages "cannot read %s" and "seek on %s failed"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

First patch standardizes the plain "cannot read %s" and "seek on %s failed"
error messages.  Second, third and fourth make some tiny textual corrections.
Fifth patch slices up also the first third of the help text of losetup; the
rest of the text is already sliced.

Benno

-- 
http://www.fastmail.fm - Send your email first class

From decdac2cd98de8cb5b84b5007bafc8fb3a8d3afd Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
Date: Tue, 8 Oct 2013 17:04:22 +0200
Subject: [PATCH 1/5] textual: standardize some "cannot read" and "seek failed" error messages

Signed-off-by: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
---
 disk-utils/fsck.c        |    2 +-
 disk-utils/fsck.cramfs.c |   14 +++++++-------
 lib/path.c               |    8 ++++----
 login-utils/last.c       |    8 ++++----
 login-utils/sulogin.c    |    2 +-
 sys-utils/setpriv.c      |    2 +-
 6 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/disk-utils/fsck.c b/disk-utils/fsck.c
index 19eabe3..00622c4 100644
--- a/disk-utils/fsck.c
+++ b/disk-utils/fsck.c
@@ -304,7 +304,7 @@ static int is_irrotational_disk(dev_t disk)
 	rc = fscanf(f, "%d", &x);
 	if (rc != 1) {
 		if (ferror(f))
-			warn(_("failed to read: %s"), path);
+			warn(_("cannot read %s"), path);
 		else
 			warnx(_("parse error: %s"), path);
 	}
diff --git a/disk-utils/fsck.cramfs.c b/disk-utils/fsck.cramfs.c
index 3c861d5..cd23345 100644
--- a/disk-utils/fsck.cramfs.c
+++ b/disk-utils/fsck.cramfs.c
@@ -166,14 +166,14 @@ static void test_super(int *start, size_t * length)
 
 	/* find superblock */
 	if (read(fd, &super, sizeof(super)) != sizeof(super))
-		err(FSCK_EX_ERROR, _("read failed: %s"), filename);
+		err(FSCK_EX_ERROR, _("cannot read %s"), filename);
 	if (get_superblock_endianness(super.magic) != -1)
 		*start = 0;
 	else if (*length >= (PAD_SIZE + sizeof(super))) {
 		if (lseek(fd, PAD_SIZE, SEEK_SET) == (off_t) -1)
-			err(FSCK_EX_ERROR, _("seek failed: %s"), filename);
+			err(FSCK_EX_ERROR, _("seek on %s failed"), filename);
 		if (read(fd, &super, sizeof(super)) != sizeof(super))
-			err(FSCK_EX_ERROR, _("read failed: %s"), filename);
+			err(FSCK_EX_ERROR, _("cannot read %s"), filename);
 		if (get_superblock_endianness(super.magic) != -1)
 			*start = PAD_SIZE;
 		else
@@ -228,9 +228,9 @@ static void test_crc(int start)
 			 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
 		if (buf != MAP_FAILED) {
 			if (lseek(fd, 0, SEEK_SET) == (off_t) -1)
-				err(FSCK_EX_ERROR, _("seek failed: %s"), filename);
+				err(FSCK_EX_ERROR, _("seek on %s failed"), filename);
 			if (read(fd, buf, super.size) < 0)
-				err(FSCK_EX_ERROR, _("read failed: %s"), filename);
+				err(FSCK_EX_ERROR, _("cannot read %s"), filename);
 		}
 	}
 	if (buf != MAP_FAILED) {
@@ -244,11 +244,11 @@ static void test_crc(int start)
 
 		buf = xmalloc(4096);
 		if (lseek(fd, start, SEEK_SET) == (off_t) -1)
-			err(FSCK_EX_ERROR, _("seek failed: %s"), filename);
+			err(FSCK_EX_ERROR, _("seek on %s failed"), filename);
 		for (;;) {
 			retval = read(fd, buf, 4096);
 			if (retval < 0)
-				err(FSCK_EX_ERROR, _("read failed: %s"), filename);
+				err(FSCK_EX_ERROR, _("cannot read %s"), filename);
 			else if (retval == 0)
 				break;
 			if (length == 0)
diff --git a/lib/path.c b/lib/path.c
index 7a68d9f..1f7e258 100644
--- a/lib/path.c
+++ b/lib/path.c
@@ -97,7 +97,7 @@ path_read_str(char *result, size_t len, const char *path, ...)
 	va_end(ap);
 
 	if (!fgets(result, len, fd))
-		err(EXIT_FAILURE, _("failed to read: %s"), pathbuf);
+		err(EXIT_FAILURE, _("cannot read %s"), pathbuf);
 	fclose(fd);
 
 	len = strlen(result);
@@ -118,7 +118,7 @@ path_read_s32(const char *path, ...)
 
 	if (fscanf(fd, "%d", &result) != 1) {
 		if (ferror(fd))
-			err(EXIT_FAILURE, _("failed to read: %s"), pathbuf);
+			err(EXIT_FAILURE, _("cannot read %s"), pathbuf);
 		else
 			errx(EXIT_FAILURE, _("parse error: %s"), pathbuf);
 	}
@@ -139,7 +139,7 @@ path_read_u64(const char *path, ...)
 
 	if (fscanf(fd, "%"SCNu64, &result) != 1) {
 		if (ferror(fd))
-			err(EXIT_FAILURE, _("failed to read: %s"), pathbuf);
+			err(EXIT_FAILURE, _("cannot read %s"), pathbuf);
 		else
 			errx(EXIT_FAILURE, _("parse error: %s"), pathbuf);
 	}
@@ -187,7 +187,7 @@ path_cpuparse(int maxcpus, int islist, const char *path, va_list ap)
 	fd = path_vfopen("r" UL_CLOEXECSTR, 1, path, ap);
 
 	if (!fgets(buf, len, fd))
-		err(EXIT_FAILURE, _("failed to read: %s"), pathbuf);
+		err(EXIT_FAILURE, _("cannot read %s"), pathbuf);
 	fclose(fd);
 
 	len = strlen(buf);
diff --git a/login-utils/last.c b/login-utils/last.c
index 8da42ba..5550dcb 100644
--- a/login-utils/last.c
+++ b/login-utils/last.c
@@ -186,12 +186,12 @@ static int uread(const struct last_control *ctl, FILE *fp, struct utmp *u,
 			return 0;
 		o = ((fpos - 1) / UCHUNKSIZE) * UCHUNKSIZE;
 		if (fseeko(fp, o, SEEK_SET) < 0) {
-			warn(_("seek failed: %s"), ctl->altv[ctl->alti]);
+			warn(_("seek on %s failed"), ctl->altv[ctl->alti]);
 			return 0;
 		}
 		bpos = (int)(fpos - o);
 		if (fread(buf, bpos, 1, fp) != 1) {
-			warn(_("read failed: %s"), ctl->altv[ctl->alti]);
+			warn(_("cannot read %s"), ctl->altv[ctl->alti]);
 			return 0;
 		}
 		fpos = o;
@@ -220,7 +220,7 @@ static int uread(const struct last_control *ctl, FILE *fp, struct utmp *u,
 	 */
 	memcpy(tmp + (-bpos), buf, utsize + bpos);
 	if (fseeko(fp, fpos, SEEK_SET) < 0) {
-		warn(_("seek failed: %s"), ctl->altv[ctl->alti]);
+		warn(_("seek on %s failed"), ctl->altv[ctl->alti]);
 		return 0;
 	}
 
@@ -228,7 +228,7 @@ static int uread(const struct last_control *ctl, FILE *fp, struct utmp *u,
 	 *	Read another UCHUNKSIZE bytes.
 	 */
 	if (fread(buf, UCHUNKSIZE, 1, fp) != 1) {
-		warn(_("read failed: %s"), ctl->altv[ctl->alti]);
+		warn(_("cannot read %s"), ctl->altv[ctl->alti]);
 		return 0;
 	}
 
diff --git a/login-utils/sulogin.c b/login-utils/sulogin.c
index 352c781..4560ee0 100644
--- a/login-utils/sulogin.c
+++ b/login-utils/sulogin.c
@@ -602,7 +602,7 @@ static char *getpasswd(struct console *con)
 			case ENOENT:
 				break;
 			default:
-				warn(_("%s: read failed"), con->tty);
+				warn(_("cannot read %s"), con->tty);
 				break;
 			}
 			goto quit;
diff --git a/sys-utils/setpriv.c b/sys-utils/setpriv.c
index a572736..c3f2a8b 100644
--- a/sys-utils/setpriv.c
+++ b/sys-utils/setpriv.c
@@ -230,7 +230,7 @@ static void dump_label(const char *name)
 	close(fd);
 	if (len < 0) {
 		errno = e;
-		warn(_("read failed: %s"), name);
+		warn(_("cannot read %s"), name);
 		return;
 	}
 	if (sizeof(buf) - 1 <= (size_t)len) {
-- 
1.7.0.4

From 74f0a6a749d4ef022ed17e7f01fb58899b54b03f Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
Date: Tue, 8 Oct 2013 17:11:01 +0200
Subject: [PATCH 2/5] libfdisk/dos: correct the grammar of the disk-identifier prompt

Signed-off-by: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
---
 libfdisk/src/dos.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c
index 06971de..c90721d 100644
--- a/libfdisk/src/dos.c
+++ b/libfdisk/src/dos.c
@@ -566,7 +566,7 @@ static int dos_set_disklabel_id(struct fdisk_context *cxt)
 	l = self_label(cxt);
 	old = mbr_get_id(cxt->firstsector);
 	rc = fdisk_ask_string(cxt,
-			_("Enter of the new disk identifier"), &str);
+			_("Enter the new disk identifier"), &str);
 	if (rc)
 		return rc;
 
-- 
1.7.0.4

From 1daa896a55e18807990863ba4f8124df5ba30d91 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
Date: Tue, 8 Oct 2013 17:14:38 +0200
Subject: [PATCH 3/5] libfdisk/dos: improve the grammar of an error message

Signed-off-by: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
---
 libfdisk/src/dos.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c
index c90721d..520ba34 100644
--- a/libfdisk/src/dos.c
+++ b/libfdisk/src/dos.c
@@ -1322,7 +1322,7 @@ static int write_sector(struct fdisk_context *cxt, sector_t secno,
 
 	rc = seek_sector(cxt, secno);
 	if (rc != 0) {
-		fdisk_warn(cxt, _("Write sector %jd failed: seek failed"),
+		fdisk_warn(cxt, _("Cannot write sector %jd: seek failed"),
 				(uintmax_t) secno);
 		return rc;
 	}
-- 
1.7.0.4

From 3e0ea7e8f800fdb0bba7c8caa2c50bf426f61acd Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
Date: Tue, 8 Oct 2013 17:18:18 +0200
Subject: [PATCH 4/5] libfdisk/gpt: use consistent final period in status messages

Signed-off-by: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
---
 libfdisk/src/gpt.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c
index c04b21e..448b1ff 100644
--- a/libfdisk/src/gpt.c
+++ b/libfdisk/src/gpt.c
@@ -1811,7 +1811,7 @@ static int gpt_create_disklabel(struct fdisk_context *cxt)
 	guid_to_string(&gpt->pheader->disk_guid, str);
 	fdisk_label_set_changed(cxt->label, 1);
 	fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
-			_("Created a new GPT disklabel (GUID: %s)"), str);
+			_("Created a new GPT disklabel (GUID: %s)."), str);
 done:
 	return rc;
 }
@@ -1998,7 +1998,7 @@ int fdisk_gpt_partition_set_uuid(struct fdisk_context *cxt, size_t i)
 	fdisk_label_set_changed(cxt->label, 1);
 
 	fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
-			_("Partition UUID changed from %s to %s"),
+			_("Partition UUID changed from %s to %s."),
 			old_u, new_u);
 	return 0;
 }
@@ -2043,7 +2043,7 @@ int fdisk_gpt_partition_set_name(struct fdisk_context *cxt, size_t i)
 	fdisk_label_set_changed(cxt->label, 1);
 
 	fdisk_sinfo(cxt, FDISK_INFO_SUCCESS,
-			_("Partition name changed from '%s' to '%.*s'"),
+			_("Partition name changed from '%s' to '%.*s'."),
 			old, GPT_PART_NAME_LEN, str);
 	free(str);
 	free(old);
-- 
1.7.0.4

From 21be54adc0372b0a0c907877308734202e041940 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
Date: Tue, 8 Oct 2013 17:29:20 +0200
Subject: [PATCH 5/5] losetup: cut the remaining little block of help text into slices too

Signed-off-by: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
---
 sys-utils/losetup.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c
index 9169f88..5be3288 100644
--- a/sys-utils/losetup.c
+++ b/sys-utils/losetup.c
@@ -368,12 +368,13 @@ static void usage(FILE *out)
 		program_invocation_short_name);
 
 	fputs(USAGE_OPTIONS, out);
-	fputs(_(" -a, --all                     list all used devices\n"
-		" -d, --detach <loopdev> [...]  detach one or more devices\n"
-		" -D, --detach-all              detach all used devices\n"
-		" -f, --find                    find first unused device\n"
-		" -c, --set-capacity <loopdev>  resize device\n"
-		" -j, --associated <file>       list all devices associated with <file>\n"), out);
+	fputs(_(" -a, --all                     list all used devices\n"), out);
+	fputs(_(" -d, --detach <loopdev> [...]  detach one or more devices\n"), out);
+	fputs(_(" -D, --detach-all              detach all used devices\n"), out);
+	fputs(_(" -f, --find                    find first unused device\n"), out);
+	fputs(_(" -c, --set-capacity <loopdev>  resize device\n"), out);
+	fputs(_(" -j, --associated <file>       list all devices associated with <file>\n"), out);
+
 	fputs(USAGE_SEPARATOR, out);
 
 	fputs(_(" -o, --offset <num>            start at offset <num> into file\n"), out);
-- 
1.7.0.4


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux