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)
committerRalph Boehme <slow@samba.org>
Wed, 10 Oct 2018 20:22:13 +0000 (22:22 +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>
source3/modules/vfs_fruit.c

index 2dec90890064468a260258a5631067f75addf2b4..7d544ea7f944fdacba73d961640f483b3fff47d7 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;
 }
 
 /**