]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_fruit: do direct return from error checks in ad_convert()
authorRalph Boehme <slow@samba.org>
Thu, 4 Oct 2018 06:23:59 +0000 (08:23 +0200)
committerKarolin Seeger <kseeger@samba.org>
Thu, 18 Oct 2018 11:00:09 +0000 (13:00 +0200)
Subsequent commits will move the mmap() into the subfunctions. This
change just prepares for that.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13649

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 8bc36d723ff41afe768f42b833aa951e1ee8fb38)

source3/modules/vfs_fruit.c

index 493bd7511a4c109ce3ba47e1518e2b1d24bd037e..87329405e71e242273f6a19b4698c1533f0cdacc 100644 (file)
@@ -1081,8 +1081,7 @@ static int ad_convert(struct adouble *ad,
        map = mmap(NULL, origlen, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
        if (map == MAP_FAILED) {
                DEBUG(2, ("mmap AppleDouble: %s\n", strerror(errno)));
-               rc = -1;
-               goto exit;
+               return -1;
        }
 
        ok = ad_convert_xattr(ad, smb_fname, map);
@@ -1106,12 +1105,18 @@ static int ad_convert(struct adouble *ad,
         */
        rc = ftruncate(fd, ad_getentryoff(ad, ADEID_RFORK)
                       + ad_getentrylen(ad, ADEID_RFORK));
-
-exit:
-       if (map != MAP_FAILED) {
+       if (rc != 0) {
                munmap(map, origlen);
+               return -1;
        }
-       return rc;
+
+       rc = munmap(map, origlen);
+       if (rc != 0) {
+               DBG_ERR("munmap failed: %s\n", strerror(errno));
+               return -1;
+       }
+
+       return 0;
 }
 
 /**