Skip to content

Commit

Permalink
John E. Malmberg convinced me to standardize on #ifs for defined
Browse files Browse the repository at this point in the history
values instead of non-zero.
  • Loading branch information
Wayne Davison committed Feb 14, 2005
1 parent fe1c19d commit 4f5b075
Show file tree
Hide file tree
Showing 20 changed files with 144 additions and 146 deletions.
12 changes: 6 additions & 6 deletions access.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static int match_address(char *addr, char *tok)
int gai;
int ret = 0;
int addrlen = 0;
#if HAVE_STRTOL
#ifdef HAVE_STRTOL
long int bits;
#else
int bits;
Expand All @@ -88,7 +88,7 @@ static int match_address(char *addr, char *tok)

/* Fail quietly if tok is a hostname (not an address) */
if (strspn(tok, ".0123456789") != len
#if INET6
#ifdef INET6
&& strchr(tok, ':') == NULL
#endif
) {
Expand Down Expand Up @@ -133,7 +133,7 @@ static int match_address(char *addr, char *tok)

break;

#if INET6
#ifdef INET6
case PF_INET6:
{
struct sockaddr_in6 *sin6a, *sin6t;
Expand All @@ -146,7 +146,7 @@ static int match_address(char *addr, char *tok)

addrlen = 16;

#if HAVE_SOCKADDR_IN6_SCOPE_ID
#ifdef HAVE_SOCKADDR_IN6_SCOPE_ID
if (sin6t->sin6_scope_id &&
sin6a->sin6_scope_id != sin6t->sin6_scope_id) {
ret = 0;
Expand All @@ -166,13 +166,13 @@ static int match_address(char *addr, char *tok)
bits = -1;
if (p) {
if (inet_pton(resa->ai_addr->sa_family, p, mask) <= 0) {
#if HAVE_STRTOL
#ifdef HAVE_STRTOL
char *ep = NULL;
#else
unsigned char *pp;
#endif

#if HAVE_STRTOL
#ifdef HAVE_STRTOL
bits = strtol(p, &ep, 10);
if (!*p || *ep) {
rprintf(FLOG, "malformed mask in %s\n", tok);
Expand Down
2 changes: 1 addition & 1 deletion backup.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static int keep_backup(char *fname)
kept = 1;
}

#if SUPPORT_LINKS
#ifdef SUPPORT_LINKS
if (!kept && preserve_links && S_ISLNK(file->mode)) {
if (safe_symlinks && unsafe_symlink(file->u.link, buf)) {
if (verbose) {
Expand Down
10 changes: 5 additions & 5 deletions clientname.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ char *client_name(int fd)
ss_len = sizeof (struct sockaddr_in);
memcpy(&ss, answer->ai_addr, ss_len);
break;
#if INET6
#ifdef INET6
case AF_INET6:
ss_len = sizeof (struct sockaddr_in6);
memcpy(&ss, answer->ai_addr, ss_len);
Expand Down Expand Up @@ -172,7 +172,7 @@ void client_sockaddr(int fd,
exit_cleanup(RERR_SOCKETIO);
}

#if INET6
#ifdef INET6
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
Expand All @@ -189,7 +189,7 @@ void client_sockaddr(int fd,
memset(sin, 0, sizeof *sin);
sin->sin_family = AF_INET;
*ss_len = sizeof (struct sockaddr_in);
#if HAVE_SOCKADDR_IN_LEN
#ifdef HAVE_SOCKADDR_IN_LEN
sin->sin_len = *ss_len;
#endif
sin->sin_port = sin6.sin6_port;
Expand Down Expand Up @@ -261,7 +261,7 @@ int compare_addrinfo_sockaddr(const struct addrinfo *ai,
sizeof sin1->sin_addr);
}

#if INET6
#ifdef INET6
if (ss_family == AF_INET6) {
const struct sockaddr_in6 *sin1, *sin2;

Expand All @@ -278,7 +278,7 @@ int compare_addrinfo_sockaddr(const struct addrinfo *ai,
sizeof sin1->sin6_addr))
return 1;

#if HAVE_SOCKADDR_IN6_SCOPE_ID
#ifdef HAVE_SOCKADDR_IN6_SCOPE_ID
if (sin1->sin6_scope_id != sin2->sin6_scope_id)
return 1;
#endif
Expand Down
2 changes: 1 addition & 1 deletion clientserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ static int rsync_module(int f_in, int f_out, int i)
io_printf(f_out, "@ERROR: setgid failed\n");
return -1;
}
#if HAVE_SETGROUPS
#ifdef HAVE_SETGROUPS
/* Get rid of any supplementary groups this process
* might have inheristed. */
if (setgroups(1, &gid)) {
Expand Down
34 changes: 17 additions & 17 deletions flist.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static void list_file_entry(struct file_struct *f)

permstring(perms, f->mode);

#if SUPPORT_LINKS
#ifdef SUPPORT_LINKS
if (preserve_links && S_ISLNK(f->mode)) {
rprintf(FINFO, "%s %11.0f %s %s -> %s\n",
perms,
Expand Down Expand Up @@ -178,7 +178,7 @@ static void list_file_entry(struct file_struct *f)
**/
static int readlink_stat(const char *path, STRUCT_STAT *buffer, char *linkbuf)
{
#if SUPPORT_LINKS
#ifdef SUPPORT_LINKS
if (copy_links)
return do_stat(path, buffer);
if (link_stat(path, buffer, 0) < 0)
Expand All @@ -204,7 +204,7 @@ static int readlink_stat(const char *path, STRUCT_STAT *buffer, char *linkbuf)

int link_stat(const char *path, STRUCT_STAT *buffer, int follow_dirlinks)
{
#if SUPPORT_LINKS
#ifdef SUPPORT_LINKS
if (copy_links)
return do_stat(path, buffer);
if (do_lstat(path, buffer) < 0)
Expand Down Expand Up @@ -253,7 +253,7 @@ static int is_excluded(char *fname, int is_dir, int filter_level)

static int to_wire_mode(mode_t mode)
{
#if SUPPORT_LINKS
#ifdef SUPPORT_LINKS
if (S_ISLNK(mode) && (_S_IFLNK != 0120000))
return (mode & ~(_S_IFMT)) | 0120000;
#endif
Expand Down Expand Up @@ -385,7 +385,7 @@ void send_file_entry(struct file_struct *file, int f, unsigned short base_flags)
else
modtime = file->modtime;

#if SUPPORT_HARD_LINKS
#ifdef SUPPORT_HARD_LINKS
if (file->link_u.idev) {
if (file->F_DEV == dev) {
if (protocol_version >= 28)
Expand Down Expand Up @@ -463,15 +463,15 @@ void send_file_entry(struct file_struct *file, int f, unsigned short base_flags)
}
}

#if SUPPORT_LINKS
#ifdef SUPPORT_LINKS
if (preserve_links && S_ISLNK(mode)) {
int len = strlen(file->u.link);
write_int(f, len);
write_buf(f, file->u.link, len);
}
#endif

#if SUPPORT_HARD_LINKS
#ifdef SUPPORT_HARD_LINKS
if (flags & XMIT_HAS_IDEV_DATA) {
if (protocol_version < 26) {
/* 32-bit dev_t and ino_t */
Expand Down Expand Up @@ -611,7 +611,7 @@ static struct file_struct *receive_file_entry(struct file_list *flist,
}
}

#if SUPPORT_LINKS
#ifdef SUPPORT_LINKS
if (preserve_links && S_ISLNK(mode)) {
linkname_len = read_int(f) + 1; /* count the '\0' */
if (linkname_len <= 0 || linkname_len > MAXPATHLEN) {
Expand Down Expand Up @@ -679,7 +679,7 @@ static struct file_struct *receive_file_entry(struct file_list *flist,
if (preserve_devices && IS_DEVICE(mode))
file->u.rdev = rdev;

#if SUPPORT_LINKS
#ifdef SUPPORT_LINKS
if (linkname_len) {
file->u.link = bp;
read_sbuf(f, bp, linkname_len - 1);
Expand All @@ -689,7 +689,7 @@ static struct file_struct *receive_file_entry(struct file_list *flist,
}
#endif

#if SUPPORT_HARD_LINKS
#ifdef SUPPORT_HARD_LINKS
if (preserve_hard_links && protocol_version < 28 && S_ISREG(mode))
flags |= XMIT_HAS_IDEV_DATA;
if (flags & XMIT_HAS_IDEV_DATA) {
Expand Down Expand Up @@ -788,7 +788,7 @@ struct file_struct *make_file(char *fname, struct file_list *flist,
&& is_excluded(thisname, 0, filter_level))
return NULL;
if (save_errno == ENOENT) {
#if SUPPORT_LINKS
#ifdef SUPPORT_LINKS
/* Avoid "vanished" error if symlink points nowhere. */
if (copy_links && do_lstat(thisname, &st) == 0
&& S_ISLNK(st.st_mode)) {
Expand Down Expand Up @@ -832,7 +832,7 @@ struct file_struct *make_file(char *fname, struct file_list *flist,
return NULL;

if (lp_ignore_nonreadable(module_id)) {
#if SUPPORT_LINKS
#ifdef SUPPORT_LINKS
if (!S_ISLNK(st.st_mode))
#endif
if (access(thisname, R_OK) != 0)
Expand Down Expand Up @@ -861,7 +861,7 @@ struct file_struct *make_file(char *fname, struct file_list *flist,
}
basename_len = strlen(basename) + 1; /* count the '\0' */

#if SUPPORT_LINKS
#ifdef SUPPORT_LINKS
linkname_len = S_ISLNK(st.st_mode) ? strlen(linkname) + 1 : 0;
#else
linkname_len = 0;
Expand Down Expand Up @@ -890,7 +890,7 @@ struct file_struct *make_file(char *fname, struct file_list *flist,
file->uid = st.st_uid;
file->gid = st.st_gid;

#if SUPPORT_HARD_LINKS
#ifdef SUPPORT_HARD_LINKS
if (flist && flist->hlink_pool) {
if (protocol_version < 28) {
if (S_ISREG(st.st_mode))
Expand Down Expand Up @@ -923,12 +923,12 @@ struct file_struct *make_file(char *fname, struct file_list *flist,
memcpy(bp, basename, basename_len);
bp += basename_len;

#if HAVE_STRUCT_STAT_ST_RDEV
#ifdef HAVE_STRUCT_STAT_ST_RDEV
if (preserve_devices && IS_DEVICE(st.st_mode))
file->u.rdev = st.st_rdev;
#endif

#if SUPPORT_LINKS
#ifdef SUPPORT_LINKS
if (linkname_len) {
file->u.link = bp;
memcpy(bp, linkname, linkname_len);
Expand Down Expand Up @@ -1415,7 +1415,7 @@ struct file_list *flist_new(int with_hlink, char *msg)
out_of_memory, POOL_INTERN)))
out_of_memory(msg);

#if SUPPORT_HARD_LINKS
#ifdef SUPPORT_HARD_LINKS
if (with_hlink && preserve_hard_links) {
if (!(flist->hlink_pool = pool_create(HLINK_EXTENT,
sizeof (struct idev), out_of_memory, POOL_INTERN)))
Expand Down
4 changes: 2 additions & 2 deletions generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ static void recv_generator(char *fname, struct file_list *flist,
}

if (preserve_links && S_ISLNK(file->mode)) {
#if SUPPORT_LINKS
#ifdef SUPPORT_LINKS
if (safe_symlinks && unsafe_symlink(file->u.link, fname)) {
if (verbose) {
rprintf(FINFO,
Expand Down Expand Up @@ -455,7 +455,7 @@ static void recv_generator(char *fname, struct file_list *flist,
pathjoin(fnamecmpbuf, sizeof fnamecmpbuf,
basis_dir[i], fname);
}
#if HAVE_LINK
#ifdef HAVE_LINK
if (link_dest && match_level == 3 && !dry_run) {
if (do_link(fnamecmpbuf, fname) < 0) {
if (verbose) {
Expand Down
2 changes: 1 addition & 1 deletion getfsdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
int ret;

while (--argc > 0) {
#if USE_STAT64_FUNCS
#ifdef USE_STAT64_FUNCS
ret = stat64(*++argv, &st);
#else
ret = stat(*++argv, &st);
Expand Down
4 changes: 2 additions & 2 deletions getgroups.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ main(UNUSED(int argc), UNUSED(char *argv[]))
gid_t gid = MY_GID();
int gid_in_list = 0;

#if HAVE_GETGROUPS
#ifdef HAVE_GETGROUPS
if ((n = getgroups(0, NULL)) < 0) {
perror("getgroups");
return 1;
Expand All @@ -49,7 +49,7 @@ main(UNUSED(int argc), UNUSED(char *argv[]))
exit(1);
}

#if HAVE_GETGROUPS
#ifdef HAVE_GETGROUPS
if (n > 0)
n = getgroups(n, list);
#endif
Expand Down
10 changes: 5 additions & 5 deletions hlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extern int dry_run;
extern int verbose;
extern int make_backups;

#if SUPPORT_HARD_LINKS
#ifdef SUPPORT_HARD_LINKS
static int hlink_compare(struct file_struct **file1, struct file_struct **file2)
{
struct file_struct *f1 = *file1;
Expand Down Expand Up @@ -104,7 +104,7 @@ static void link_idev_data(struct file_list *flist)

void init_hard_links(struct file_list *flist)
{
#if SUPPORT_HARD_LINKS
#ifdef SUPPORT_HARD_LINKS
int i;

if (flist->count < 2)
Expand Down Expand Up @@ -135,7 +135,7 @@ void init_hard_links(struct file_list *flist)

int hard_link_check(struct file_struct *file, int skip)
{
#if SUPPORT_HARD_LINKS
#ifdef SUPPORT_HARD_LINKS
if (!hlink_list || !file->link_u.links)
return 0;
if (skip && !(file->flags & FLAG_HLINK_EOL))
Expand All @@ -151,7 +151,7 @@ int hard_link_check(struct file_struct *file, int skip)
return 0;
}

#if SUPPORT_HARD_LINKS
#ifdef SUPPORT_HARD_LINKS
static void hard_link_one(char *hlink1, char *hlink2)
{
if (do_link(hlink1, hlink2)) {
Expand All @@ -173,7 +173,7 @@ static void hard_link_one(char *hlink1, char *hlink2)
**/
void do_hard_links(void)
{
#if SUPPORT_HARD_LINKS
#ifdef SUPPORT_HARD_LINKS
struct file_struct *file, *first;
char hlink1[MAXPATHLEN];
char *hlink2;
Expand Down
4 changes: 2 additions & 2 deletions lib/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
{
unsigned char *p = (unsigned char *)&ip.s_addr;
static char buf[18];
#if WORDS_BIGENDIAN
#ifdef WORDS_BIGENDIAN
snprintf(buf, 18, "%d.%d.%d.%d",
(int)p[0], (int)p[1], (int)p[2], (int)p[3]);
#else
Expand Down Expand Up @@ -196,7 +196,7 @@
/* some systems don't take the 2nd argument */
int sys_gettimeofday(struct timeval *tv)
{
#if HAVE_GETTIMEOFDAY_TZ
#ifdef HAVE_GETTIMEOFDAY_TZ
return gettimeofday(tv, NULL);
#else
return gettimeofday(tv);
Expand Down
4 changes: 2 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ static void report(int f)
**/
static void show_malloc_stats(void)
{
#if HAVE_MALLINFO
#ifdef HAVE_MALLINFO
struct mallinfo mi;

mi = mallinfo();
Expand Down Expand Up @@ -292,7 +292,7 @@ static pid_t do_cmd(char *cmd, char *machine, char *user, char *path,
dash_l_set = 1;
}

#if HAVE_REMSH
#ifdef HAVE_REMSH
/* remsh (on HPUX) takes the arguments the other way around */
args[argc++] = machine;
if (user && !(daemon_over_rsh && dash_l_set)) {
Expand Down
Loading

0 comments on commit 4f5b075

Please sign in to comment.