Add free_stat_x() inline function.
authorWayne Davison <wayned@samba.org>
Sat, 19 Jan 2013 18:20:49 +0000 (10:20 -0800)
committerWayne Davison <wayned@samba.org>
Sat, 19 Jan 2013 18:25:18 +0000 (10:25 -0800)
generator.c
hlink.c
ifuncs.h
rsync.c

index 314122c3f222e207fae619b7e8ece4999d578e3f..b89c14598955382596dd465c3c572caf8d820245 100644 (file)
@@ -1853,14 +1853,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                        iflags |= ITEM_XNAME_FOLLOWS;
                itemize(fnamecmp, file, -1, real_ret, &real_sx, iflags, fnamecmp_type,
                        fuzzy_file ? fuzzy_file->basename : NULL);
-#ifdef SUPPORT_ACLS
-               if (preserve_acls)
-                       free_acl(&real_sx);
-#endif
-#ifdef SUPPORT_XATTRS
-               if (preserve_xattrs)
-                       free_xattr(&real_sx);
-#endif
+               free_stat_x(&real_sx);
        }
 
        if (!do_xfers) {
@@ -1908,15 +1901,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                unmake_file(back_file);
        }
 
-#ifdef SUPPORT_ACLS
-       if (preserve_acls)
-               free_acl(&sx);
-#endif
-#ifdef SUPPORT_XATTRS
-       if (preserve_xattrs)
-               free_xattr(&sx);
-#endif
-       return;
+       free_stat_x(&sx);
 }
 
 /* If we are replacing an existing hard link, symlink, device, or special file,
diff --git a/hlink.c b/hlink.c
index f192e3a35b855369e97ef52b6abf9d20b672b7f3..3ecc52bdf492f47f391ea5d409f38356ca6f5882 100644 (file)
--- a/hlink.c
+++ b/hlink.c
@@ -441,16 +441,8 @@ int hard_link_check(struct file_struct *file, int ndx, char *fname,
                                }
                        }
 #endif
-               } else {
-#ifdef SUPPORT_ACLS
-                       if (preserve_acls)
-                               free_acl(&alt_sx);
-#endif
-#ifdef SUPPORT_XATTRS
-                       if (preserve_xattrs)
-                               free_xattr(&alt_sx);
-#endif
-               }
+               } else
+                       free_stat_x(&alt_sx);
        }
 
        if (maybe_hard_link(file, ndx, fname, statret, sxp, prev_name, &prev_st,
@@ -527,14 +519,7 @@ void finish_hard_link(struct file_struct *file, const char *fname, int fin_ndx,
                val = maybe_hard_link(file, ndx, prev_name, prev_statret, &prev_sx,
                                      our_name, stp, fname, itemizing, code);
                flist->in_progress--;
-#ifdef SUPPORT_ACLS
-               if (preserve_acls)
-                       free_acl(&prev_sx);
-#endif
-#ifdef SUPPORT_XATTRS
-               if (preserve_xattrs)
-                       free_xattr(&prev_sx);
-#endif
+               free_stat_x(&prev_sx);
                if (val < 0)
                        continue;
                if (remove_source_files == 1 && do_xfers)
index 656597ec90f2fa781b0d385f092b44044fc7875c..4e031ae027c5a8ea4079375df90e1e6cc30580a5 100644 (file)
--- a/ifuncs.h
+++ b/ifuncs.h
@@ -85,3 +85,17 @@ init_stat_x(stat_x *sx_p)
        sx_p->xattr = NULL;
 #endif
 }
+
+static inline void
+free_stat_x(stat_x *sx_p)
+{
+       extern int preserve_acls, preserve_xattrs;
+#ifdef SUPPORT_ACLS
+       if (preserve_acls)
+               free_acl(sx_p);
+#endif
+#ifdef SUPPORT_XATTRS
+       if (preserve_xattrs)
+               free_xattr(sx_p);
+#endif
+}
diff --git a/rsync.c b/rsync.c
index 93f6b9880df64841ddec3343714d989514b73394..4868a19a2cd9581e71594ed5e6818fbffec56ef9 100644 (file)
--- a/rsync.c
+++ b/rsync.c
@@ -587,16 +587,8 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
                        rprintf(FCLIENT, "%s is uptodate\n", fname);
        }
   cleanup:
-       if (sxp == &sx2) {
-#ifdef SUPPORT_ACLS
-               if (preserve_acls)
-                       free_acl(&sx2);
-#endif
-#ifdef SUPPORT_XATTRS
-               if (preserve_xattrs)
-                       free_xattr(&sx2);
-#endif
-       }
+       if (sxp == &sx2)
+               free_stat_x(&sx2);
        return updated;
 }