Use "#if" (not "#ifdef") for configure-defined macros.
authorWayne Davison <wayned@samba.org>
Fri, 28 Jan 2005 18:50:49 +0000 (18:50 +0000)
committerWayne Davison <wayned@samba.org>
Fri, 28 Jan 2005 18:50:49 +0000 (18:50 +0000)
12 files changed:
access.c
clientname.c
clientserver.c
flist.c
getgroups.c
main.c
options.c
receiver.c
rsync.c
socket.c
uidlist.c
util.c

index 9def1b2..f8dd593 100644 (file)
--- 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);
index 7b36f78..ed8e97f 100644 (file)
@@ -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
index fdd6386..4825b00 100644 (file)
@@ -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 bd11432..bc247a8 100644 (file)
--- 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
index 6a8fac2..6b4259d 100644 (file)
@@ -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 545c894..8ba45a2 100644 (file)
--- 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();
index b95e1e4..4687802 100644 (file)
--- 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
index 3acb7bd..09df260 100644 (file)
@@ -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 1ddb54f..acb260c 100644 (file)
--- 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;
index 969b932..5d3f009 100644 (file)
--- 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
index 5baf952..912cca1 100644 (file)
--- 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 8260897..6887d67 100644 (file)
--- 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);