]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hardlink: use err() if possible
authorKarel Zak <kzak@redhat.com>
Thu, 4 Feb 2021 12:14:51 +0000 (13:14 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 17 Feb 2021 10:50:21 +0000 (11:50 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/hardlink.c

index 87201b17314a33c211439971f68797db4a6e8a18..bf3e1a16f8de19f3c5477cbd1422cf8e03c86459 100644 (file)
@@ -367,10 +367,9 @@ static ssize_t llistxattr_or_die(const char *path, char *list, size_t size)
 {
     ssize_t len = llistxattr(path, list, size);
 
-    if (len < 0 && errno != ENOTSUP) {
-        jlog(JLOG_SYSFAT, "Cannot get xattr names for %s", path);
-        exit(1);
-    }
+    if (len < 0 && errno != ENOTSUP)
+       err(EXIT_FAILURE, _("cannot get xattr names for %s"), path);
+
     return len;
 }
 
@@ -384,10 +383,9 @@ static ssize_t lgetxattr_or_die(const char *path, const char *name, void *value,
 {
     ssize_t len = lgetxattr(path, name, value, size);
 
-    if (len < 0) {
-        jlog(JLOG_SYSFAT, "Cannot get xattr value of %s for %s", name, path);
-        exit(1);
-    }
+    if (len < 0)
+        err(EXIT_FAILURE, _("cannot get xattr value of %s for %s"), name, path);
+
     return len;
 }
 
@@ -855,13 +853,13 @@ static void visitor(const void *nodep, const VISIT which, const int depth)
 
     for (; master != NULL; master = master->next) {
         if (handle_interrupt())
-            exit(1);
+            exit(EXIT_FAILURE);
         if (master->links == NULL)
             continue;
 
         for (other = master->next; other != NULL; other = other->next) {
             if (handle_interrupt())
-                exit(1);
+                exit(EXIT_FAILURE);
 
             assert(other != other->next);
             assert(other->st.st_size == master->st.st_size);
@@ -1074,18 +1072,14 @@ int main(int argc, char *argv[])
     setlocale(LC_NUMERIC, "");
     stats.start_time = gettime();
 
-    if (atexit(to_be_called_atexit) != 0) {
-        jlog(JLOG_SYSFAT, "Cannot register exit handler");
-        return 1;
-    }
+    if (atexit(to_be_called_atexit) != 0)
+        err(EXIT_FAILURE, _("cannot register exit handler"));
 
     if (parse_options(argc, argv) != 0)
         return 1;
 
-    if (optind == argc) {
-        jlog(JLOG_FATAL, "Expected file or directory names");
-        return 1;
-    }
+    if (optind == argc)
+       errx(EXIT_FAILURE, _("no directory of dile specified"));
 
     stats.started = TRUE;