Add free_stat_x() inline function.

This commit is contained in:
Wayne Davison
2013-01-19 10:20:49 -08:00
parent c03bb3d181
commit d42e7181d5
4 changed files with 21 additions and 45 deletions

View 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,

21
hlink.c
View File

@@ -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)

View File

@@ -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
}

12
rsync.c
View File

@@ -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;
}