Skip to contentSkip to conversation

removing some duplicate includes and standardizing a usage text

PATCH Applied Benno Schulenberg 3 participants 5 messages Apr 29, 2014 – May 6, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 removing some duplicate includes and standardizing a usage text

Hi,

The first few patches remove two duplicate includes, tweak some comments and usage strings, and normalizes another include.

The sixth patch adds a missing error message to ionice. And as the usage text of ionice recently changed, the seventh patch seizes the opportunity to slice it up, standardize its form, and improve some of the descriptions.

The eighth patch tries to massage the usage howto into a better grammatical shape.

Sami, there is one thing I changed: the square brackets around the three dots, as that seems pleonastic to me, and the man-pages man page suggests the bare three dots: see 'man 1 man' and search for "repeat".

Benno

Signature · 1 line
http://www.fastmail.fm - Send your email first class

From 6eed20de0ddf39706ccef525ae98317054fc0967 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <[email protected]>
Date: Mon, 28 Apr 2014 17:52:42 +0200
Subject: [PATCH 1/8] include/c: remove a duplicate include

Also tweak some comments.

---
 include/c.h |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)
include/c.h +7 -10
index a192fb1..cf30b27 100644
@@ -19,12 +19,8 @@
 # include <err.h>
 #endif
 
-#ifndef HAVE_USLEEP
-# include <time.h>
-#endif
-
 /*
- * Compiler specific stuff
+ * Compiler-specific stuff
  */
 #ifndef __GNUC_PREREQ
 # if defined __GNUC__ && defined __GNUC_MINOR__
@@ -70,9 +66,10 @@
 # endif
 #endif
 
-/* Force a compilation error if condition is true, but also produce a
+/*
+ * Force a compilation error if condition is true, but also produce a
  * result (of value 0 and type size_t), so the expression can be used
- * e.g. in a structure initializer (or where-ever else comma expressions
+ * e.g. in a structure initializer (or wherever else comma expressions
  * aren't permitted).
  */
 #define UL_BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
@@ -254,9 +251,9 @@ static inline size_t get_hostname_max(void)
 }
 
 /*
- * The usleep function is marked obsolete in POSIX.1-2001 and removed in
- * POSIX.1-2008. This is replaced with nanosleep() that provides more
- * advantages (like no interaction with signals and other timer functions.
+ * The usleep function was marked obsolete in POSIX.1-2001 and was removed
+ * in POSIX.1-2008.  It was replaced with nanosleep() that provides more
+ * advantages (like no interaction with signals and other timer functions).
  */
 #include <time.h>
 
Signature · 1 line
1.7.0.4

From 65f46b06ed0004cfe66f67c04da66b0cd508e5a4 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <[email protected]>
Date: Mon, 28 Apr 2014 18:08:42 +0200
Subject: [PATCH 2/8] include/carefulputc: remove a duplicate include

Also tweak a comment.

---
 include/carefulputc.h |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
include/carefulputc.h +5 -4
index 2273028..f29dc69 100644
@@ -1,11 +1,12 @@
 #ifndef UTIL_LINUX_CAREFUULPUTC_H
 #define UTIL_LINUX_CAREFUULPUTC_H
 
-/* putc() for use in write and wall (that sometimes are sgid tty) */
-/* Avoid control characters in our locale, and also ASCII control characters.
-   Note that the locale of the recipient is unknown. */
+/*
+ * A putc() for use in write and wall (that sometimes are sgid tty).
+ * It avoids control characters in our locale, and also ASCII control
+ * characters.   Note that the locale of the recipient is unknown.
+*/
 #include <stdio.h>
-#include <ctype.h>
 #include <string.h>
 #include <ctype.h>
 
Signature · 1 line
1.7.0.4

From 99ba5c9d3c052eddfe3df874c17045181e16ce9f Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <[email protected]>
Date: Mon, 28 Apr 2014 18:10:38 +0200
Subject: [PATCH 3/8] lib/colors: change an include to a local one

---
 lib/colors.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/colors.c +1 -1
index 8b6f089..1950273 100644
@@ -4,10 +4,10 @@
  * This file may be distributed under the terms of the
  * GNU Lesser General Public License.
  */
-#include <c.h>
 #include <assert.h>
 #include <sys/stat.h>
 
+#include "c.h"
 #include "colors.h"
 #include "xalloc.h"
 #include "pathnames.h"
Signature · 1 line
1.7.0.4

From aa224461804ee1d0615167b8f056952ef0fe4323 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <[email protected]>
Date: Mon, 28 Apr 2014 18:15:00 +0200
Subject: [PATCH 4/8] include/c: do not gettextize a wordless string

---
 include/c.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
include/c.h +1 -1
index cf30b27..c3378fd 100644
@@ -278,7 +278,7 @@ static inline int xusleep(useconds_t usec)
  */
 #define USAGE_HEADER     _("\nUsage:\n")
 #define USAGE_OPTIONS    _("\nOptions:\n")
-#define USAGE_SEPARATOR  _("\n")
+#define USAGE_SEPARATOR    "\n"
 #define USAGE_HELP       _(" -h, --help     display this help and exit\n")
 #define USAGE_VERSION    _(" -V, --version  output version information and exit\n")
 #define USAGE_MAN_TAIL(_man)   _("\nFor more details see %s.\n"), _man
Signature · 1 line
1.7.0.4

From 5610bed4f13d9b67c647c19b8f28647d58bdfe33 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <[email protected]>
Date: Mon, 28 Apr 2014 23:12:41 +0200
Subject: [PATCH 5/8] ipcs: do not gettextize wordless strings

Also tweak a few parts of the usage message.

---
 sys-utils/ipcs.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
sys-utils/ipcs.c +5 -5
index 90d6e0e..8ed5698 100644
@@ -53,23 +53,23 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out)
 	fprintf(out, " %s [resource ...] [output-format]\n", program_invocation_short_name);
 	fprintf(out, " %s [resource] -i <id>\n", program_invocation_short_name);
 	fprintf(out, USAGE_OPTIONS);
-	fputs(_(" -i, --id <id>  print details on resource identified by id\n"), out);
+	fputs(_(" -i, --id <id>  print details on resource identified by <id>\n"), out);
 	fprintf(out, USAGE_HELP);
 	fprintf(out, USAGE_VERSION);
-	fputs(_("\n"), out);
+	fprintf(out, USAGE_SEPARATOR);
 	fputs(_("Resource options:\n"), out);
 	fputs(_(" -m, --shmems      shared memory segments\n"), out);
 	fputs(_(" -q, --queues      message queues\n"), out);
 	fputs(_(" -s, --semaphores  semaphores\n"), out);
 	fputs(_(" -a, --all         all (default)\n"), out);
-	fputs(_("\n"), out);
+	fprintf(out, USAGE_SEPARATOR);
 	fputs(_("Output format:\n"), out);
 	fputs(_(" -t, --time        show attach, detach and change times\n"), out);
-	fputs(_(" -p, --pid         show creator and last operations PIDs\n"), out);
+	fputs(_(" -p, --pid         show PIDs of creator and last operator\n"), out);
 	fputs(_(" -c, --creator     show creator and owner\n"), out);
 	fputs(_(" -l, --limits      show resource limits\n"), out);
 	fputs(_(" -u, --summary     show status summary\n"), out);
-	fputs(_("     --human       show sizes in human readable format\n"), out);
+	fputs(_("     --human       show sizes in human-readable format\n"), out);
 	fputs(_(" -b, --bytes       show sizes in bytes\n"), out);
 	fprintf(out, USAGE_MAN_TAIL("ipcs(1)"));
 	exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
Signature · 1 line
1.7.0.4

From 025b7ac4bd9081c88224101c77abf6e6d6432f3e Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <[email protected]>
Date: Tue, 29 Apr 2014 11:36:22 +0200
Subject: [PATCH 6/8] ionice: add a missing error message

---
 schedutils/ionice.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
schedutils/ionice.c +1 -0
index a3edf55..26b6d7c 100644
@@ -188,6 +188,7 @@ int main(int argc, char **argv)
 			if (who)
 				errx(EXIT_FAILURE,
 				     _("can handle one of pid, pgid or uid at once"));
+			invalid_msg = _("invalid UID argument");
 			which = strtos32_or_err(optarg, invalid_msg);
 			who = IOPRIO_WHO_USER;
 			break;
Signature · 1 line
1.7.0.4

From a5396b96d24db290d433124de930289c3ad1ec53 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <[email protected]>
Date: Tue, 29 Apr 2014 15:42:23 +0200
Subject: [PATCH 7/8] textual: slice up and standardize the usage text of ionice

Done for ease of translation and maintenance. Also improve the clarity of some of the descriptions, and of one error message.

---
 schedutils/ionice.c |   54 +++++++++++++++++++++++++-------------------------
 1 files changed, 27 insertions(+), 27 deletions(-)
schedutils/ionice.c +27 -27

84 lines not on this page · raw message

Signature · 1 line
1.7.0.4

From 2ba9e11055f94e907bcad4ecf4badf2633fdb44d Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <[email protected]>
Date: Tue, 29 Apr 2014 17:33:04 +0200
Subject: [PATCH 8/8] docs: grammarize the usage howto

---
 Documentation/howto-usage-function.txt |  158 ++++++++++++++++----------------
 1 files changed, 78 insertions(+), 80 deletions(-)
Documentation/howto-usage-function.txt +78 -80

228 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 8 lines · Benno Schulenberg

The first few patches remove two duplicate includes, tweak some comments and usage strings, and normalizes another include.

The sixth patch adds a missing error message to ionice. And as the usage text of ionice recently changed, the seventh patch seizes the opportunity to slice it up, standardize its form, and improve some of the descriptions.

Quoted 6 lines

The eighth patch tries to massage the usage howto into a better grammatical shape.

Sami, there is one thing I changed: the square brackets around the three dots, as that seems pleonastic to me, and the man-pages man page suggests the bare three dots: see 'man 1 man' and search for "repeat".

Hi Benno,

You are right. That looks better. Now when you are working with this maybe the commands and other documents could be fixed in same go.

$ git grep -l '\[\.\.\.\]' *utils lib* Documentation
Documentation/howto-debug.txt
Documentation/howto-usage-function.txt
Documentation/releases/v2.13-ReleaseNotes
disk-utils/sfdisk.c
misc-utils/kill.c
sys-utils/cytune.8
sys-utils/cytune.c
sys-utils/ipcrm.c
sys-utils/losetup.c
text-utils/hexdump.1
Signature · 2 lines
Sami Kerola
http://www.iki.fi/kerolasa/
#2 lore raw
Quoted 2 lines · Sami Kerola

You are right. That looks better. Now when you are working with this maybe the commands and other documents could be fixed in same go.

Okay, attached patch does that. The remaining "[...]" in the docs are appropriate and shouldn't be changed. The patch also removes some angular brackets around <shm|msg|sem> as those are literal values and should not be replaced with anything else. This mistaken use of angular brackets occurs more often -- I've been wanting to bring this up for a long time, but didn't get around to it.

For another issue, see the upcoming message.

Benno

Signature · 2 lines
http://www.fastmail.fm - One of many happy users:
  http://www.fastmail.fm/help/overview_quotes.html

From 8bf64e22f04b71c58bd52b62dd0a24d3fd70694b Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <[email protected]>
Date: Wed, 30 Apr 2014 10:38:12 +0200
Subject: [PATCH] textual: remove square brackets from around three dots

Also improve some option descriptions here and there.

---
 disk-utils/sfdisk.c  |    6 +++---
 misc-utils/kill.c    |    2 +-
 sys-utils/cytune.8   |    8 ++++----
 sys-utils/cytune.c   |   12 ++++++------
 sys-utils/ipcrm.c    |    8 ++++----
 sys-utils/losetup.c  |   10 +++++-----
 text-utils/hexdump.1 |    2 +-
 7 files changed, 24 insertions(+), 24 deletions(-)
disk-utils/sfdisk.c +3 -3
index bd32aa8..3c55d5e 100644
@@ -2346,7 +2346,7 @@ static void usage(FILE * out)
 {
 	fputs(USAGE_HEADER, out);
 	fprintf(out,
-		_(" %s [options] <device> [...]\n"),  program_invocation_short_name);
+		_(" %s [options] <device>...\n"),  program_invocation_short_name);
 
 	fputs(USAGE_OPTIONS, out);
 	fputs(_(" -s, --show-size           list size of a partition\n"
@@ -2378,8 +2378,8 @@ static void usage(FILE * out)
 		" -L, --Linux               do not complain about things irrelevant for Linux\n"), out);
 	fputs(_(" -g, --show-geometry       print the kernel's idea of the geometry\n"
 		" -G, --show-pt-geometry    print geometry guessed from the partition table\n"), out);
-	fputs(_(" -A, --activate[=<device>] activate bootable flag\n"
-		" -U, --unhide[=<dev>]      set partition unhidden\n"
+	fputs(_(" -A, --activate[=<device>] activate the bootable flag\n"
+		" -U, --unhide[=<device>]   set partition as unhidden\n"
 		" -x, --show-extended       also list extended partitions in the output,\n"
 		"                             or expect descriptors for them in the input\n"), out);
 	fputs(_("     --leave-last          do not allocate the last cylinder\n"
misc-utils/kill.c +1 -1
index b30b94f..5d2f27d 100644
@@ -303,7 +303,7 @@ static int arg_to_signum(char *arg, int maskbit)
 static void __attribute__((__noreturn__)) usage(FILE *out)
 {
 	fputs(USAGE_HEADER, out);
-	fprintf(out, _(" %s [options] <pid|name> [...]\n"), program_invocation_short_name);
+	fprintf(out, _(" %s [options] <pid|name>...\n"), program_invocation_short_name);
 
 	fputs(USAGE_OPTIONS, out);
 	fputs(_(" -a, --all              do not restrict the name-to-pid conversion to processes\n"
sys-utils/cytune.8 +4 -4
index 940fa28..3bf7afc 100644
@@ -29,7 +29,7 @@
 cytune \- tune driver parameters for Cyclades-Z multiport serial card
 .SH SYNOPSIS
 .B cytune
-[options] tty [...]
+.RI [options] tty ...
 .SH DESCRIPTION
 .B cytune
 queries and modifies the interruption threshold for the Cyclades driver.
@@ -136,8 +136,8 @@ next open.  Only values between 0 and 255, inclusive, are permitted.  Setting
 to zero forces the default, currently 0x20 (160ms), but soon to be 0x02
 (10ms).  Units are 5 ms.
 .TP
-\fB\-g\fR, \fB\-\-get\-threshold\fR
-Get the current threshold and timeout.
+\fB\-g\fR, \fB\-\-get-threshold\fR
+Get the current threshold and flush timeout values.
 .TP
 \fB\-S\fR, \fB\-\-set\-default\-threshold\fR \fIvalue\fR
 Set the default threshold to
@@ -157,7 +157,7 @@ is next opened, this value will be used instead of the default.  If
 is zero, then the value will default to 0x20 (160ms), soon to be 0x02
 (10ms).
 .TP
-\fB\-G\fR, \fB\-\-get\-glush\fR
+\fB\-G\fR, \fB\-\-get-flush\fR
 Get the default threshold and flush timeout values.
 .TP
 \fB\-q\fR, \fB\-\-stats\fR
sys-utils/cytune.c +6 -6
index 8a42f96..15529ff 100644
@@ -89,14 +89,14 @@ static char ***global_argv;
 static void __attribute__ ((__noreturn__)) usage(FILE * out)
 {
 	fprintf(out, USAGE_HEADER);
-	fprintf(out, _(" %s [options] <tty> [...]\n"), program_invocation_short_name);
+	fprintf(out, _(" %s [options] <tty>...\n"), program_invocation_short_name);
 	fprintf(out, USAGE_OPTIONS);
 	fprintf(out, _(" -s, --set-threshold <num>          set interruption threshold value\n"));
-	fprintf(out, _(" -g, --get-threshold                display current threshold value\n"));
-	fprintf(out, _(" -S, --set-default-threshold <num>  set default threshold value\n"));
-	fprintf(out, _(" -t, --set-flush <num>              set flush timeout to value\n"));
-	fprintf(out, _(" -G, --get-flush                    display default flush timeout value\n"));
-	fprintf(out, _(" -T, --set-default-flush <num>      set the default flush timeout to value\n"));
+	fprintf(out, _(" -g, --get-threshold                display the current values\n"));
+	fprintf(out, _(" -S, --set-default-threshold <num>  set the default threshold value\n"));
+	fprintf(out, _(" -t, --set-flush <num>              set the flush timeout\n"));
+	fprintf(out, _(" -G, --get-flush                    display the default values\n"));
+	fprintf(out, _(" -T, --set-default-flush <num>      set the default flush timeout\n"));
 	fprintf(out, _(" -q, --stats                        display statistics about the tty\n"));
 	fprintf(out, _(" -i, --interval <seconds>           gather statistics every <seconds> interval\n"));
 	fprintf(out, USAGE_SEPARATOR);
sys-utils/ipcrm.c +4 -4
index 46c2997..aa58172 100644
@@ -43,20 +43,20 @@ typedef enum type_id {
 
 static int verbose = 0;
 
-/* print the new usage */
+/* print the usage */
 static void __attribute__ ((__noreturn__)) usage(FILE * out)
 {
 	fprintf(out, USAGE_HEADER);
 	fprintf(out, " %s [options]\n", program_invocation_short_name);
-	fprintf(out, " %s <shm|msg|sem> <id> [...]\n", program_invocation_short_name);
+	fprintf(out, " %s shm|msg|sem <id>...\n", program_invocation_short_name);
 	fprintf(out, USAGE_OPTIONS);
-	fputs(_(" -m, --shmem-id <id>        remove shared memory segment by shmid\n"), out);
+	fputs(_(" -m, --shmem-id <id>        remove shared memory segment by id\n"), out);
 	fputs(_(" -M, --shmem-key <key>      remove shared memory segment by key\n"), out);
 	fputs(_(" -q, --queue-id <id>        remove message queue by id\n"), out);
 	fputs(_(" -Q, --queue-key <key>      remove message queue by key\n"), out);
 	fputs(_(" -s, --semaphore-id <id>    remove semaphore by id\n"), out);
 	fputs(_(" -S, --semaphore-key <key>  remove semaphore by key\n"), out);
-	fputs(_(" -a, --all[=<shm|msg|sem>]  remove all\n"), out);
+	fputs(_(" -a, --all[=shm|msg|sem]    remove all (in the specified category)\n"), out);
 	fputs(_(" -v, --verbose              explain what is being done\n"), out);
 	fprintf(out, USAGE_SEPARATOR);
 	fprintf(out, USAGE_HELP);
sys-utils/losetup.c +5 -5
index 85a15ac..275ae45 100644
@@ -372,18 +372,18 @@ static void usage(FILE *out)
 
 	fputs(USAGE_OPTIONS, out);
 	fputs(_(" -a, --all                     list all used devices\n"), out);
-	fputs(_(" -d, --detach <loopdev> [...]  detach one or more 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(_(" -c, --set-capacity <loopdev>  resize the 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);
-	fputs(_("     --sizelimit <num>         device limited to <num> bytes of the file\n"), out);
-	fputs(_(" -P, --partscan                create partitioned loop device\n"), out);
-	fputs(_(" -r, --read-only               setup read-only loop device\n"), out);
+	fputs(_("     --sizelimit <num>         device is limited to <num> bytes of the file\n"), out);
+	fputs(_(" -P, --partscan                create a partitioned loop device\n"), out);
+	fputs(_(" -r, --read-only               set up a read-only loop device\n"), out);
 	fputs(_("     --show                    print device name after setup (with -f)\n"), out);
 	fputs(_(" -v, --verbose                 verbose mode\n"), out);
 
text-utils/hexdump.1 +1 -1
index e48889b..624b8d3 100644
@@ -36,7 +36,7 @@
 hexdump \- display file contents in ascii, decimal, hexadecimal, or octal
 .SH SYNOPSIS
 .B hexdump
-[options] file [...]
+.RI [options] file ...
 .SH DESCRIPTION
 The
 .B hexdump
Signature · 1 line
1.7.0.4
maintainer Applied
#3 lore raw
Quoted 6 lines · Benno Schulenberg
Quoted 2 lines · Sami Kerola

You are right. That looks better. Now when you are working with this maybe the commands and other documents could be fixed in same go.

Okay, attached patch does that. The remaining "[...]" in the docs are

Applied, thanks.

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
maintainer Applied
#4 lore raw
In reply to Benno Schulenberg
Quoted 8 lines · Benno Schulenberg

The first few patches remove two duplicate includes, tweak some comments and usage strings, and normalizes another include.

The sixth patch adds a missing error message to ionice. And as the usage text of ionice recently changed, the seventh patch seizes the opportunity to slice it up, standardize its form, and improve some of the descriptions.

Quoted 6 lines

The eighth patch tries to massage the usage howto into a better grammatical shape.

Sami, there is one thing I changed: the square brackets around the three dots, as that seems pleonastic to me, and the man-pages man page suggests the bare three dots: see 'man 1 man' and search for "repeat".

Applied, thanks.

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com