Re: [PATCH 6/7] pipesz: report default size in --help, instead of referring the user

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

 



Hello Benno Schulenberg,

    I do not think that this change is a good idea, especially in this location. If it is to be done at all, it MUST be done inside the usage() function; so that it is unlikely that future changes will introduce a read of an uninitialized global variable.
 
    However, I do not think this is a good idea in isolation, as it deprives the user of the knowledge of where the default size comes from, and additionally could cause the help message to print a warning! A path forwards that I would support is to keep the existing text but include the value read from the file as a parenthetical, if and only if the parse was successful.

    Kind regards,
        Nathan Sharp
        Principal Consultant
        Scherpzinnige Oplossingen, B.V.

________________________________________
From: Benno Schulenberg <bensberg@xxxxxxxxxx>
Sent: Thursday, April 24, 2025 11:32 AM
To: util-linux@xxxxxxxxxxxxxxx <util-linux@xxxxxxxxxxxxxxx>
Cc: Nathan Sharp <nwsharp@xxxxxxxx>
Subject: [PATCH 6/7] pipesz: report default size in --help, instead of referring the user
 
The man page says where this default size can be found.  In the --help
text it is more useful to directly say what this default size is.

CC: Nathan Sharp <nwsharp@xxxxxxxx>
Signed-off-by: Benno Schulenberg <bensberg@xxxxxxxxxx>
---
 misc-utils/pipesz.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/misc-utils/pipesz.c b/misc-utils/pipesz.c
index 48f07aed7..c317959e4 100644
--- a/misc-utils/pipesz.c
+++ b/misc-utils/pipesz.c
@@ -71,11 +71,8 @@ static void __attribute__((__noreturn__)) usage(void)
 
         fputs(USAGE_OPTIONS, stdout);
         fputsln(_(" -g, --get          examine pipe buffers"), stdout);
-       /* TRANSLATORS: '%s' refers to a system file */
         fprintf(stdout,
-            _(" -s, --set <size>   set pipe buffer sizes\n"
-              "                      size defaults to %s\n"),
-               PIPESZ_DEFAULT_SIZE_FILE);
+               _(" -s, --set <size>   the buffer size to be used (default: %u)\n"), opt_size);
 
         fputs(USAGE_SEPARATOR, stdout);
         fputsln(_(" -f, --file <path>  act on a file"), stdout);
@@ -232,6 +229,8 @@ int main(int argc, char **argv)
         while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) {
                 switch (c) {
                 case 'h':
+                       if (ul_path_read_s32(NULL, &opt_size, PIPESZ_DEFAULT_SIZE_FILE))
+                               warn(_("cannot parse %s"), PIPESZ_DEFAULT_SIZE_FILE);
                         usage();
                 case 'V':
                         print_version(EXIT_SUCCESS);
--
2.48.1





[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