]> arthur.barton.de Git - netatalk.git/commitdiff
Prevent error check macro inflation
authorFrank Lahm <franklahm@googlemail.com>
Tue, 12 Oct 2010 08:50:18 +0000 (10:50 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Tue, 12 Oct 2010 08:50:18 +0000 (10:50 +0200)
bin/ad/ad_mv.c
etc/afpd/acls.c
include/atalk/errchk.h

index 9b49c336b8c4e2c0c4641c11e02e25f2bd47870b..a02777c1d0f23b9f354c50ab274b5d0e8f294b19 100644 (file)
@@ -359,6 +359,16 @@ static int do_move(const char *from, const char *to)
         }
         free(name);
 
+        struct adouble ad;
+        ad_init(&ad, dvolume.volinfo.v_adouble, dvolume.volinfo.v_ad_options);
+        if (ad_open_metadata(to, S_ISDIR(sb.st_mode) ? ADFLAGS_DIR : 0, O_RDWR, &ad) != 0) {
+            SLOG("Error opening adouble for: %s", to);
+            return 1;
+        }
+        ad_setid(&ad, sb.st_dev, sb.st_ino, cnid, newdid, dvolume.db_stamp);
+        ad_flush(&ad);
+        ad_close_metadata(&ad);
+
         if (vflg)
             printf("%s -> %s\n", from, to);
         return (0);
@@ -492,7 +502,9 @@ static int copy(const char *from, const char *to)
         execl(adexecp, "cp", vflg ? "-Rpv" : "-Rp", "--", from, to, (char *)NULL);
         _exit(1);
     }
-    if (waitpid(pid, &status, 0) == -1) {
+    while ((waitpid(pid, &status, 0)) == -1) {
+        if (errno == EINTR)
+            continue;
         SLOG("%s %s %s: waitpid: %s", adexecp, from, to, strerror(errno));
         return (1);
     }
@@ -504,7 +516,7 @@ static int copy(const char *from, const char *to)
     case 0:
         break;
     default:
-        SLOG("%s %s %s: terminated with %d (non-zero) status",
+        SLOG("%s cp %s %s: terminated with %d (non-zero) status",
               adexecp, from, to, WEXITSTATUS(status));
         return (1);
     }
@@ -514,19 +526,21 @@ static int copy(const char *from, const char *to)
         execl(adexecp, "rm", "-Rf", "--", from, (char *)NULL);
         _exit(1);
     }
-    if (waitpid(pid, &status, 0) == -1) {
-        SLOG("%s %s: waitpid: %s", adexecp, from, strerror(errno));
+    while ((waitpid(pid, &status, 0)) == -1) {
+        if (errno == EINTR)
+            continue;
+        SLOG("%s rm %s: waitpid: %s", adexecp, from, strerror(errno));
         return (1);
     }
     if (!WIFEXITED(status)) {
-        SLOG("%s %s: did not terminate normally", adexecp, from);
+        SLOG("%s rm %s: did not terminate normally", adexecp, from);
         return (1);
     }
     switch (WEXITSTATUS(status)) {
     case 0:
         break;
     default:
-        SLOG("%s %s: terminated with %d (non-zero) status",
+        SLOG("%s rm %s: terminated with %d (non-zero) status",
               adexecp, from, WEXITSTATUS(status));
         return (1);
     }
index d48163af869cfe5dd7da6398e0ee584445ee4811..45d96f32627490802b6265f92dddb66d30a52290 100644 (file)
@@ -905,10 +905,10 @@ static int set_acl(const struct vol *vol,
     LOG(log_debug7, logtype_afpd, "set_acl: copied %d inherited ACEs", new_aces_count);
 
     /* Now the ACEs from the client */
-    if (EC_NEG1_CUSTOM(map_acl(DARWIN_2_SOLARIS,
-                               &new_aces[new_aces_count],
-                               daces,
-                               ace_count))) {
+    if ((ret = (map_acl(DARWIN_2_SOLARIS,
+                        &new_aces[new_aces_count],
+                        daces,
+                        ace_count))) == -1) {
         EC_STATUS(AFPERR_PARAM);
         goto EC_CLEANUP;
     }
@@ -928,7 +928,7 @@ static int set_acl(const struct vol *vol,
     /* Ressourcefork first.
        Note: for dirs we set the same ACL on the .AppleDouble/.Parent _file_. This
        might be strange for ACE_DELETE_CHILD and for inheritance flags. */
-    if (EC_ZERO_CUSTOM(vol->vfs->vfs_acl(vol, name, ACE_SETACL, new_aces_count, new_aces))) {
+    if ((ret = (vol->vfs->vfs_acl(vol, name, ACE_SETACL, new_aces_count, new_aces))) != 0) {
         LOG(log_error, logtype_afpd, "set_acl: error setting acl: %s", strerror(errno));
         if (errno == (EACCES | EPERM))
             EC_STATUS(AFPERR_ACCESS);
@@ -938,7 +938,7 @@ static int set_acl(const struct vol *vol,
             EC_STATUS(AFPERR_MISC);
         goto EC_CLEANUP;
     }
-    if (EC_ZERO_CUSTOM(acl(name, ACE_SETACL, new_aces_count, new_aces))) {
+    if ((ret = (acl(name, ACE_SETACL, new_aces_count, new_aces)) != 0) {
         LOG(log_error, logtype_afpd, "set_acl: error setting acl: %s", strerror(errno));
         if (errno == (EACCES | EPERM))
             EC_STATUS(AFPERR_ACCESS);
index 510c73a56269e590d7409472ce9b360be6c4b928..6dae929a2010c5541310e1f591d008ac86cb9164 100644 (file)
@@ -79,9 +79,6 @@
         }                                       \
     } while (0)
 
-#define EC_ZERO_CUSTOM(a) \
-    (ret = (a)) != 0
-
 /* check for return val 0 which is ok, every other is an error, prints errno */
 #define EC_NEG1_LOG(a) \
     do { \
         } \
     } while (0)
 
-#define EC_NEG1_CUSTOM(a) \
-    (ret = (a)) == -1
-
 /* check for return val != NULL, prints errno */
 #define EC_NULL_LOG(a) \
     do { \
         } \
     } while (0)
 
-#define EC_NULL_CUSTOM(a) \
-    (ret = (a)) == NULL
-
 #endif /* ERRCHECK_H */