Some indentation fixes.

This commit is contained in:
Wayne Davison
2020-06-13 18:19:12 -07:00
parent 8a70f1420b
commit e63ff70eae
30 changed files with 201 additions and 289 deletions

View File

@@ -2,7 +2,7 @@
* Routines to authenticate access to a daemon (hosts allow/deny).
*
* Copyright (C) 1998 Andrew Tridgell
* Copyright (C) 2004-2019 Wayne Davison
* Copyright (C) 2004-2020 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -158,8 +158,7 @@ static int match_address(const char *addr, const char *tok)
break;
#ifdef INET6
case PF_INET6:
{
case PF_INET6: {
struct sockaddr_in6 *sin6a, *sin6t;
sin6a = (struct sockaddr_in6 *)resa->ai_addr;
@@ -171,20 +170,19 @@ static int match_address(const char *addr, const char *tok)
addrlen = 16;
#ifdef HAVE_SOCKADDR_IN6_SCOPE_ID
if (sin6t->sin6_scope_id &&
sin6a->sin6_scope_id != sin6t->sin6_scope_id) {
if (sin6t->sin6_scope_id && sin6a->sin6_scope_id != sin6t->sin6_scope_id) {
ret = 0;
goto out;
}
#endif
break;
}
}
#endif
default:
rprintf(FLOG, "unknown family %u\n", rest->ai_family);
ret = 0;
goto out;
rprintf(FLOG, "unknown family %u\n", rest->ai_family);
ret = 0;
goto out;
}
bits = -1;

15
acls.c
View File

@@ -332,14 +332,12 @@ static BOOL unpack_smb_acl(SMB_ACL_T sacl, rsync_acl *racl)
if (temp_ida_list.count) {
#ifdef SMB_ACL_NEED_SORT
if (temp_ida_list.count > 1) {
qsort(temp_ida_list.items, temp_ida_list.count,
sizeof (id_access), id_access_sorter);
qsort(temp_ida_list.items, temp_ida_list.count, sizeof (id_access), id_access_sorter);
}
#endif
if (!(racl->names.idas = new_array(id_access, temp_ida_list.count)))
out_of_memory("unpack_smb_acl");
memcpy(racl->names.idas, temp_ida_list.items,
temp_ida_list.count * sizeof (id_access));
memcpy(racl->names.idas, temp_ida_list.items, temp_ida_list.count * sizeof (id_access));
} else
racl->names.idas = NULL;
@@ -825,14 +823,12 @@ void cache_tmp_acl(struct file_struct *file, stat_x *sxp)
if (prior_access_count == (size_t)-1)
prior_access_count = access_acl_list.count;
F_ACL(file) = cache_rsync_acl(sxp->acc_acl,
SMB_ACL_TYPE_ACCESS, &access_acl_list);
F_ACL(file) = cache_rsync_acl(sxp->acc_acl, SMB_ACL_TYPE_ACCESS, &access_acl_list);
if (S_ISDIR(sxp->st.st_mode)) {
if (prior_default_count == (size_t)-1)
prior_default_count = default_acl_list.count;
F_DIR_DEFACL(file) = cache_rsync_acl(sxp->def_acl,
SMB_ACL_TYPE_DEFAULT, &default_acl_list);
F_DIR_DEFACL(file) = cache_rsync_acl(sxp->def_acl, SMB_ACL_TYPE_DEFAULT, &default_acl_list);
}
}
@@ -996,8 +992,7 @@ static int set_rsync_acl(const char *fname, acl_duo *duo_item,
mode = 0; /* eliminate compiler warning */
#else
if (type == SMB_ACL_TYPE_ACCESS) {
cur_mode = change_sacl_perms(duo_item->sacl, &duo_item->racl,
cur_mode, mode);
cur_mode = change_sacl_perms(duo_item->sacl, &duo_item->racl, cur_mode, mode);
if (cur_mode == (mode_t)-1)
return 0;
}

View File

@@ -289,9 +289,9 @@ void write_batch_shell_file(void)
if (!(p = raw_argv[i]))
continue;
if (strncmp(p, "--files-from", 12) == 0
|| strncmp(p, "--filter", 8) == 0
|| strncmp(p, "--include", 9) == 0
|| strncmp(p, "--exclude", 9) == 0) {
|| strncmp(p, "--filter", 8) == 0
|| strncmp(p, "--include", 9) == 0
|| strncmp(p, "--exclude", 9) == 0) {
if (strchr(p, '=') == NULL)
i++;
continue;

View File

@@ -172,11 +172,11 @@ NORETURN void _exit_cleanup(int code, const char *file, int line)
const char *fname = cleanup_fname;
cleanup_fname = NULL;
if (!partial_dir) {
/* We don't want to leave a partial file with a modern time or it
* could be skipped via --update. Setting the time to something
* really old also helps it to stand out as unfinished in an ls. */
tweak_modtime = 1;
cleanup_file->modtime = 0;
/* We don't want to leave a partial file with a modern time or it
* could be skipped via --update. Setting the time to something
* really old also helps it to stand out as unfinished in an ls. */
tweak_modtime = 1;
cleanup_file->modtime = 0;
}
finish_transfer(cleanup_new_fname, fname, NULL, NULL,
cleanup_file, tweak_modtime, !partial_dir);

View File

@@ -325,8 +325,8 @@ static void client_sockaddr(int fd, struct sockaddr_storage *ss, socklen_t *ss_l
}
#ifdef INET6
if (GET_SOCKADDR_FAMILY(ss) == AF_INET6 &&
IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)ss)->sin6_addr)) {
if (GET_SOCKADDR_FAMILY(ss) == AF_INET6
&& IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)ss)->sin6_addr)) {
/* OK, so ss is in the IPv6 family, but it is really
* an IPv4 address: something like
* "::ffff:10.130.1.2". If we use it as-is, then the
@@ -349,8 +349,7 @@ static void client_sockaddr(int fd, struct sockaddr_storage *ss, socklen_t *ss_l
/* There is a macro to extract the mapped part
* (IN6_V4MAPPED_TO_SINADDR ?), but it does not seem
* to be present in the Linux headers. */
memcpy(&sin->sin_addr, &sin6.sin6_addr.s6_addr[12],
sizeof sin->sin_addr);
memcpy(&sin->sin_addr, &sin6.sin6_addr.s6_addr[12], sizeof sin->sin_addr);
}
#endif
}
@@ -379,8 +378,7 @@ static int compare_addrinfo_sockaddr(const struct addrinfo *ai, const struct soc
sin1 = (const struct sockaddr_in *) ss;
sin2 = (const struct sockaddr_in *) ai->ai_addr;
return memcmp(&sin1->sin_addr, &sin2->sin_addr,
sizeof sin1->sin_addr);
return memcmp(&sin1->sin_addr, &sin2->sin_addr, sizeof sin1->sin_addr);
}
#ifdef INET6
@@ -396,8 +394,7 @@ static int compare_addrinfo_sockaddr(const struct addrinfo *ai, const struct soc
return 1;
}
if (memcmp(&sin1->sin6_addr, &sin2->sin6_addr,
sizeof sin1->sin6_addr))
if (memcmp(&sin1->sin6_addr, &sin2->sin6_addr, sizeof sin1->sin6_addr))
return 1;
#ifdef HAVE_SOCKADDR_IN6_SCOPE_ID

View File

@@ -123,8 +123,7 @@ int start_socket_client(char *host, int remote_argc, char *remote_argv[],
*p = '\0';
}
fd = open_socket_out_wrapped(host, rsync_port, bind_address,
default_af_hint);
fd = open_socket_out_wrapped(host, rsync_port, bind_address, default_af_hint);
if (fd == -1)
exit_cleanup(RERR_SOCKETIO);
@@ -755,24 +754,24 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
p = lp_filter(i);
parse_filter_str(&daemon_filter_list, p, rule_template(FILTRULE_WORD_SPLIT),
XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3);
XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3);
p = lp_include_from(i);
parse_filter_file(&daemon_filter_list, p, rule_template(FILTRULE_INCLUDE),
XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3 | XFLG_OLD_PREFIXES | XFLG_FATAL_ERRORS);
XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3 | XFLG_OLD_PREFIXES | XFLG_FATAL_ERRORS);
p = lp_include(i);
parse_filter_str(&daemon_filter_list, p,
rule_template(FILTRULE_INCLUDE | FILTRULE_WORD_SPLIT),
XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3 | XFLG_OLD_PREFIXES);
rule_template(FILTRULE_INCLUDE | FILTRULE_WORD_SPLIT),
XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3 | XFLG_OLD_PREFIXES);
p = lp_exclude_from(i);
parse_filter_file(&daemon_filter_list, p, rule_template(0),
XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3 | XFLG_OLD_PREFIXES | XFLG_FATAL_ERRORS);
XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3 | XFLG_OLD_PREFIXES | XFLG_FATAL_ERRORS);
p = lp_exclude(i);
parse_filter_str(&daemon_filter_list, p, rule_template(FILTRULE_WORD_SPLIT),
XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3 | XFLG_OLD_PREFIXES);
XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3 | XFLG_OLD_PREFIXES);
log_init(1);
@@ -996,8 +995,7 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
limit_output_verbosity(lp_max_verbosity(i));
#endif
if (protocol_version < 23
&& (protocol_version == 22 || am_sender))
if (protocol_version < 23 && (protocol_version == 22 || am_sender))
io_start_multiplex_out(f_out);
else if (!ret || err_msg) {
/* We have to get I/O multiplexing started so that we can

View File

@@ -531,16 +531,16 @@ void setup_protocol(int f_out,int f_in)
append_mode = 2;
if (preserve_acls && !local_server) {
rprintf(FERROR,
"--acls requires protocol 30 or higher"
" (negotiated %d).\n",
protocol_version);
"--acls requires protocol 30 or higher"
" (negotiated %d).\n",
protocol_version);
exit_cleanup(RERR_PROTOCOL);
}
if (preserve_xattrs && !local_server) {
rprintf(FERROR,
"--xattrs requires protocol 30 or higher"
" (negotiated %d).\n",
protocol_version);
"--xattrs requires protocol 30 or higher"
" (negotiated %d).\n",
protocol_version);
exit_cleanup(RERR_PROTOCOL);
}
}
@@ -555,33 +555,33 @@ void setup_protocol(int f_out,int f_in)
if (protocol_version < 29) {
if (fuzzy_basis) {
rprintf(FERROR,
"--fuzzy requires protocol 29 or higher"
" (negotiated %d).\n",
protocol_version);
"--fuzzy requires protocol 29 or higher"
" (negotiated %d).\n",
protocol_version);
exit_cleanup(RERR_PROTOCOL);
}
if (basis_dir_cnt && inplace) {
rprintf(FERROR,
"%s with --inplace requires protocol 29 or higher"
" (negotiated %d).\n",
alt_dest_opt(0), protocol_version);
"%s with --inplace requires protocol 29 or higher"
" (negotiated %d).\n",
alt_dest_opt(0), protocol_version);
exit_cleanup(RERR_PROTOCOL);
}
if (basis_dir_cnt > 1) {
rprintf(FERROR,
"Using more than one %s option requires protocol"
" 29 or higher (negotiated %d).\n",
alt_dest_opt(0), protocol_version);
"Using more than one %s option requires protocol"
" 29 or higher (negotiated %d).\n",
alt_dest_opt(0), protocol_version);
exit_cleanup(RERR_PROTOCOL);
}
if (prune_empty_dirs) {
rprintf(FERROR,
"--prune-empty-dirs requires protocol 29 or higher"
" (negotiated %d).\n",
protocol_version);
"--prune-empty-dirs requires protocol 29 or higher"
" (negotiated %d).\n",
protocol_version);
exit_cleanup(RERR_PROTOCOL);
}
} else if (protocol_version >= 30) {
@@ -640,8 +640,8 @@ void setup_protocol(int f_out,int f_in)
if (inc_recurse && !allow_inc_recurse) {
/* This should only be able to happen in a batch. */
fprintf(stderr,
"Incompatible options specified for inc-recursive %s.\n",
read_batch ? "batch file" : "connection");
"Incompatible options specified for inc-recursive %s.\n",
read_batch ? "batch file" : "connection");
exit_cleanup(RERR_SYNTAX);
}
use_safe_inc_flist = (compat_flags & CF_SAFE_FLIST) || protocol_version >= 31;

View File

@@ -4,7 +4,7 @@
* Copyright (C) 1996-2000 Andrew Tridgell
* Copyright (C) 1996 Paul Mackerras
* Copyright (C) 2002 Martin Pool <mbp@samba.org>
* Copyright (C) 2003-2019 Wayne Davison
* Copyright (C) 2003-2020 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -89,8 +89,8 @@ static enum delret delete_dir_contents(char *fname, uint16 flags)
if (fp->flags & FLAG_MOUNT_DIR && S_ISDIR(fp->mode)) {
if (DEBUG_GTE(DEL, 1)) {
rprintf(FINFO,
"mount point, %s, pins parent directory\n",
f_name(fp, NULL));
"mount point, %s, pins parent directory\n",
f_name(fp, NULL));
}
ret = DR_NOT_EMPTY;
continue;

View File

@@ -4,7 +4,7 @@
* Copyright (C) 1996-2001 Andrew Tridgell <tridge@samba.org>
* Copyright (C) 1996 Paul Mackerras
* Copyright (C) 2002 Martin Pool
* Copyright (C) 2003-2019 Wayne Davison
* Copyright (C) 2003-2020 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1406,8 +1406,7 @@ void recv_filter_list(int f_in)
char line[BIGPATHBUFLEN];
int xflags = protocol_version >= 29 ? 0 : XFLG_OLD_PREFIXES;
int receiver_wants_list = prune_empty_dirs
|| (delete_mode
&& (!delete_excluded || protocol_version >= 29));
|| (delete_mode && (!delete_excluded || protocol_version >= 29));
unsigned int len;
if (!local_server && (am_sender || receiver_wants_list)) {

View File

@@ -171,10 +171,8 @@ static int remember_delete(struct file_struct *file, const char *fname, int flag
deldelay_buf[deldelay_cnt++] = '!';
while (1) {
len = snprintf(deldelay_buf + deldelay_cnt,
deldelay_size - deldelay_cnt,
"%x %s%c",
(int)file->mode, fname, '\0');
len = snprintf(deldelay_buf + deldelay_cnt, deldelay_size - deldelay_cnt,
"%x %s%c", (int)file->mode, fname, '\0');
if ((deldelay_cnt += len) <= deldelay_size)
break;
deldelay_cnt -= len;
@@ -211,8 +209,7 @@ static int read_delay_line(char *buf, int *flags_p)
deldelay_size - deldelay_cnt);
if (len == 0) {
if (deldelay_cnt) {
rprintf(FERROR,
"ERROR: unexpected EOF in delete-delay file.\n");
rprintf(FERROR, "ERROR: unexpected EOF in delete-delay file.\n");
}
return -1;
}
@@ -528,8 +525,7 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
iflags |= ITEM_REPORT_PERMS;
if (uid_ndx && am_root && (uid_t)F_OWNER(file) != sxp->st.st_uid)
iflags |= ITEM_REPORT_OWNER;
if (gid_ndx && !(file->flags & FLAG_SKIP_GROUP)
&& sxp->st.st_gid != (gid_t)F_GROUP(file))
if (gid_ndx && !(file->flags & FLAG_SKIP_GROUP) && sxp->st.st_gid != (gid_t)F_GROUP(file))
iflags |= ITEM_REPORT_GROUP;
#ifdef SUPPORT_ACLS
if (preserve_acls && !S_ISLNK(file->mode)) {
@@ -648,14 +644,14 @@ static void sum_sizes_sqroot(struct sum_struct *sum, int64 len)
if (c < 0 || c >= max_blength)
blength = max_blength;
else {
blength = 0;
do {
blength |= c;
if (len < (int64)blength * blength)
blength &= ~c;
c >>= 1;
} while (c >= 8); /* round to multiple of 8 */
blength = MAX(blength, BLOCK_SIZE);
blength = 0;
do {
blength |= c;
if (len < (int64)blength * blength)
blength &= ~c;
c >>= 1;
} while (c >= 8); /* round to multiple of 8 */
blength = MAX(blength, BLOCK_SIZE);
}
}
@@ -1415,12 +1411,10 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
if (file->flags & FLAG_DIR_CREATED)
statret = -1;
if (!preserve_perms) { /* See comment in non-dir code below. */
file->mode = dest_mode(file->mode, sx.st.st_mode,
dflt_perms, statret == 0);
file->mode = dest_mode(file->mode, sx.st.st_mode, dflt_perms, statret == 0);
}
if (statret != 0 && basis_dir[0] != NULL) {
int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &sx,
itemizing, code);
int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &sx, itemizing, code);
if (j == -2) {
itemizing = 0;
code = FNONE;
@@ -1442,8 +1436,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
"recv_generator: mkdir %s failed",
full_fname(fname));
skipping_dir_contents:
rprintf(FERROR,
"*** Skipping any contents from this failed directory ***\n");
rprintf(FERROR, "*** Skipping any contents from this failed directory ***\n");
skip_dir = file;
file->flags |= FLAG_MISSING_DIR;
goto cleanup;
@@ -1455,7 +1448,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
copy_xattrs(fnamecmpbuf, fname);
#endif
if (set_file_attrs(fname, file, real_ret ? NULL : &real_sx, NULL, 0)
&& INFO_GTE(NAME, 1) && code != FNONE && f_out != -1)
&& INFO_GTE(NAME, 1) && code != FNONE && f_out != -1)
rprintf(code, "%s/\n", fname);
/* We need to ensure that the dirs in the transfer have both
@@ -1498,8 +1491,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
* mode based on the local permissions and some heuristics. */
if (!preserve_perms) {
int exists = statret == 0 && !S_ISDIR(sx.st.st_mode);
file->mode = dest_mode(file->mode, sx.st.st_mode, dflt_perms,
exists);
file->mode = dest_mode(file->mode, sx.st.st_mode, dflt_perms, exists);
}
#ifdef SUPPORT_HARD_LINKS
@@ -1544,8 +1536,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
goto cleanup;
}
} else if (basis_dir[0] != NULL) {
int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &sx,
itemizing, code);
int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &sx, itemizing, code);
if (j == -2) {
#ifndef CAN_HARDLINK_SYMLINK
if (alt_dest_type == LINK_DEST) {
@@ -1620,8 +1611,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
goto cleanup;
}
} else if (basis_dir[0] != NULL) {
int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &sx,
itemizing, code);
int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &sx, itemizing, code);
if (j == -2) {
#ifndef CAN_HARDLINK_SPECIAL
if (alt_dest_type == LINK_DEST) {
@@ -1704,8 +1694,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
}
if (basis_dir[0] != NULL && (statret != 0 || alt_dest_type != COPY_DEST)) {
int j = try_dests_reg(file, fname, ndx, fnamecmpbuf, &sx,
statret == 0, itemizing, code);
int j = try_dests_reg(file, fname, ndx, fnamecmpbuf, &sx, statret == 0, itemizing, code);
if (j == -2) {
if (remove_source_files == 1)
goto return_with_success;
@@ -1723,8 +1712,8 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
real_ret = statret;
if (partial_dir && (partialptr = partial_dir_fname(fname)) != NULL
&& link_stat(partialptr, &partial_st, 0) == 0
&& S_ISREG(partial_st.st_mode)) {
&& link_stat(partialptr, &partial_st, 0) == 0
&& S_ISREG(partial_st.st_mode)) {
if (statret != 0)
goto prepare_to_open;
} else
@@ -1931,8 +1920,8 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
} else {
if (generate_and_send_sums(fd, sx.st.st_size, f_out, f_copy) < 0) {
rprintf(FWARNING,
"WARNING: file is too large for checksum sending: %s\n",
fnamecmp);
"WARNING: file is too large for checksum sending: %s\n",
fnamecmp);
write_sum_head(f_out, NULL);
}
close(fd);

View File

@@ -15,8 +15,7 @@
fprintf(stderr, "Unable to stat `%s'\n", *argv);
exit(1);
}
printf("%ld/%ld\n", (long)major(st.st_dev),
(long)minor(st.st_dev));
printf("%ld/%ld\n", (long)major(st.st_dev), (long)minor(st.st_dev));
}
return 0;

View File

@@ -75,9 +75,8 @@ struct ht_int64_node *idev_find(int64 dev, int64 ino)
if (dev_node->data == data_when_new) {
dev_node->data = hashtable_create(512, HT_KEY64);
if (DEBUG_GTE(HLINK, 3)) {
rprintf(FINFO,
"[%s] created hashtable for dev %s\n",
who_am_i(), big_num(dev));
rprintf(FINFO, "[%s] created hashtable for dev %s\n",
who_am_i(), big_num(dev));
}
}
}
@@ -118,8 +117,7 @@ static void match_gnums(int32 *ndx_list, int ndx_count)
struct ht_int32_node *node = NULL;
int32 gnum, gnum_next;
qsort(ndx_list, ndx_count, sizeof ndx_list[0],
(int (*)()) hlink_compare_gnum);
qsort(ndx_list, ndx_count, sizeof ndx_list[0], (int (*)()) hlink_compare_gnum);
for (from = 0; from < ndx_count; from++) {
file = hlink_flist->sorted[ndx_list[from]];

3
io.c
View File

@@ -1122,8 +1122,7 @@ static void check_for_d_option_error(const char *msg)
}
if (saw_d) {
rprintf(FWARNING,
"*** Try using \"--old-d\" if remote rsync is <= 2.6.3 ***\n");
rprintf(FWARNING, "*** Try using \"--old-d\" if remote rsync is <= 2.6.3 ***\n");
}
}

5
log.c
View File

@@ -696,7 +696,7 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
}
n = c = buf2 + MAXPATHLEN - 32;
c[0] = iflags & ITEM_LOCAL_CHANGE
? iflags & ITEM_XNAME_FOLLOWS ? 'h' : 'c'
? iflags & ITEM_XNAME_FOLLOWS ? 'h' : 'c'
: !(iflags & ITEM_TRANSFER) ? '.'
: !local_server && *op == 's' ? '<' : '>';
if (S_ISLNK(file->mode)) {
@@ -815,8 +815,7 @@ void log_item(enum logcode code, struct file_struct *file, int iflags, const cha
log_formatted(FLOG, logfile_format, s_or_r, file, NULL, iflags, hlink);
}
void maybe_log_item(struct file_struct *file, int iflags, int itemizing,
const char *buf)
void maybe_log_item(struct file_struct *file, int iflags, int itemizing, const char *buf)
{
int significant_flags = iflags & SIGNIFICANT_ITEM_FLAGS;
int see_item = itemizing && (significant_flags || *buf

37
main.c
View File

@@ -525,8 +525,8 @@ static pid_t do_cmd(char *cmd, char *machine, char *user, char **remote_argv, in
if (!*f) {
if (in_quote) {
rprintf(FERROR,
"Missing trailing-%c in remote-shell command.\n",
in_quote);
"Missing trailing-%c in remote-shell command.\n",
in_quote);
exit_cleanup(RERR_SYNTAX);
}
f--;
@@ -685,7 +685,7 @@ static char *get_local_name(struct file_list *flist, char *dest_path)
/* Treat an empty string as a copy into the current directory. */
if (!*dest_path)
dest_path = ".";
dest_path = ".";
if (daemon_filter_list.head) {
char *slash = strrchr(dest_path, '/');
@@ -746,8 +746,7 @@ static char *get_local_name(struct file_list *flist, char *dest_path)
*cp = '\0';
if (statret == 0) {
rprintf(FERROR,
"ERROR: destination path is not a directory\n");
rprintf(FERROR, "ERROR: destination path is not a directory\n");
exit_cleanup(RERR_SYNTAX);
}
@@ -821,15 +820,15 @@ static void check_alt_basis_dirs(void)
if (!new)
out_of_memory("check_alt_basis_dirs");
if (slash && strncmp(bdir, "../", 3) == 0) {
/* We want to remove only one leading "../" prefix for
* the directory we couldn't create in dry-run mode:
* this ensures that any other ".." references get
* evaluated the same as they would for a live copy. */
*slash = '\0';
pathjoin(new, len, curr_dir, bdir + 3);
*slash = '/';
/* We want to remove only one leading "../" prefix for
* the directory we couldn't create in dry-run mode:
* this ensures that any other ".." references get
* evaluated the same as they would for a live copy. */
*slash = '\0';
pathjoin(new, len, curr_dir, bdir + 3);
*slash = '/';
} else
pathjoin(new, len, curr_dir, bdir);
pathjoin(new, len, curr_dir, bdir);
basis_dir[j] = bdir = new;
}
if (do_stat(bdir, &st) < 0)
@@ -1169,8 +1168,7 @@ static void do_server_recv(int f_in, int f_out, int argc, char *argv[])
if (partial_dir && *partial_dir == '/'
&& check_filter(elp, FLOG, partial_dir + module_dirlen, 1) < 0) {
options_rejected:
rprintf(FERROR,
"Your options have been rejected by the server.\n");
rprintf(FERROR, "Your options have been rejected by the server.\n");
exit_cleanup(RERR_SYNTAX);
}
}
@@ -1389,8 +1387,7 @@ static int start_client(int argc, char *argv[])
remote_argc--; /* don't count dest */
argc = 1;
}
if (filesfrom_host && *filesfrom_host
&& strcmp(filesfrom_host, shell_machine) != 0) {
if (filesfrom_host && *filesfrom_host && strcmp(filesfrom_host, shell_machine) != 0) {
rprintf(FERROR,
"--files-from hostname is not the same as the transfer hostname\n");
exit_cleanup(RERR_SYNTAX);
@@ -1412,8 +1409,7 @@ static int start_client(int argc, char *argv[])
remote_argc = 1;
path = check_for_hostspec(p, &shell_machine, &rsync_port);
if (path && filesfrom_host && *filesfrom_host
&& strcmp(filesfrom_host, shell_machine) != 0) {
if (path && filesfrom_host && *filesfrom_host && strcmp(filesfrom_host, shell_machine) != 0) {
rprintf(FERROR,
"--files-from hostname is not the same as the transfer hostname\n");
exit_cleanup(RERR_SYNTAX);
@@ -1528,8 +1524,7 @@ static int start_client(int argc, char *argv[])
set_env_num("RSYNC_PORT", env_port);
#endif
pid = do_cmd(shell_cmd, shell_machine, shell_user, remote_argv, remote_argc,
&f_in, &f_out);
pid = do_cmd(shell_cmd, shell_machine, shell_user, remote_argv, remote_argc, &f_in, &f_out);
/* if we're running an rsync server on the remote host over a
* remote shell command, we need to do the RSYNCD protocol first */

18
match.c
View File

@@ -3,7 +3,7 @@
*
* Copyright (C) 1996 Andrew Tridgell
* Copyright (C) 1996 Paul Mackerras
* Copyright (C) 2003-2019 Wayne Davison
* Copyright (C) 2003-2020 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -102,8 +102,7 @@ static OFF_T last_match;
* If i >= 0, the number of a matched token. If < 0, indicates we have
* only literal data. A -1 will send a 0-token-int too, and a -2 sends
* only literal data, w/o any token-int. */
static void matched(int f, struct sum_struct *s, struct map_struct *buf,
OFF_T offset, int32 i)
static void matched(int f, struct sum_struct *s, struct map_struct *buf, OFF_T offset, int32 i)
{
int32 n = (int32)(offset - last_match); /* max value: block_size (int32) */
int32 j;
@@ -207,7 +206,7 @@ static void hash_search(int f,struct sum_struct *s,
* either >= our offset or identical data at that offset.
* Remove any bypassed entries that we can never use. */
if (updating_basis_file && s->sums[i].offset < offset
&& !(s->sums[i].flags & SUMFLG_SAME_OFFSET)) {
&& !(s->sums[i].flags & SUMFLG_SAME_OFFSET)) {
*prev = s->sums[i].chain;
continue;
}
@@ -288,10 +287,10 @@ static void hash_search(int f,struct sum_struct *s,
/* we've found a match, but now check to see
* if want_i can hint at a better match. */
if (i != want_i && want_i < s->count
&& (!updating_basis_file || s->sums[want_i].offset >= offset
|| s->sums[want_i].flags & SUMFLG_SAME_OFFSET)
&& sum == s->sums[want_i].sum1
&& memcmp(sum2, s->sums[want_i].sum2, s->s2length) == 0) {
&& (!updating_basis_file || s->sums[want_i].offset >= offset
|| s->sums[want_i].flags & SUMFLG_SAME_OFFSET)
&& sum == s->sums[want_i].sum1
&& memcmp(sum2, s->sums[want_i].sum2, s->s2length) == 0) {
/* we've found an adjacent match - the RLL coder
* will be happy */
i = want_i;
@@ -317,8 +316,7 @@ static void hash_search(int f,struct sum_struct *s,
/* Trim off the first byte from the checksum */
more = offset + k < len;
map = (schar *)map_ptr(buf, offset - backup, k + more + backup)
+ backup;
map = (schar *)map_ptr(buf, offset - backup, k + more + backup) + backup;
s1 -= map[0] + CHAR_OFFSET;
s2 -= k * (map[0]+CHAR_OFFSET);

View File

@@ -409,8 +409,7 @@ static char *make_output_option(struct output_struct *words, short *levels, ucha
return buf;
}
static void parse_output_words(struct output_struct *words, short *levels,
const char *str, uchar priority)
static void parse_output_words(struct output_struct *words, short *levels, const char *str, uchar priority)
{
const char *s;
int j, len, lev;
@@ -1369,8 +1368,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
/* Disable popt aliases on the server side and
* then start parsing the options again. */
poptFreeContext(pc);
pc = poptGetContext(RSYNC_NAME, argc, argv,
long_options, 0);
pc = poptGetContext(RSYNC_NAME, argc, argv, long_options, 0);
am_server = 1;
}
#ifdef ICONV_OPTION
@@ -1398,8 +1396,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
#endif
protect_args = 0;
poptFreeContext(pc);
pc = poptGetContext(RSYNC_NAME, argc, argv,
long_daemon_options, 0);
pc = poptGetContext(RSYNC_NAME, argc, argv, long_daemon_options, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
char **cpp;
switch (opt) {
@@ -1411,8 +1408,8 @@ int parse_arguments(int *argc_p, const char ***argv_p)
arg = poptGetOptArg(pc);
if (!strchr(arg, '=')) {
rprintf(FERROR,
"--dparam value is missing an '=': %s\n",
arg);
"--dparam value is missing an '=': %s\n",
arg);
goto daemon_error;
}
cpp = EXPAND_ITEM_LIST(&dparam_list, char *, 4);
@@ -1425,9 +1422,9 @@ int parse_arguments(int *argc_p, const char ***argv_p)
default:
rprintf(FERROR,
"rsync: %s: %s (in daemon mode)\n",
poptBadOption(pc, POPT_BADOPTION_NOALIAS),
poptStrerror(opt));
"rsync: %s: %s (in daemon mode)\n",
poptBadOption(pc, POPT_BADOPTION_NOALIAS),
poptStrerror(opt));
goto daemon_error;
}
}
@@ -1444,8 +1441,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
if (!daemon_opt) {
rprintf(FERROR, "Daemon option(s) used without --daemon.\n");
daemon_error:
rprintf(FERROR,
"(Type \"rsync --daemon --help\" for assistance with daemon mode.)\n");
rprintf(FERROR, "(Type \"rsync --daemon --help\" for assistance with daemon mode.)\n");
exit_cleanup(RERR_SYNTAX);
}
@@ -1576,8 +1572,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
case 'P':
if (refused_partial || refused_progress) {
create_refuse_error(refused_partial
? refused_partial : refused_progress);
create_refuse_error(refused_partial ? refused_partial : refused_progress);
return 0;
}
do_progress = 1;
@@ -1719,8 +1714,8 @@ int parse_arguments(int *argc_p, const char ***argv_p)
arg = poptGetOptArg(pc);
if (!parse_chmod(arg, &chmod_modes)) {
snprintf(err_buf, sizeof err_buf,
"Invalid argument passed to --chmod (%s)\n",
arg);
"Invalid argument passed to --chmod (%s)\n",
arg);
return 0;
}
break;
@@ -1739,11 +1734,11 @@ int parse_arguments(int *argc_p, const char ***argv_p)
if (usermap) {
if (usermap_via_chown) {
snprintf(err_buf, sizeof err_buf,
"--usermap conflicts with prior --chown.\n");
"--usermap conflicts with prior --chown.\n");
return 0;
}
snprintf(err_buf, sizeof err_buf,
"You can only specify --usermap once.\n");
"You can only specify --usermap once.\n");
return 0;
}
usermap = (char *)poptGetOptArg(pc);
@@ -1754,11 +1749,11 @@ int parse_arguments(int *argc_p, const char ***argv_p)
if (groupmap) {
if (groupmap_via_chown) {
snprintf(err_buf, sizeof err_buf,
"--groupmap conflicts with prior --chown.\n");
"--groupmap conflicts with prior --chown.\n");
return 0;
}
snprintf(err_buf, sizeof err_buf,
"You can only specify --groupmap once.\n");
"You can only specify --groupmap once.\n");
return 0;
}
groupmap = (char *)poptGetOptArg(pc);
@@ -1776,11 +1771,11 @@ int parse_arguments(int *argc_p, const char ***argv_p)
if (usermap) {
if (!usermap_via_chown) {
snprintf(err_buf, sizeof err_buf,
"--chown conflicts with prior --usermap.\n");
"--chown conflicts with prior --usermap.\n");
return 0;
}
snprintf(err_buf, sizeof err_buf,
"You can only specify a user-affecting --chown once.\n");
"You can only specify a user-affecting --chown once.\n");
return 0;
}
if (asprintf(&usermap, "*:%.*s", len, chown) < 0)
@@ -1791,11 +1786,11 @@ int parse_arguments(int *argc_p, const char ***argv_p)
if (groupmap) {
if (!groupmap_via_chown) {
snprintf(err_buf, sizeof err_buf,
"--chown conflicts with prior --groupmap.\n");
"--chown conflicts with prior --groupmap.\n");
return 0;
}
snprintf(err_buf, sizeof err_buf,
"You can only specify a group-affecting --chown once.\n");
"You can only specify a group-affecting --chown once.\n");
return 0;
}
if (asprintf(&groupmap, "*:%s", arg) < 0)

24
pipe.c
View File

@@ -4,7 +4,7 @@
* Copyright (C) 1996-2000 Andrew Tridgell
* Copyright (C) 1996 Paul Mackerras
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
* Copyright (C) 2004-2019 Wayne Davison
* Copyright (C) 2004-2020 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -66,10 +66,10 @@ pid_t piped_child(char **command, int *f_in, int *f_out)
}
if (pid == 0) {
if (dup2(to_child_pipe[0], STDIN_FILENO) < 0 ||
close(to_child_pipe[1]) < 0 ||
close(from_child_pipe[0]) < 0 ||
dup2(from_child_pipe[1], STDOUT_FILENO) < 0) {
if (dup2(to_child_pipe[0], STDIN_FILENO) < 0
|| close(to_child_pipe[1]) < 0
|| close(from_child_pipe[0]) < 0
|| dup2(from_child_pipe[1], STDOUT_FILENO) < 0) {
rsyserr(FERROR, errno, "Failed to dup/close");
exit_cleanup(RERR_IPC);
}
@@ -116,8 +116,7 @@ pid_t local_child(int argc, char **argv, int *f_in, int *f_out,
/* The parent process is always the sender for a local rsync. */
assert(am_sender);
if (fd_pair(to_child_pipe) < 0 ||
fd_pair(from_child_pipe) < 0) {
if (fd_pair(to_child_pipe) < 0 || fd_pair(from_child_pipe) < 0) {
rsyserr(FERROR, errno, "pipe");
exit_cleanup(RERR_IPC);
}
@@ -150,10 +149,10 @@ pid_t local_child(int argc, char **argv, int *f_in, int *f_out,
}
}
if (dup2(to_child_pipe[0], STDIN_FILENO) < 0 ||
close(to_child_pipe[1]) < 0 ||
close(from_child_pipe[0]) < 0 ||
dup2(from_child_pipe[1], STDOUT_FILENO) < 0) {
if (dup2(to_child_pipe[0], STDIN_FILENO) < 0
|| close(to_child_pipe[1]) < 0
|| close(from_child_pipe[0]) < 0
|| dup2(from_child_pipe[1], STDOUT_FILENO) < 0) {
rsyserr(FERROR, errno, "Failed to dup/close");
exit_cleanup(RERR_IPC);
}
@@ -167,8 +166,7 @@ pid_t local_child(int argc, char **argv, int *f_in, int *f_out,
child_main(argc, argv);
}
if (close(from_child_pipe[1]) < 0 ||
close(to_child_pipe[0]) < 0) {
if (close(from_child_pipe[1]) < 0 || close(to_child_pipe[0]) < 0) {
rsyserr(FERROR, errno, "Failed to close");
exit_cleanup(RERR_IPC);
}

View File

@@ -66,8 +66,7 @@ static unsigned long msdiff(struct timeval *t1, struct timeval *t2)
* printed for this file, so we should output a newline. (Not
* necessarily the same as all bytes being received.)
**/
static void rprint_progress(OFF_T ofs, OFF_T size, struct timeval *now,
int is_last)
static void rprint_progress(OFF_T ofs, OFF_T size, struct timeval *now, int is_last)
{
char rembuf[64], eol[128];
const char *units;
@@ -92,8 +91,7 @@ static void rprint_progress(OFF_T ofs, OFF_T size, struct timeval *now,
is_last = 0;
}
/* Compute stats based on the starting info. */
if (!ph_start.time.tv_sec
|| !(diff = msdiff(&ph_start.time, now)))
if (!ph_start.time.tv_sec || !(diff = msdiff(&ph_start.time, now)))
diff = 1;
rate = (double) (ofs - ph_start.ofs) * 1000.0 / diff / 1024.0;
/* Switch to total time taken for our last update. */
@@ -103,8 +101,7 @@ static void rprint_progress(OFF_T ofs, OFF_T size, struct timeval *now,
/* Compute stats based on recent progress. */
if (!(diff = msdiff(&ph_list[oldest_hpos].time, now)))
diff = 1;
rate = (double) (ofs - ph_list[oldest_hpos].ofs) * 1000.0
/ diff / 1024.0;
rate = (double) (ofs - ph_list[oldest_hpos].ofs) * 1000.0 / diff / 1024.0;
remain = rate ? (double) (size - ofs) / rate / 1000.0 : 0.0;
}

View File

@@ -819,8 +819,7 @@ int recv_files(int f_in, int f_out, char *local_name)
parent_dirname = dn;
}
#endif
file->mode = dest_mode(file->mode, st.st_mode,
dflt_perms, exists);
file->mode = dest_mode(file->mode, st.st_mode, dflt_perms, exists);
}
/* We now check to see if we are writing the file "inplace" */
@@ -872,8 +871,7 @@ int recv_files(int f_in, int f_out, char *local_name)
if ((recv_ok && (!delay_updates || !partialptr)) || inplace) {
if (partialptr == fname)
partialptr = NULL;
if (!finish_transfer(fname, fnametmp, fnamecmp,
partialptr, file, recv_ok, 1))
if (!finish_transfer(fname, fnametmp, fnamecmp, partialptr, file, recv_ok, 1))
recv_ok = -1;
else if (fnamecmp == partialptr) {
if (!one_inplace)
@@ -883,9 +881,9 @@ int recv_files(int f_in, int f_out, char *local_name)
} else if (keep_partial && partialptr && !one_inplace) {
if (!handle_partial_dir(partialptr, PDIR_CREATE)) {
rprintf(FERROR,
"Unable to create partial-dir for %s -- discarding %s.\n",
local_name ? local_name : f_name(file, NULL),
recv_ok ? "completed file" : "partial file");
"Unable to create partial-dir for %s -- discarding %s.\n",
local_name ? local_name : f_name(file, NULL),
recv_ok ? "completed file" : "partial file");
do_unlink(fnametmp);
recv_ok = -1;
} else if (!finish_transfer(partialptr, fnametmp, fnamecmp, NULL,
@@ -943,7 +941,7 @@ int recv_files(int f_in, int f_out, char *local_name)
} else if (inc_recurse)
send_msg_int(MSG_NO_SEND, ndx);
break;
}
}
case -1:
if (inc_recurse)
send_msg_int(MSG_NO_SEND, ndx);

11
rsync.c
View File

@@ -318,8 +318,7 @@ void send_protected_args(int fd, char *args[])
#endif
}
int read_ndx_and_attrs(int f_in, int f_out, int *iflag_ptr, uchar *type_ptr,
char *buf, int *len_ptr)
int read_ndx_and_attrs(int f_in, int f_out, int *iflag_ptr, uchar *type_ptr, char *buf, int *len_ptr)
{
int len, iflags = 0;
struct file_list *flist;
@@ -548,8 +547,8 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
/* We shouldn't have attempted to change uid
* or gid unless have the privilege. */
rsyserr(FERROR_XFER, errno, "%s %s failed",
change_uid ? "chown" : "chgrp",
full_fname(fname));
change_uid ? "chown" : "chgrp",
full_fname(fname));
goto cleanup;
}
if (uid == (uid_t)-1 && sxp->st.st_uid != (uid_t)-1)
@@ -565,9 +564,9 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
}
}
if (change_uid)
updated |= UPDATED_OWNER;
updated |= UPDATED_OWNER;
if (change_gid)
updated |= UPDATED_GROUP;
updated |= UPDATED_GROUP;
}
#ifdef SUPPORT_XATTRS

View File

@@ -273,8 +273,7 @@ void send_files(int f_in, int f_out)
if (!(iflags & ITEM_TRANSFER)) {
maybe_log_item(file, iflags, itemizing, xname);
write_ndx_and_attrs(f_out, ndx, iflags, fname, file,
fnamecmp_type, xname, xlen);
write_ndx_and_attrs(f_out, ndx, iflags, fname, file, fnamecmp_type, xname, xlen);
if (iflags & ITEM_IS_NEW) {
stats.created_files++;
if (S_ISREG(file->mode)) {
@@ -329,8 +328,7 @@ void send_files(int f_in, int f_out)
if (!do_xfers) { /* log the transfer */
log_item(FCLIENT, file, iflags, NULL);
write_ndx_and_attrs(f_out, ndx, iflags, fname, file,
fnamecmp_type, xname, xlen);
write_ndx_and_attrs(f_out, ndx, iflags, fname, file, fnamecmp_type, xname, xlen);
continue;
}
@@ -343,9 +341,7 @@ void send_files(int f_in, int f_out)
fd = do_open(fname, O_RDONLY, 0);
if (fd == -1) {
if (errno == ENOENT) {
enum logcode c = am_daemon
&& protocol_version < 28 ? FERROR
: FWARNING;
enum logcode c = am_daemon && protocol_version < 28 ? FERROR : FWARNING;
io_error |= IOERR_VANISHED;
rprintf(c, "file has vanished: %s\n",
full_fname(fname));
@@ -381,8 +377,7 @@ void send_files(int f_in, int f_out)
path,slash,fname, big_num(st.st_size));
}
write_ndx_and_attrs(f_out, ndx, iflags, fname, file,
fnamecmp_type, xname, xlen);
write_ndx_and_attrs(f_out, ndx, iflags, fname, file, fnamecmp_type, xname, xlen);
write_sum_head(f_xfer, s);
if (DEBUG_GTE(DELTASUM, 2))

View File

@@ -49,8 +49,7 @@ static int sock_exec(const char *prog);
/* Establish a proxy connection on an open socket to a web proxy by using the
* CONNECT method. If proxy_user and proxy_pass are not NULL, they are used to
* authenticate to the proxy using the "Basic" proxy-authorization protocol. */
static int establish_proxy_connection(int fd, char *host, int port,
char *proxy_user, char *proxy_pass)
static int establish_proxy_connection(int fd, char *host, int port, char *proxy_user, char *proxy_pass)
{
char *cp, buffer[1024];
char *authhdr, authbuf[1024];
@@ -182,8 +181,7 @@ static void contimeout_handler(UNUSED(int val))
* bind_addr: local address to use. Normally NULL to bind the wildcard address.
*
* af_hint: address family, e.g. AF_INET or AF_INET6. */
int open_socket_out(char *host, int port, const char *bind_addr,
int af_hint)
int open_socket_out(char *host, int port, const char *bind_addr, int af_hint)
{
int type = SOCK_STREAM;
int error, s, j, addr_cnt, *errnos;
@@ -294,9 +292,7 @@ int open_socket_out(char *host, int port, const char *bind_addr,
continue;
}
if (proxied
&& establish_proxy_connection(s, host, port,
proxy_user, proxy_pass) != 0) {
if (proxied && establish_proxy_connection(s, host, port, proxy_user, proxy_pass) != 0) {
close(s);
s = -1;
continue;
@@ -340,8 +336,7 @@ int open_socket_out(char *host, int port, const char *bind_addr,
* This is based on the Samba LIBSMB_PROG feature.
*
* bind_addr: local address to use. Normally NULL to get the stack default. */
int open_socket_out_wrapped(char *host, int port, const char *bind_addr,
int af_hint)
int open_socket_out_wrapped(char *host, int port, const char *bind_addr, int af_hint)
{
char *prog = getenv("RSYNC_CONNECT_PROG");
@@ -458,9 +453,8 @@ static int *open_socket_in(int type, int port, const char *bind_addr,
#ifdef IPV6_V6ONLY
if (resp->ai_family == AF_INET6) {
if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY,
(char *)&one, sizeof one) < 0
&& default_af_hint != AF_INET6) {
if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&one, sizeof one) < 0
&& default_af_hint != AF_INET6) {
close(s);
continue;
}
@@ -561,8 +555,7 @@ void start_accept_loop(int port, int (*fn)(int, int))
rsyserr(FERROR, errno, "listen() on socket failed");
#ifdef INET6
if (errno == EADDRINUSE && i > 0) {
rprintf(FINFO,
"Try using --ipv4 or --ipv6 to avoid this listen() error.\n");
rprintf(FINFO, "Try using --ipv4 or --ipv6 to avoid this listen() error.\n");
}
#endif
exit_cleanup(RERR_SOCKETIO);
@@ -597,8 +590,7 @@ void start_accept_loop(int port, int (*fn)(int, int))
for (i = 0, fd = -1; sp[i] >= 0; i++) {
if (FD_ISSET(sp[i], &fds)) {
fd = accept(sp[i], (struct sockaddr *)&addr,
&addrlen);
fd = accept(sp[i], (struct sockaddr *)&addr, &addrlen);
break;
}
}
@@ -799,8 +791,7 @@ static int socketpair_tcp(int fd[2])
set_blocking(fd[1]);
if (connect_done == 0) {
if (connect(fd[1], (struct sockaddr *)&sock, sizeof sock) != 0
&& errno != EISCONN)
if (connect(fd[1], (struct sockaddr *)&sock, sizeof sock) != 0 && errno != EISCONN)
goto failed;
}

View File

@@ -171,8 +171,8 @@ int do_mknod(const char *pathname, mode_t mode, dev_t dev)
saddr.sun_family = AF_UNIX;
if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0
|| (unlink(pathname) < 0 && errno != ENOENT)
|| (bind(sock, (struct sockaddr*)&saddr, sizeof saddr)) < 0)
|| (unlink(pathname) < 0 && errno != ENOENT)
|| (bind(sock, (struct sockaddr*)&saddr, sizeof saddr)) < 0)
return -1;
close(sock);
#ifdef HAVE_CHMOD

View File

@@ -38,8 +38,7 @@ main(int argc, char **argv)
return 1;
}
printf("%s\n",
unsafe_symlink(argv[1], argv[2]) ? "unsafe" : "safe");
printf("%s\n", unsafe_symlink(argv[1], argv[2]) ? "unsafe" : "safe");
return 0;
}

10
tls.c
View File

@@ -200,9 +200,7 @@ static void list_file(const char *fname)
printf("%s ", permbuf);
if (S_ISCHR(buf.st_mode) || S_ISBLK(buf.st_mode)) {
printf("%5ld,%6ld",
(long)major(buf.st_rdev),
(long)minor(buf.st_rdev));
printf("%5ld,%6ld", (long)major(buf.st_rdev), (long)minor(buf.st_rdev));
} else
printf("%15s", do_big_num(buf.st_size, 1, NULL));
@@ -249,15 +247,13 @@ main(int argc, char *argv[])
const char **extra_args;
int opt;
pc = poptGetContext(PROGRAM, argc, (const char **)argv,
long_options, 0);
pc = poptGetContext(PROGRAM, argc, (const char **)argv, long_options, 0);
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case 'h':
tls_usage(0);
default:
fprintf(stderr,
"%s: %s\n",
fprintf(stderr, "%s: %s\n",
poptBadOption(pc, POPT_BADOPTION_NOALIAS),
poptStrerror(opt));
tls_usage(1);

19
token.c
View File

@@ -303,8 +303,7 @@ static int32 simple_recv_token(int f, char **data)
}
/* non-compressing send token */
static void simple_send_token(int f, int32 token, struct map_struct *buf,
OFF_T offset, int32 n)
static void simple_send_token(int f, int32 token, struct map_struct *buf, OFF_T offset, int32 n)
{
if (n > 0) {
int32 len = 0;
@@ -357,8 +356,7 @@ static char *obuf;
/* Send a deflated token */
static void
send_deflated_token(int f, int32 token, struct map_struct *buf, OFF_T offset,
int32 nb, int32 toklen)
send_deflated_token(int f, int32 token, struct map_struct *buf, OFF_T offset, int32 nb, int32 toklen)
{
static int init_done, flush_pending;
int32 n, r;
@@ -430,8 +428,7 @@ send_deflated_token(int f, int32 token, struct map_struct *buf, OFF_T offset,
* buffer, in case they are the
* last 4. Move them to the front.
*/
memcpy(tx_strm.next_out,
obuf+MAX_DATA_COUNT-2, 4);
memcpy(tx_strm.next_out, obuf+MAX_DATA_COUNT-2, 4);
tx_strm.next_out += 4;
tx_strm.avail_out -= 4;
}
@@ -522,7 +519,7 @@ static int32 recv_deflated_token(int f, char **data)
exit_cleanup(RERR_PROTOCOL);
}
if (!(cbuf = new_array(char, MAX_DATA_COUNT))
|| !(dbuf = new_array(char, AVAIL_OUT_SIZE(CHUNK_SIZE))))
|| !(dbuf = new_array(char, AVAIL_OUT_SIZE(CHUNK_SIZE))))
out_of_memory("recv_deflated_token");
init_done = 1;
} else {
@@ -682,8 +679,7 @@ static ZSTD_inBuffer zstd_in_buff;
static ZSTD_outBuffer zstd_out_buff;
static ZSTD_CCtx *zstd_cctx;
static void send_zstd_token(int f, int32 token, struct map_struct *buf,
OFF_T offset, int32 nb)
static void send_zstd_token(int f, int32 token, struct map_struct *buf, OFF_T offset, int32 nb)
{
static int comp_init_done, flush_pending;
ZSTD_EndDirective flush = ZSTD_e_continue;
@@ -702,8 +698,7 @@ static void send_zstd_token(int f, int32 token, struct map_struct *buf,
if (!obuf)
out_of_memory("send_deflated_token");
ZSTD_CCtx_setParameter(zstd_cctx, ZSTD_c_compressionLevel,
do_compression_level);
ZSTD_CCtx_setParameter(zstd_cctx, ZSTD_c_compressionLevel, do_compression_level);
zstd_out_buff.dst = obuf + 2;
comp_init_done = 1;
@@ -990,7 +985,7 @@ static int32 recv_compressed_token(int f, char **data)
case r_init:
if (!init_done) {
if (!(cbuf = new_array(char, MAX_DATA_COUNT))
|| !(dbuf = new_array(char, size)))
|| !(dbuf = new_array(char, size)))
out_of_memory("recv_compressed_token");
init_done = 1;
}

View File

@@ -176,8 +176,7 @@ static int is_in_group(gid_t gid)
char *gidbuf = new_array(char, ngroups*21+32);
if (!gidbuf)
out_of_memory("is_in_group");
pos = snprintf(gidbuf, 32, "process has %d gid%s: ",
ngroups, ngroups == 1? "" : "s");
pos = snprintf(gidbuf, 32, "process has %d gid%s: ", ngroups, ngroups == 1? "" : "s");
for (n = 0; n < ngroups; n++) {
pos += snprintf(gidbuf+pos, 21, " %d", (int)gidset[n]);
}
@@ -435,8 +434,7 @@ void recv_id_list(int f, struct file_list *flist)
}
if (preserve_gid && (!am_root || !numeric_ids || groupmap)) {
for (i = 0; i < flist->used; i++) {
F_GROUP(flist->files[i]) = match_gid(F_GROUP(flist->files[i]),
&flist->files[i]->flags);
F_GROUP(flist->files[i]) = match_gid(F_GROUP(flist->files[i]), &flist->files[i]->flags);
}
}
}
@@ -497,18 +495,14 @@ void parse_name_map(char *map, BOOL usernames)
if (user_to_uid(colon+1, &uid, True))
add_to_list(idmap_ptr, id1, noiu, uid, flags);
else {
rprintf(FERROR,
"Unknown --usermap name on receiver: %s\n",
colon+1);
rprintf(FERROR, "Unknown --usermap name on receiver: %s\n", colon+1);
}
} else {
gid_t gid;
if (group_to_gid(colon+1, &gid, True))
add_to_list(idmap_ptr, id1, noiu, gid, flags);
else {
rprintf(FERROR,
"Unknown --groupmap name on receiver: %s\n",
colon+1);
rprintf(FERROR, "Unknown --groupmap name on receiver: %s\n", colon+1);
}
}
@@ -519,8 +513,7 @@ void parse_name_map(char *map, BOOL usernames)
}
/* The 0 user/group doesn't get its name sent, so add it explicitly. */
recv_add_id(idlist_ptr, *idmap_ptr, 0,
numeric_ids ? NULL : usernames ? uid_to_user(0) : gid_to_group(0));
recv_add_id(idlist_ptr, *idmap_ptr, 0, numeric_ids ? NULL : usernames ? uid_to_user(0) : gid_to_group(0));
}
#ifdef HAVE_GETGROUPLIST

13
util.c
View File

@@ -722,9 +722,7 @@ int glob_expand(const char *arg, char ***argv_p, int *argc_p, int *maxargs_p)
s = strdup(arg);
if (!s)
out_of_memory("glob_expand");
clean_fname(s, CFN_KEEP_DOT_DIRS
| CFN_KEEP_TRAILING_SLASH
| CFN_COLLAPSE_DOT_DOT_DIRS);
clean_fname(s, CFN_KEEP_DOT_DIRS | CFN_KEEP_TRAILING_SLASH | CFN_COLLAPSE_DOT_DOT_DIRS);
}
ENSURE_MEMSPACE(glob.arg_buf, char, glob.absize, MAXPATHLEN);
@@ -1005,8 +1003,7 @@ int clean_fname(char *name, int flags)
* ALWAYS collapses ".." elements (except for those at the start of the
* string up to "depth" deep). If the resulting name would be empty,
* change it into a ".". */
char *sanitize_path(char *dest, const char *p, const char *rootdir, int depth,
int flags)
char *sanitize_path(char *dest, const char *p, const char *rootdir, int depth, int flags)
{
char *start, *sanp;
int rlen = 0, drop_dot_dirs = !relative_paths || !(flags & SP_KEEP_DOT_DIRS);
@@ -1438,8 +1435,7 @@ const char *find_filename_suffix(const char *fn, int fn_len, int *len_ptr)
} else if (s_len == 5) {
if (strcmp(s+1, "orig") == 0)
continue;
} else if (s_len > 2 && had_tilde
&& s[1] == '~' && isDigit(s + 2))
} else if (s_len > 2 && had_tilde && s[1] == '~' && isDigit(s + 2))
continue;
*len_ptr = s_len;
suf = s;
@@ -1642,8 +1638,7 @@ int flist_ndx_pop(flist_ndx_list *lp)
* After the size check, the list's count is incremented by 1 and a pointer
* to the "new" list item is returned.
*/
void *expand_item_list(item_list *lp, size_t item_size,
const char *desc, int incr)
void *expand_item_list(item_list *lp, size_t item_size, const char *desc, int incr)
{
/* First time through, 0 <= 0, so list is expanded. */
if (lp->malloced <= lp->count) {

View File

@@ -44,8 +44,7 @@ extern int saw_xattr_filter;
#define MAX_FULL_DATUM 32
#define HAS_PREFIX(str, prfx) (*(str) == *(prfx) \
&& strncmp(str, prfx, sizeof (prfx) - 1) == 0)
#define HAS_PREFIX(str, prfx) (*(str) == *(prfx) && strncmp(str, prfx, sizeof (prfx) - 1) == 0)
#define XATTR_ABBREV(x) ((size_t)((x).name - (x).datum) < (x).datum_len)
@@ -185,8 +184,7 @@ static ssize_t get_xattr_names(const char *fname)
/* On entry, the *len_ptr parameter contains the size of the extra space we
* should allocate when we create a buffer for the data. On exit, it contains
* the length of the datum. */
static char *get_xattr_data(const char *fname, const char *name, size_t *len_ptr,
int no_missing_error)
static char *get_xattr_data(const char *fname, const char *name, size_t *len_ptr, int no_missing_error)
{
size_t datum_len = sys_lgetxattr(fname, name, NULL, 0);
size_t extra_len = *len_ptr;
@@ -215,13 +213,13 @@ static char *get_xattr_data(const char *fname, const char *name, size_t *len_ptr
if (len != datum_len) {
if (len == (size_t)-1) {
rsyserr(FERROR_XFER, errno,
"get_xattr_data: lgetxattr(%s,\"%s\",%ld) failed",
full_fname(fname), name, (long)datum_len);
"get_xattr_data: lgetxattr(%s,\"%s\",%ld) failed",
full_fname(fname), name, (long)datum_len);
} else {
rprintf(FERROR_XFER,
"get_xattr_data: lgetxattr(%s,\"%s\",%ld) returned %ld\n",
full_fname(fname), name,
(long)datum_len, (long)len);
"get_xattr_data: lgetxattr(%s,\"%s\",%ld) returned %ld\n",
full_fname(fname), name,
(long)datum_len, (long)len);
}
free(ptr);
return NULL;
@@ -1067,8 +1065,7 @@ static int rsync_xal_set(const char *fname, item_list *xalp,
}
/* Set extended attributes on indicated filename. */
int set_xattr(const char *fname, const struct file_struct *file,
const char *fnamecmp, stat_x *sxp)
int set_xattr(const char *fname, const struct file_struct *file, const char *fnamecmp, stat_x *sxp)
{
rsync_xa_list *glst = rsync_xal_l.items;
item_list *lst;