Whamcloud - gitweb
LU-5170 lfs: Standardize error messages in lfs_changelog() 65/30665/3
authorSteve Guminski <stephenx.guminski@intel.com>
Wed, 12 Jul 2017 19:00:25 +0000 (15:00 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 19 Apr 2018 04:38:20 +0000 (04:38 +0000)
Error messages in lfs_changelog() 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: Ib9229d13a6fa4e76ee407de33f181465adc879b6
Reviewed-on: https://review.whamcloud.com/30665
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: James Nunez <james.a.nunez@intel.com>
lustre/utils/lfs.c

index bddec09..4dcb8f3 100644 (file)
@@ -6259,16 +6259,18 @@ static int lfs_changelog(int argc, char **argv)
                 case 'f':
                         follow++;
                         break;
                 case 'f':
                         follow++;
                         break;
-                case '?':
-                        return CMD_HELP;
                 default:
                 default:
-                        fprintf(stderr, "error: %s: option '%s' unrecognized\n",
-                                argv[0], argv[optind - 1]);
+                       fprintf(stderr,
+                               "%s changelog: unrecognized option '%s'\n",
+                               progname, argv[optind - 1]);
                         return CMD_HELP;
                 }
         }
                         return CMD_HELP;
                 }
         }
-        if (optind >= argc)
-                return CMD_HELP;
+       if (optind >= argc) {
+               fprintf(stderr, "%s changelog: mdtname must be specified\n",
+                       progname);
+               return CMD_HELP;
+       }
 
         mdd = argv[optind++];
         if (argc > optind)
 
         mdd = argv[optind++];
         if (argc > optind)
@@ -6283,8 +6285,8 @@ static int lfs_changelog(int argc, char **argv)
                                   (follow ? CHANGELOG_FLAG_FOLLOW : 0),
                                   mdd, startrec);
        if (rc < 0) {
                                   (follow ? CHANGELOG_FLAG_FOLLOW : 0),
                                   mdd, startrec);
        if (rc < 0) {
-               fprintf(stderr, "Can't start changelog: %s\n",
-                       strerror(errno = -rc));
+               fprintf(stderr, "%s changelog: cannot start changelog: %s\n",
+                       progname, strerror(errno = -rc));
                return rc;
        }
 
                return rc;
        }
 
@@ -6294,8 +6296,9 @@ static int lfs_changelog(int argc, char **argv)
                                        CHANGELOG_EXTRA_FLAG_OMODE |
                                        CHANGELOG_EXTRA_FLAG_XATTR);
        if (rc < 0) {
                                        CHANGELOG_EXTRA_FLAG_OMODE |
                                        CHANGELOG_EXTRA_FLAG_XATTR);
        if (rc < 0) {
-               fprintf(stderr, "Can't set xflags for changelog: %s\n",
-                       strerror(errno = -rc));
+               fprintf(stderr,
+                       "%s changelog: cannot set xflags for changelog: %s\n",
+                       progname, strerror(errno = -rc));
                return rc;
        }
 
                return rc;
        }
 
@@ -6401,14 +6404,15 @@ static int lfs_changelog(int argc, char **argv)
                printf("\n");
 
                llapi_changelog_free(&rec);
                printf("\n");
 
                llapi_changelog_free(&rec);
-        }
+       }
 
 
-        llapi_changelog_fini(&changelog_priv);
+       llapi_changelog_fini(&changelog_priv);
 
 
-        if (rc < 0)
-                fprintf(stderr, "Changelog: %s\n", strerror(errno = -rc));
+       if (rc < 0)
+               fprintf(stderr, "%s changelog: cannot access changelog: %s\n",
+                       progname, strerror(errno = -rc));
 
 
-        return (rc == 1 ? 0 : rc);
+       return (rc == 1 ? 0 : rc);
 }
 
 static int lfs_changelog_clear(int argc, char **argv)
 }
 
 static int lfs_changelog_clear(int argc, char **argv)