From 25ff04417e4b4fa0aeb44e0b1576a01021aa1650 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Fri, 28 Jan 2005 18:50:49 +0000 Subject: [PATCH] Use "#if" (not "#ifdef") for configure-defined macros. --- access.c | 12 ++++++------ clientname.c | 8 ++++---- clientserver.c | 2 +- flist.c | 2 +- getgroups.c | 4 ++-- main.c | 2 +- options.c | 12 ++++++------ receiver.c | 2 +- rsync.c | 2 +- socket.c | 4 ++-- uidlist.c | 6 +++--- util.c | 8 ++++---- 12 files changed, 32 insertions(+), 32 deletions(-) diff --git a/access.c b/access.c index 9def1b2c..f8dd593f 100644 --- a/access.c +++ b/access.c @@ -67,7 +67,7 @@ static int match_address(char *addr, char *tok) int gai; int ret = 0; int addrlen = 0; -#ifdef HAVE_STRTOL +#if HAVE_STRTOL long int bits; #else int bits; @@ -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 -#ifdef INET6 +#if INET6 && strchr(tok, ':') == NULL #endif ) { @@ -133,7 +133,7 @@ static int match_address(char *addr, char *tok) break; -#ifdef INET6 +#if INET6 case PF_INET6: { struct sockaddr_in6 *sin6a, *sin6t; @@ -146,7 +146,7 @@ static int match_address(char *addr, char *tok) addrlen = 16; -#ifdef HAVE_SOCKADDR_IN6_SCOPE_ID +#if HAVE_SOCKADDR_IN6_SCOPE_ID if (sin6t->sin6_scope_id && sin6a->sin6_scope_id != sin6t->sin6_scope_id) { ret = 0; @@ -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) { -#ifdef HAVE_STRTOL +#if HAVE_STRTOL char *ep = NULL; #else unsigned char *pp; #endif -#ifdef HAVE_STRTOL +#if HAVE_STRTOL bits = strtol(p, &ep, 10); if (!*p || *ep) { rprintf(FLOG, "malformed mask in %s\n", tok); diff --git a/clientname.c b/clientname.c index 7b36f78b..ed8e97fd 100644 --- a/clientname.c +++ b/clientname.c @@ -132,7 +132,7 @@ char *client_name(int fd) ss_len = sizeof (struct sockaddr_in); memcpy(&ss, answer->ai_addr, ss_len); break; -#ifdef INET6 +#if INET6 case AF_INET6: ss_len = sizeof (struct sockaddr_in6); memcpy(&ss, answer->ai_addr, ss_len); @@ -172,7 +172,7 @@ void client_sockaddr(int fd, exit_cleanup(RERR_SOCKETIO); } -#ifdef INET6 +#if 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 @@ -261,7 +261,7 @@ int compare_addrinfo_sockaddr(const struct addrinfo *ai, sizeof sin1->sin_addr); } -#ifdef INET6 +#if INET6 if (ss_family == AF_INET6) { const struct sockaddr_in6 *sin1, *sin2; @@ -278,7 +278,7 @@ int compare_addrinfo_sockaddr(const struct addrinfo *ai, sizeof sin1->sin6_addr)) return 1; -#ifdef HAVE_SOCKADDR_IN6_SCOPE_ID +#if HAVE_SOCKADDR_IN6_SCOPE_ID if (sin1->sin6_scope_id != sin2->sin6_scope_id) return 1; #endif diff --git a/clientserver.c b/clientserver.c index fdd63868..4825b00a 100644 --- a/clientserver.c +++ b/clientserver.c @@ -395,7 +395,7 @@ static int rsync_module(int f_in, int f_out, int i) io_printf(f_out, "@ERROR: setgid failed\n"); return -1; } -#ifdef HAVE_SETGROUPS +#if HAVE_SETGROUPS /* Get rid of any supplementary groups this process * might have inheristed. */ if (setgroups(1, &gid)) { diff --git a/flist.c b/flist.c index bd114323..bc247a88 100644 --- a/flist.c +++ b/flist.c @@ -925,7 +925,7 @@ skip_filters: memcpy(bp, basename, basename_len); bp += basename_len; -#ifdef HAVE_STRUCT_STAT_ST_RDEV +#if HAVE_STRUCT_STAT_ST_RDEV if (preserve_devices && IS_DEVICE(st.st_mode)) file->u.rdev = st.st_rdev; #endif diff --git a/getgroups.c b/getgroups.c index 6a8fac2e..6b4259d7 100644 --- a/getgroups.c +++ b/getgroups.c @@ -34,7 +34,7 @@ main(UNUSED(int argc), UNUSED(char *argv[])) gid_t gid = MY_GID(); int gid_in_list = 0; -#ifdef HAVE_GETGROUPS +#if HAVE_GETGROUPS if ((n = getgroups(0, NULL)) < 0) { perror("getgroups"); return 1; @@ -49,7 +49,7 @@ main(UNUSED(int argc), UNUSED(char *argv[])) exit(1); } -#ifdef HAVE_GETGROUPS +#if HAVE_GETGROUPS if (n > 0) n = getgroups(n, list); #endif diff --git a/main.c b/main.c index 545c8940..8ba45a26 100644 --- a/main.c +++ b/main.c @@ -227,7 +227,7 @@ static void report(int f) **/ static void show_malloc_stats(void) { -#ifdef HAVE_MALLINFO +#if HAVE_MALLINFO struct mallinfo mi; mi = mallinfo(); diff --git a/options.c b/options.c index b95e1e45..46878027 100644 --- a/options.c +++ b/options.c @@ -105,7 +105,7 @@ long block_size = 0; /* "long" because popt can't set an int32. */ /** Network address family. **/ -#ifdef INET6 +#if INET6 int default_af_hint = 0; /* Any protocol */ #else int default_af_hint = AF_INET; /* Must use IPv4 */ @@ -168,7 +168,7 @@ static void print_rsync_version(enum logcode f) char const *ipv6 = "no "; STRUCT_STAT *dumstat; -#ifdef HAVE_SOCKETPAIR +#if HAVE_SOCKETPAIR got_socketpair = ""; #endif @@ -327,7 +327,7 @@ void usage(enum logcode F) rprintf(F," --bwlimit=KBPS limit I/O bandwidth; KBytes per second\n"); rprintf(F," --write-batch=FILE write a batched update to FILE\n"); rprintf(F," --read-batch=FILE read a batched update from FILE\n"); -#ifdef INET6 +#if INET6 rprintf(F," -4, --ipv4 prefer IPv4\n"); rprintf(F," -6, --ipv6 prefer IPv6\n"); #endif @@ -432,7 +432,7 @@ static struct poptOption long_options[] = { {"no-implied-dirs", 0, POPT_ARG_VAL, &implied_dirs, 0, 0, 0 }, {"protocol", 0, POPT_ARG_INT, &protocol_version, 0, 0, 0 }, {"checksum-seed", 0, POPT_ARG_INT, &checksum_seed, 0, 0, 0 }, -#ifdef INET6 +#if INET6 {"ipv4", '4', POPT_ARG_VAL, &default_af_hint, AF_INET, 0, 0 }, {"ipv6", '6', POPT_ARG_VAL, &default_af_hint, AF_INET6, 0, 0 }, #endif @@ -455,7 +455,7 @@ static void daemon_usage(enum logcode F) rprintf(F," --no-detach do not detach from the parent\n"); rprintf(F," --port=PORT listen on alternate port number\n"); rprintf(F," -v, --verbose increase verbosity\n"); -#ifdef INET6 +#if INET6 rprintf(F," -4, --ipv4 prefer IPv4\n"); rprintf(F," -6, --ipv6 prefer IPv6\n"); #endif @@ -471,7 +471,7 @@ static struct poptOption long_daemon_options[] = { {"bwlimit", 0, POPT_ARG_INT, &daemon_bwlimit, 0, 0, 0 }, {"config", 0, POPT_ARG_STRING, &config_file, 0, 0, 0 }, {"daemon", 0, POPT_ARG_NONE, &daemon_opt, 0, 0, 0 }, -#ifdef INET6 +#if INET6 {"ipv4", '4', POPT_ARG_VAL, &default_af_hint, AF_INET, 0, 0 }, {"ipv6", '6', POPT_ARG_VAL, &default_af_hint, AF_INET6, 0, 0 }, #endif diff --git a/receiver.c b/receiver.c index 3acb7bd0..09df2602 100644 --- a/receiver.c +++ b/receiver.c @@ -223,7 +223,7 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r, if (flush_write_file(fd) < 0) goto report_write_error; -#ifdef HAVE_FTRUNCATE +#if HAVE_FTRUNCATE if (inplace && fd != -1) ftruncate(fd, offset); #endif diff --git a/rsync.c b/rsync.c index 1ddb54f3..acb260cc 100644 --- a/rsync.c +++ b/rsync.c @@ -221,7 +221,7 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st, updated = 1; } -#ifdef HAVE_CHMOD +#if HAVE_CHMOD if (!S_ISLNK(st->st_mode)) { if ((st->st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS)) { updated = 1; diff --git a/socket.c b/socket.c index 969b9321..5d3f0098 100644 --- a/socket.c +++ b/socket.c @@ -452,7 +452,7 @@ void start_accept_loop(int port, int (*fn)(int, int)) for (i = 0, maxfd = -1; sp[i] >= 0; i++) { if (listen(sp[i], 5) < 0) { rsyserr(FERROR, errno, "listen() on socket failed"); -#ifdef INET6 +#if INET6 if (errno == EADDRINUSE && i > 0) { rprintf(FINFO, "Try using --ipv4 or --ipv6 to avoid this listen() error.\n"); @@ -649,7 +649,7 @@ void become_daemon(void) } /* detach from the terminal */ -#ifdef HAVE_SETSID +#if HAVE_SETSID setsid(); #else #ifdef TIOCNOTTY diff --git a/uidlist.c b/uidlist.c index 5baf952f..912cca1a 100644 --- a/uidlist.c +++ b/uidlist.c @@ -25,8 +25,8 @@ #include "rsync.h" -#ifdef HAVE_GETGROUPS -# if !defined(GETGROUPS_T) +#if HAVE_GETGROUPS +# ifndef GETGROUPS_T # define GETGROUPS_T gid_t # endif #endif @@ -96,7 +96,7 @@ static int map_gid(int id, char *name) static int is_in_group(gid_t gid) { -#ifdef HAVE_GETGROUPS +#if HAVE_GETGROUPS static gid_t last_in = GID_NONE, last_out; static int ngroups = -2; static GETGROUPS_T *gidset; diff --git a/util.c b/util.c index 8260897d..6887d67c 100644 --- a/util.c +++ b/util.c @@ -140,12 +140,12 @@ int set_modtime(char *fname, time_t modtime) return 0; { -#ifdef HAVE_UTIMBUF +#if HAVE_UTIMBUF struct utimbuf tbuf; tbuf.actime = time(NULL); tbuf.modtime = modtime; return utime(fname,&tbuf); -#elif defined(HAVE_UTIME) +#elif HAVE_UTIME time_t t[2]; t[0] = time(NULL); t[1] = modtime; @@ -502,7 +502,7 @@ static void glob_expand_one(char *s, char ***argv_ptr, int *argc_ptr, char **argv = *argv_ptr; int argc = *argc_ptr; int maxargs = *maxargs_ptr; -#if !(defined(HAVE_GLOB) && defined(HAVE_GLOB_H)) +#if !(HAVE_GLOB && HAVE_GLOB_H) if (argc == maxargs) { maxargs += MAX_ARGS; if (!(argv = realloc_array(argv, char *, maxargs))) @@ -1094,7 +1094,7 @@ char *timestring(time_t t) static char TimeBuf[200]; struct tm *tm = localtime(&t); -#ifdef HAVE_STRFTIME +#if HAVE_STRFTIME strftime(TimeBuf, sizeof TimeBuf - 1, "%Y/%m/%d %H:%M:%S", tm); #else strlcpy(TimeBuf, asctime(tm), sizeof TimeBuf); -- 2.34.1