]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
iptables: replace open-coded sizeof by ARRAY_SIZE
authorJan Engelhardt <jengelh@medozas.de>
Thu, 30 Apr 2009 17:32:02 +0000 (19:32 +0200)
committerJan Engelhardt <jengelh@medozas.de>
Tue, 26 May 2009 11:14:15 +0000 (13:14 +0200)
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
18 files changed:
extensions/dscp_helper.c
extensions/libip6t_LOG.c
extensions/libip6t_REJECT.c
extensions/libip6t_icmp6.c
extensions/libip6t_ipv6header.c
extensions/libip6t_mh.c
extensions/libipt_LOG.c
extensions/libipt_REJECT.c
extensions/libipt_icmp.c
extensions/libxt_dccp.c
extensions/libxt_hashlimit.c
extensions/libxt_limit.c
extensions/libxt_pkttype.c
extensions/libxt_sctp.c
extensions/libxt_tcp.c
ip6tables-restore.c
iptables-restore.c
iptables-xml.c

index 8fa0f4a08bf72cc603a1633176995a7561ba4112..75b1fece09a63e17fd3f07bef4df3dfee6652993 100644 (file)
@@ -51,7 +51,7 @@ class_to_dscp(const char *name)
 {
        unsigned int i;
 
-       for (i = 0; i < sizeof(ds_classes) / sizeof(struct ds_class); i++) {
+       for (i = 0; i < ARRAY_SIZE(ds_classes); i++) {
                if (!strncasecmp(name, ds_classes[i].name,
                                        strlen(ds_classes[i].name)))
                        return ds_classes[i].dscp;
@@ -68,11 +68,9 @@ dscp_to_name(unsigned int dscp)
 {
        int i;
 
-       for (i = 0; i < sizeof(ds_classes) / sizeof(struct ds_class); i++) {
+       for (i = 0; i < ARRAY_SIZE(ds_classes); ++i) 
                if (dscp == ds_classes[i].dscp)
                        return ds_classes[i].name;
-       }
-
 
        xtables_error(PARAMETER_PROBLEM,
                        "Invalid DSCP value `%d'\n", dscp);
index 390cb9792966f8e4214dfb592da55770c7521db6..f7132016dd21c209533972409777e293b37790e5 100644 (file)
@@ -72,9 +72,7 @@ parse_level(const char *level)
        if (!xtables_strtoui(level, NULL, &lev, 0, 7)) {
                unsigned int i = 0;
 
-               for (i = 0;
-                    i < sizeof(ip6t_log_names) / sizeof(struct ip6t_log_names);
-                    i++) {
+               for (i = 0; i < ARRAY_SIZE(ip6t_log_names); ++i)
                        if (strncasecmp(level, ip6t_log_names[i].name,
                                        strlen(level)) == 0) {
                                if (set++)
@@ -83,7 +81,6 @@ parse_level(const char *level)
                                                   level);
                                lev = ip6t_log_names[i].level;
                        }
-               }
 
                if (!set)
                        xtables_error(PARAMETER_PROBLEM,
@@ -201,15 +198,12 @@ static void LOG_print(const void *ip, const struct xt_entry_target *target,
                printf("flags %u level %u ",
                       loginfo->logflags, loginfo->level);
        else {
-               for (i = 0;
-                    i < sizeof(ip6t_log_names) / sizeof(struct ip6t_log_names);
-                    i++) {
+               for (i = 0; i < ARRAY_SIZE(ip6t_log_names); ++i)
                        if (loginfo->level == ip6t_log_names[i].level) {
                                printf("level %s ", ip6t_log_names[i].name);
                                break;
                        }
-               }
-               if (i == sizeof(ip6t_log_names) / sizeof(struct ip6t_log_names))
+               if (i == ARRAY_SIZE(ip6t_log_names))
                        printf("UNKNOWN level %u ", loginfo->level);
                if (loginfo->logflags & IP6T_LOG_TCPSEQ)
                        printf("tcp-sequence ");
index 527f5950121d569eccba0c6e1342e5dbf0f1aa8a..9ad3b685e2d46370c406693466c5827ba2aeda04 100644 (file)
@@ -43,7 +43,7 @@ print_reject_types(void)
 
        printf("Valid reject types:\n");
 
-       for (i = 0; i < sizeof(reject_table)/sizeof(struct reject_names); i++) {
+       for (i = 0; i < ARRAY_SIZE(reject_table); ++i) {
                printf("    %-25s\t%s\n", reject_table[i].name, reject_table[i].desc);
                printf("    %-25s\talias\n", reject_table[i].alias);
        }
@@ -79,7 +79,6 @@ static int REJECT_parse(int c, char **argv, int invert, unsigned int *flags,
 {
        struct ip6t_reject_info *reject = 
                (struct ip6t_reject_info *)(*target)->data;
-       unsigned int limit = sizeof(reject_table)/sizeof(struct reject_names);
        unsigned int i;
 
        switch(c) {
@@ -87,13 +86,12 @@ static int REJECT_parse(int c, char **argv, int invert, unsigned int *flags,
                if (xtables_check_inverse(optarg, &invert, NULL, 0))
                        xtables_error(PARAMETER_PROBLEM,
                                   "Unexpected `!' after --reject-with");
-               for (i = 0; i < limit; i++) {
+               for (i = 0; i < ARRAY_SIZE(reject_table); ++i)
                        if ((strncasecmp(reject_table[i].name, optarg, strlen(optarg)) == 0)
                            || (strncasecmp(reject_table[i].alias, optarg, strlen(optarg)) == 0)) {
                                reject->with = reject_table[i].with;
                                return 1;
                        }
-               }
                xtables_error(PARAMETER_PROBLEM, "unknown reject type \"%s\"", optarg);
        default:
                /* Fall through */
@@ -109,10 +107,9 @@ static void REJECT_print(const void *ip, const struct xt_entry_target *target,
                = (const struct ip6t_reject_info *)target->data;
        unsigned int i;
 
-       for (i = 0; i < sizeof(reject_table)/sizeof(struct reject_names); i++) {
+       for (i = 0; i < ARRAY_SIZE(reject_table); ++i)
                if (reject_table[i].with == reject->with)
                        break;
-       }
        printf("reject-with %s ", reject_table[i].name);
 }
 
@@ -122,7 +119,7 @@ static void REJECT_save(const void *ip, const struct xt_entry_target *target)
                = (const struct ip6t_reject_info *)target->data;
        unsigned int i;
 
-       for (i = 0; i < sizeof(reject_table)/sizeof(struct reject_names); i++)
+       for (i = 0; i < ARRAY_SIZE(reject_table); ++i)
                if (reject_table[i].with == reject->with)
                        break;
 
index 0678aac3939c675a56ea47dbe5e29ebc230b7886..e41a670cbe247a125e3204c79b81c455355d98dd 100644 (file)
@@ -59,7 +59,7 @@ print_icmpv6types(void)
        unsigned int i;
        printf("Valid ICMPv6 Types:");
 
-       for (i = 0; i < sizeof(icmpv6_codes)/sizeof(struct icmpv6_names); i++) {
+       for (i = 0; i < ARRAY_SIZE(icmpv6_codes); ++i) {
                if (i && icmpv6_codes[i].type == icmpv6_codes[i-1].type) {
                        if (icmpv6_codes[i].code_min == icmpv6_codes[i-1].code_min
                            && (icmpv6_codes[i].code_max
@@ -91,7 +91,7 @@ static const struct option icmp6_opts[] = {
 static void
 parse_icmpv6(const char *icmpv6type, u_int8_t *type, u_int8_t code[])
 {
-       unsigned int limit = sizeof(icmpv6_codes)/sizeof(struct icmpv6_names);
+       static const unsigned int limit = ARRAY_SIZE(icmpv6_codes);
        unsigned int match = limit;
        unsigned int i;
 
@@ -181,16 +181,13 @@ static void print_icmpv6type(u_int8_t type,
        if (!numeric) {
                unsigned int i;
 
-               for (i = 0;
-                    i < sizeof(icmpv6_codes)/sizeof(struct icmpv6_names);
-                    i++) {
+               for (i = 0; i < ARRAY_SIZE(icmpv6_codes); ++i)
                        if (icmpv6_codes[i].type == type
                            && icmpv6_codes[i].code_min == code_min
                            && icmpv6_codes[i].code_max == code_max)
                                break;
-               }
 
-               if (i != sizeof(icmpv6_codes)/sizeof(struct icmpv6_names)) {
+               if (i != ARRAY_SIZE(icmpv6_codes)) {
                        printf("%s%s ",
                               invert ? "!" : "",
                               icmpv6_codes[i].name);
index 479b313277ab4de42e4e4ac82ee3b00ff1f717fc..2674c8fb6500ebc0ab9ac5d682436bc73afbcdba 100644 (file)
@@ -77,7 +77,7 @@ proto_to_name(u_int8_t proto, int nolookup)
                         return pent->p_name;
         }
 
-        for (i = 0; i < sizeof(chain_protos)/sizeof(struct pprot); i++)
+        for (i = 0; i < ARRAY_SIZE(chain_protos); ++i)
                 if (chain_protos[i].num == proto)
                         return chain_protos[i].name;
 
@@ -94,16 +94,13 @@ name_to_proto(const char *s)
                proto = pent->p_proto;
         else {
                unsigned int i;
-               for (i = 0;
-                       i < sizeof(chain_protos)/sizeof(struct pprot);
-                       i++) {
+               for (i = 0; i < ARRAY_SIZE(chain_protos); ++i)
                        if (strcmp(s, chain_protos[i].name) == 0) {
                                proto = chain_protos[i].num;
                                break;
                        }
-               }
 
-               if (i == sizeof(chain_protos)/sizeof(struct pprot))
+               if (i == ARRAY_SIZE(chain_protos))
                        xtables_error(PARAMETER_PROBLEM,
                                "unknown header `%s' specified",
                                s);
@@ -116,16 +113,13 @@ static unsigned int
 add_proto_to_mask(int proto){
        unsigned int i=0, flag=0;
 
-       for (i = 0;
-               i < sizeof(chain_flags)/sizeof(struct numflag);
-               i++) {
+       for (i = 0; i < ARRAY_SIZE(chain_flags); ++i)
                        if (proto == chain_flags[i].proto){
                                flag = chain_flags[i].flag;
                                break;
                        }
-       }
 
-       if (i == sizeof(chain_flags)/sizeof(struct numflag))
+       if (i == ARRAY_SIZE(chain_flags))
                xtables_error(PARAMETER_PROBLEM,
                "unknown header `%d' specified",
                proto);
index 9711f764097932e30244db5a7c6dd329d2dad436..47d554482c9f5173c98e0c103a43367fb1c79afd 100644 (file)
@@ -48,7 +48,7 @@ static void print_types_all(void)
        unsigned int i;
        printf("Valid MH types:");
 
-       for (i = 0; i < sizeof(mh_names)/sizeof(struct mh_name); i++) {
+       for (i = 0; i < ARRAY_SIZE(mh_names); ++i) {
                if (i && mh_names[i].type == mh_names[i-1].type)
                        printf(" (%s)", mh_names[i].name);
                else
@@ -75,7 +75,7 @@ static void mh_init(struct xt_entry_match *m)
 static unsigned int name_to_type(const char *name)
 {
        int namelen = strlen(name);
-       unsigned int limit = sizeof(mh_names)/sizeof(struct mh_name);
+       static const unsigned int limit = ARRAY_SIZE(mh_names);
        unsigned int match = limit;
        unsigned int i;
 
@@ -151,10 +151,9 @@ static const char *type_to_name(u_int8_t type)
 {
        unsigned int i;
 
-       for (i = 0; i < sizeof(mh_names)/sizeof(struct mh_name); i++) {
+       for (i = 0; i < ARRAY_SIZE(mh_names); ++i)
                if (mh_names[i].type == type)
                        return mh_names[i].name;
-       }
 
        return NULL;
 }
index ebcb5742b3756a07dd9b53693415bf72b7e2864c..5b90033aaf8820c2d285276fdc2fd79bd18c6a4f 100644 (file)
@@ -72,9 +72,7 @@ parse_level(const char *level)
        if (!xtables_strtoui(level, NULL, &lev, 0, 7)) {
                unsigned int i = 0;
 
-               for (i = 0;
-                    i < sizeof(ipt_log_names) / sizeof(struct ipt_log_names);
-                    i++) {
+               for (i = 0; i < ARRAY_SIZE(ipt_log_names); ++i)
                        if (strncasecmp(level, ipt_log_names[i].name,
                                        strlen(level)) == 0) {
                                if (set++)
@@ -83,7 +81,6 @@ parse_level(const char *level)
                                                   level);
                                lev = ipt_log_names[i].level;
                        }
-               }
 
                if (!set)
                        xtables_error(PARAMETER_PROBLEM,
@@ -201,15 +198,12 @@ static void LOG_print(const void *ip, const struct xt_entry_target *target,
                printf("flags %u level %u ",
                       loginfo->logflags, loginfo->level);
        else {
-               for (i = 0;
-                    i < sizeof(ipt_log_names) / sizeof(struct ipt_log_names);
-                    i++) {
+               for (i = 0; i < ARRAY_SIZE(ipt_log_names); ++i)
                        if (loginfo->level == ipt_log_names[i].level) {
                                printf("level %s ", ipt_log_names[i].name);
                                break;
                        }
-               }
-               if (i == sizeof(ipt_log_names) / sizeof(struct ipt_log_names))
+               if (i == ARRAY_SIZE(ipt_log_names))
                        printf("UNKNOWN level %u ", loginfo->level);
                if (loginfo->logflags & IPT_LOG_TCPSEQ)
                        printf("tcp-sequence ");
index 5b23f547b8aa1bc65d698c850d85847d099b5974..888ff39763de8dfd543a46b2d2f6018d11d64891 100644 (file)
@@ -56,7 +56,7 @@ print_reject_types(void)
 
        printf("Valid reject types:\n");
 
-       for (i = 0; i < sizeof(reject_table)/sizeof(struct reject_names); i++) {
+       for (i = 0; i < ARRAY_SIZE(reject_table); ++i) {
                printf("    %-25s\t%s\n", reject_table[i].name, reject_table[i].desc);
                printf("    %-25s\talias\n", reject_table[i].alias);
        }
@@ -93,7 +93,7 @@ static int REJECT_parse(int c, char **argv, int invert, unsigned int *flags,
                         const void *entry, struct xt_entry_target **target)
 {
        struct ipt_reject_info *reject = (struct ipt_reject_info *)(*target)->data;
-       unsigned int limit = sizeof(reject_table)/sizeof(struct reject_names);
+       static const unsigned int limit = ARRAY_SIZE(reject_table);
        unsigned int i;
 
        switch(c) {
@@ -128,10 +128,9 @@ static void REJECT_print(const void *ip, const struct xt_entry_target *target,
                = (const struct ipt_reject_info *)target->data;
        unsigned int i;
 
-       for (i = 0; i < sizeof(reject_table)/sizeof(struct reject_names); i++) {
+       for (i = 0; i < ARRAY_SIZE(reject_table); ++i)
                if (reject_table[i].with == reject->with)
                        break;
-       }
        printf("reject-with %s ", reject_table[i].name);
 }
 
@@ -141,7 +140,7 @@ static void REJECT_save(const void *ip, const struct xt_entry_target *target)
                = (const struct ipt_reject_info *)target->data;
        unsigned int i;
 
-       for (i = 0; i < sizeof(reject_table)/sizeof(struct reject_names); i++)
+       for (i = 0; i < ARRAY_SIZE(reject_table); ++i)
                if (reject_table[i].with == reject->with)
                        break;
 
index 15c17872219b442277c27278a6234c585f0c4e10..5667955249f27f5b46551d15853fa7a8827fc17e 100644 (file)
@@ -83,7 +83,7 @@ print_icmptypes(void)
        unsigned int i;
        printf("Valid ICMP Types:");
 
-       for (i = 0; i < sizeof(icmp_codes)/sizeof(struct icmp_names); i++) {
+       for (i = 0; i < ARRAY_SIZE(icmp_codes); ++i) {
                if (i && icmp_codes[i].type == icmp_codes[i-1].type) {
                        if (icmp_codes[i].code_min == icmp_codes[i-1].code_min
                            && (icmp_codes[i].code_max
@@ -115,7 +115,7 @@ static const struct option icmp_opts[] = {
 static void 
 parse_icmp(const char *icmptype, u_int8_t *type, u_int8_t code[])
 {
-       unsigned int limit = sizeof(icmp_codes)/sizeof(struct icmp_names);
+       static const unsigned int limit = ARRAY_SIZE(icmp_codes);
        unsigned int match = limit;
        unsigned int i;
 
@@ -206,16 +206,13 @@ static void print_icmptype(u_int8_t type,
        if (!numeric) {
                unsigned int i;
 
-               for (i = 0;
-                    i < sizeof(icmp_codes)/sizeof(struct icmp_names);
-                    i++) {
+               for (i = 0; i < ARRAY_SIZE(icmp_codes); ++i)
                        if (icmp_codes[i].type == type
                            && icmp_codes[i].code_min == code_min
                            && icmp_codes[i].code_max == code_max)
                                break;
-               }
 
-               if (i != sizeof(icmp_codes)/sizeof(struct icmp_names)) {
+               if (i != ARRAY_SIZE(icmp_codes)) {
                        printf("%s%s ",
                               invert ? "!" : "",
                               icmp_codes[i].name);
index 413624e1fb84ad62da479e59e92c40a5c0cc4133..73211459ab224501d582378d98599dc759feed56 100644 (file)
@@ -102,13 +102,12 @@ parse_dccp_types(const char *typestring)
 
        for (ptr = strtok(buffer, ","); ptr; ptr = strtok(NULL, ",")) {
                unsigned int i;
-               for (i = 0; i < sizeof(dccp_pkt_types)/sizeof(char *); i++) {
+               for (i = 0; i < ARRAY_SIZE(dccp_pkt_types); ++i)
                        if (!strcasecmp(dccp_pkt_types[i], ptr)) {
                                typemask |= (1 << i);
                                break;
                        }
-               }
-               if (i == sizeof(dccp_pkt_types)/sizeof(char *))
+               if (i == ARRAY_SIZE(dccp_pkt_types))
                        xtables_error(PARAMETER_PROBLEM,
                                   "Unknown DCCP type `%s'", ptr);
        }
index aa56c652bedf65881f4026f1fda8b0b6df9072eb..84dd786864c5c58895c33a755969794b3e81a3b4 100644 (file)
@@ -485,11 +485,10 @@ static void print_rate(u_int32_t period)
 {
        unsigned int i;
 
-       for (i = 1; i < sizeof(rates)/sizeof(struct rates); i++) {
+       for (i = 1; i < ARRAY_SIZE(rates); ++i)
                if (period > rates[i].mult
             || rates[i].mult/period < rates[i].mult%period)
                        break;
-       }
 
        printf("%u/%s ", rates[i-1].mult / period, rates[i-1].name);
 }
index 18224f3f52d03e627d75a6614d4d3315569a92ce..498f009a613194a7db8b286a95cb302df7d8268a 100644 (file)
@@ -132,11 +132,10 @@ static void print_rate(u_int32_t period)
 {
        unsigned int i;
 
-       for (i = 1; i < sizeof(rates)/sizeof(struct rates); i++) {
+       for (i = 1; i < ARRAY_SIZE(rates); ++i)
                if (period > rates[i].mult
             || rates[i].mult/period < rates[i].mult%period)
                        break;
-       }
 
        printf("%u/%s ", rates[i-1].mult / period, rates[i-1].name);
 }
index 50af3ed43a22ce427d7f8dde963093e21b85979a..e3db2aa986b5277a05c07acc8842a660f3c1754e 100644 (file)
@@ -46,11 +46,9 @@ static void print_types(void)
        unsigned int    i;
        
        printf("Valid packet types:\n");
-       for (i = 0; i < sizeof(supported_types)/sizeof(struct pkttypes); i++)
-       {
+       for (i = 0; i < ARRAY_SIZE(supported_types); ++i)
                if(supported_types[i].printhelp == 1)
                        printf("\t%-14s\t\t%s\n", supported_types[i].name, supported_types[i].help);
-       }
        printf("\n");
 }
 
@@ -71,14 +69,12 @@ static void parse_pkttype(const char *pkttype, struct xt_pkttype_info *info)
 {
        unsigned int    i;
        
-       for (i = 0; i < sizeof(supported_types)/sizeof(struct pkttypes); i++)
-       {
+       for (i = 0; i < ARRAY_SIZE(supported_types); ++i)
                if(strcasecmp(pkttype, supported_types[i].name)==0)
                {
                        info->pkttype=supported_types[i].pkttype;
                        return;
                }
-       }
        
        xtables_error(PARAMETER_PROBLEM, "Bad packet type '%s'", pkttype);
 }
@@ -115,14 +111,12 @@ static void print_pkttype(const struct xt_pkttype_info *info)
 {
        unsigned int    i;
        
-       for (i = 0; i < sizeof(supported_types)/sizeof(struct pkttypes); i++)
-       {
+       for (i = 0; i < ARRAY_SIZE(supported_types); ++i)
                if(supported_types[i].pkttype==info->pkttype)
                {
                        printf("%s ", supported_types[i].name);
                        return;
                }
-       }
 
        printf("%d ", info->pkttype);   /* in case we didn't find an entry in named-packtes */
 }
index b889406b5b88fbd0713eb36d0a1270ea699ce662..829eade00d592c5abec527d959fa0085a1737a81 100644 (file)
 #include <netinet/in.h>
 #include <xtables.h>
 
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-#endif
-
 #include <linux/netfilter/xt_sctp.h>
 
-/* Some ZS!#@:$%*#$! has replaced the ELEMCOUNT macro in ipt_sctp.h with
- * ARRAY_SIZE without noticing that this file is used from userspace,
- * and userspace doesn't have ARRAY_SIZE */
-
-#ifndef ELEMCOUNT
-#define ELEMCOUNT ARRAY_SIZE
-#endif
-
 #if 0
 #define DEBUGP(format, first...) printf(format, ##first)
 #define static
@@ -198,7 +186,7 @@ parse_sctp_chunk(struct xt_sctp_info *einfo,
                        *chunk_flags++ = 0;
                }
                
-               for (i = 0; i < ELEMCOUNT(sctp_chunk_names); i++) {
+               for (i = 0; i < ARRAY_SIZE(sctp_chunk_names); ++i)
                        if (strcasecmp(sctp_chunk_names[i].name, ptr) == 0) {
                                DEBUGP("Chunk num %d\n", sctp_chunk_names[i].chunk_type);
                                SCTP_CHUNKMAP_SET(einfo->chunkmap, 
@@ -206,7 +194,6 @@ parse_sctp_chunk(struct xt_sctp_info *einfo,
                                found = 1;
                                break;
                        }
-               }
                if (!found)
                        xtables_error(PARAMETER_PROBLEM,
                                   "Unknown sctp chunk `%s'", ptr);
@@ -389,10 +376,9 @@ print_chunk(u_int32_t chunknum, int numeric)
        else {
                int i;
 
-               for (i = 0; i < ELEMCOUNT(sctp_chunk_names); i++) {
+               for (i = 0; i < ARRAY_SIZE(sctp_chunk_names); ++i)
                        if (sctp_chunk_names[i].chunk_type == chunknum)
                                printf("%s", sctp_chunk_names[chunknum].name);
-               }
        }
 }
 
index d2ad53b3d0a23c5b795ddd87cadf26dc9418c4ea..5ea9ebd2bb15bb9e2dfafe22cc66204f47600819 100644 (file)
@@ -86,18 +86,15 @@ parse_tcp_flag(const char *flags)
 
        for (ptr = strtok(buffer, ","); ptr; ptr = strtok(NULL, ",")) {
                unsigned int i;
-               for (i = 0;
-                    i < sizeof(tcp_flag_names)/sizeof(struct tcp_flag_names);
-                    i++) {
+               for (i = 0; i < ARRAY_SIZE(tcp_flag_names); ++i)
                        if (strcasecmp(tcp_flag_names[i].name, ptr) == 0) {
                                ret |= tcp_flag_names[i].flag;
                                break;
                        }
-               }
-               if (i == sizeof(tcp_flag_names)/sizeof(struct tcp_flag_names))
+               if (i == ARRAY_SIZE(tcp_flag_names))
                        xtables_error(PARAMETER_PROBLEM,
                                   "Unknown TCP flag `%s'", ptr);
-               }
+       }
 
        free(buffer);
        return ret;
index 324dd1f1870a74574808504441899f1c68556577..1d5efea2a17d5c2cf3b7f9bfef40487393f7553d 100644 (file)
@@ -99,7 +99,7 @@ static int newargc;
  * returns true if argument added, false otherwise */
 static int add_argv(char *what) {
        DEBUGP("add_argv: %s\n", what);
-       if (what && ((newargc + 1) < sizeof(newargv)/sizeof(char *))) {
+       if (what && newargc + 1 < ARRAY_SIZE(newargv)) {
                newargv[newargc] = strdup(what);
                newargc++;
                return 1;
index f1c5e3ea3aaf5e0c6bf88bb70d84c556616ceb48..2a797ccff85bb87856838779ea2030efbc9c017c 100644 (file)
@@ -99,7 +99,7 @@ static int newargc;
  * returns true if argument added, false otherwise */
 static int add_argv(char *what) {
        DEBUGP("add_argv: %s\n", what);
-       if (what && ((newargc + 1) < sizeof(newargv)/sizeof(char *))) {
+       if (what && newargc + 1 < ARRAY_SIZE(newargv)) {
                newargv[newargc] = strdup(what);
                newargc++;
                return 1;
index 543715b4aec3737933f98563e020f3848e5fec7f..e5d194197823366e053cec3ceaed8309fa2d0074 100644 (file)
@@ -110,7 +110,7 @@ static int
 add_argv(char *what, int quoted)
 {
        DEBUGP("add_argv: %d %s\n", newargc, what);
-       if (what && ((newargc + 1) < sizeof(newargv) / sizeof(char *))) {
+       if (what && newargc + 1 < ARRAY_SIZE(newargv)) {
                newargv[newargc] = strdup(what);
                newargvattr[newargc] = quoted;
                newargc++;