Whamcloud - gitweb
LU-5170 lfs: Standardize error messages in macros 50/28250/2
authorSteve Guminski <stephenx.guminski@intel.com>
Wed, 12 Jul 2017 14:46:33 +0000 (10:46 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 1 Dec 2017 05:15:52 +0000 (05:15 +0000)
Error messages in ARG2INT() and ARG2ULL() are updated to a standard
format.  Messages are prefixed with the name of the utility and the
command that caused the error.  User-provided values are delimited
with single quotes.

Test-Parameters: trivial
Signed-off-by: Steve Guminski <stephenx.guminski@intel.com>
Change-Id: I31a0a30ac15681826e7e25b8a44d56174fb23e08
Reviewed-on: https://review.whamcloud.com/28250
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
lustre/utils/lfs.c

index ac201eb..dac8589 100644 (file)
@@ -3570,12 +3570,13 @@ static int lfs_check(int argc, char **argv)
 #ifdef HAVE_SYS_QUOTA_H
 #define ARG2INT(nr, str, msg)                                           \
 do {                                                                    \
-        char *endp;                                                     \
-        nr = strtol(str, &endp, 0);                                     \
-        if (*endp) {                                                    \
-                fprintf(stderr, "error: bad %s: %s\n", msg, str);       \
-                return CMD_HELP;                                        \
-        }                                                               \
+       char *endp;                                                     \
+       nr = strtol(str, &endp, 0);                                     \
+       if (*endp != '\0') {                                            \
+               fprintf(stderr, "%s: bad %s '%s'\n",                    \
+                       progname, msg, str);                            \
+               return CMD_HELP;                                        \
+       }                                                               \
 } while (0)
 
 #define ADD_OVERFLOW(a,b) ((a + b) < a) ? (a = ULONG_MAX) : (a = a + b)
@@ -3644,7 +3645,8 @@ do {                                                                      \
                                                                        \
        rc = llapi_parse_size(str, &limit, &units, 1);                  \
        if (rc < 0) {                                                   \
-               fprintf(stderr, "error: bad limit value %s\n", str);    \
+               fprintf(stderr, "%s: bad limit '%s'\n",                 \
+                       progname, str);                                 \
                return CMD_HELP;                                        \
        }                                                               \
        nr = limit;                                                     \