utils.h: Avoid name clashes for setbit/delbit/hasbit
authorFlorian Fainelli <f.fainelli@gmail.com>
Fri, 2 Sep 2016 02:10:15 +0000 (19:10 -0700)
committerJohn Crispin <john@phrozen.org>
Sun, 18 Sep 2016 12:06:00 +0000 (14:06 +0200)
Rename to fw3_{set,del,has}bit to avoid name clashes with sys/param.h:

/opt/toolchains/stbgcc-4.8-1.5/arm-linux-gnueabihf/sys-root/usr/include/sys/param.h:80:0: note: this is the location of the previous definition
 #define setbit(a,i)     ((a)[(i)/NBBY] |= 1<<((i)%NBBY))

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
defaults.c
forwards.c
iptables.c
options.c
rules.c
utils.h
zones.c

index 2dbbb633e2e442b10c5d0f15de034ae934df864a..8afbf9acf8323071c7ba4f59666987eb76b1a9d7 100644 (file)
@@ -154,7 +154,7 @@ fw3_print_default_chains(struct fw3_ipt_handle *handle, struct fw3_state *state,
                        continue;
 
                if (c->flag &&
-                   !hasbit(defs->flags[handle->family == FW3_FAMILY_V6], c->flag))
+                   !fw3_hasbit(defs->flags[handle->family == FW3_FAMILY_V6], c->flag))
                        continue;
 
                fw3_ipt_create_chain(handle, c->format);
index 5911732799969a9f14d1d1686bf28adc178fafd4..6f950520fd37f0f3d004a766e8a9878415ba697f 100644 (file)
@@ -86,8 +86,8 @@ fw3_load_forwards(struct fw3_state *state, struct uci_package *p)
                /* NB: forward family... */
                if (forward->_dest)
                {
-                       setbit(forward->_dest->flags[0], FW3_FLAG_ACCEPT);
-                       setbit(forward->_dest->flags[1], FW3_FLAG_ACCEPT);
+                       fw3_setbit(forward->_dest->flags[0], FW3_FLAG_ACCEPT);
+                       fw3_setbit(forward->_dest->flags[1], FW3_FLAG_ACCEPT);
 
                        if (forward->_src &&
                            (forward->_src->conntrack || forward->_dest->conntrack))
index 96fba12f0e90fb45baadae7fc597226cafd006ea..e54ea53f2c39d48cf5e0ab3234e5c36e5d2cfbe8 100644 (file)
@@ -1030,7 +1030,7 @@ fw3_ipt_rule_time(struct fw3_ipt_rule *r, struct fw3_time *time)
        {
                for (i = 1, p = buf; i < 32; i++)
                {
-                       if (hasbit(time->monthdays, i))
+                       if (fw3_hasbit(time->monthdays, i))
                        {
                                if (p > buf)
                                        *p++ = ',';
@@ -1039,14 +1039,14 @@ fw3_ipt_rule_time(struct fw3_ipt_rule *r, struct fw3_time *time)
                        }
                }
 
-               fw3_ipt_rule_addarg(r, hasbit(time->monthdays, 0), "--monthdays", buf);
+               fw3_ipt_rule_addarg(r, fw3_hasbit(time->monthdays, 0), "--monthdays", buf);
        }
 
        if (time->weekdays & 0xFE)
        {
                for (i = 1, p = buf; i < 8; i++)
                {
-                       if (hasbit(time->weekdays, i))
+                       if (fw3_hasbit(time->weekdays, i))
                        {
                                if (p > buf)
                                        *p++ = ',';
@@ -1055,7 +1055,7 @@ fw3_ipt_rule_time(struct fw3_ipt_rule *r, struct fw3_time *time)
                        }
                }
 
-               fw3_ipt_rule_addarg(r, hasbit(time->weekdays, 0), "--weekdays", buf);
+               fw3_ipt_rule_addarg(r, fw3_hasbit(time->weekdays, 0), "--weekdays", buf);
        }
 }
 
index 407931b4c49062c9ff922b3f502837817a48ae7f..d88d3ba09b50b6f17173af7fbac5071a692fe440 100644 (file)
--- a/options.c
+++ b/options.c
@@ -718,7 +718,7 @@ fw3_parse_weekdays(void *ptr, const char *val, bool is_list)
 
        if (*val == '!')
        {
-               setbit(*(uint8_t *)ptr, 0);
+               fw3_setbit(*(uint8_t *)ptr, 0);
                while (isspace(*++val));
        }
 
@@ -738,7 +738,7 @@ fw3_parse_weekdays(void *ptr, const char *val, bool is_list)
                        }
                }
 
-               setbit(*(uint8_t *)ptr, w);
+               fw3_setbit(*(uint8_t *)ptr, w);
        }
 
        free(s);
@@ -753,7 +753,7 @@ fw3_parse_monthdays(void *ptr, const char *val, bool is_list)
 
        if (*val == '!')
        {
-               setbit(*(uint32_t *)ptr, 0);
+               fw3_setbit(*(uint32_t *)ptr, 0);
                while (isspace(*++val));
        }
 
@@ -770,7 +770,7 @@ fw3_parse_monthdays(void *ptr, const char *val, bool is_list)
                        return false;
                }
 
-               setbit(*(uint32_t *)ptr, d);
+               fw3_setbit(*(uint32_t *)ptr, d);
        }
 
        free(s);
diff --git a/rules.c b/rules.c
index 2c682b1b0b7e1f020a6c4c4be73f0e0557dd1d19..8f232d3e06449f5e6221adacb8675103d1876c7b 100644 (file)
--- a/rules.c
+++ b/rules.c
@@ -247,13 +247,13 @@ fw3_load_rules(struct fw3_state *state, struct uci_package *p,
                /* NB: rule family... */
                if (rule->_dest)
                {
-                       setbit(rule->_dest->flags[0], rule->target);
-                       setbit(rule->_dest->flags[1], rule->target);
+                       fw3_setbit(rule->_dest->flags[0], rule->target);
+                       fw3_setbit(rule->_dest->flags[1], rule->target);
                }
                else if (need_src_action_chain(rule))
                {
-                       setbit(rule->_src->flags[0], fw3_to_src_target(rule->target));
-                       setbit(rule->_src->flags[1], fw3_to_src_target(rule->target));
+                       fw3_setbit(rule->_src->flags[0], fw3_to_src_target(rule->target));
+                       fw3_setbit(rule->_src->flags[1], fw3_to_src_target(rule->target));
                }
        }
 }
diff --git a/utils.h b/utils.h
index 166ac26cfd0768a511e9215cef284996d777e68d..c74a5dd76d22fcab5b7e496ed2582899302e9923 100644 (file)
--- a/utils.h
+++ b/utils.h
@@ -46,13 +46,13 @@ void warn(const char *format, ...);
 void error(const char *format, ...);
 void info(const char *format, ...);
 
-#define setbit(field, flag) field |= (1 << (flag))
-#define delbit(field, flag) field &= ~(1 << (flag))
-#define hasbit(field, flag) (field & (1 << (flag)))
+#define fw3_setbit(field, flag) field |= (1 << (flag))
+#define fw3_delbit(field, flag) field &= ~(1 << (flag))
+#define fw3_hasbit(field, flag) (field & (1 << (flag)))
 
-#define set(field, family, flag) setbit(field[family == FW3_FAMILY_V6], flag)
-#define del(field, family, flag) delbit(field[family == FW3_FAMILY_V6], flag)
-#define has(field, family, flag) hasbit(field[family == FW3_FAMILY_V6], flag)
+#define set(field, family, flag) fw3_setbit(field[family == FW3_FAMILY_V6], flag)
+#define del(field, family, flag) fw3_delbit(field[family == FW3_FAMILY_V6], flag)
+#define has(field, family, flag) fw3_hasbit(field[family == FW3_FAMILY_V6], flag)
 
 #define fw3_foreach(p, h)                                                  \
        for (p = list_empty(h) ? NULL : list_first_entry(h, typeof(*p), list); \
diff --git a/zones.c b/zones.c
index a4458fe5f7ea96b0248bb1ed70f7c459f56317a4..9ae0c75b98350c577046ecb72654a87f56c3b240 100644 (file)
--- a/zones.c
+++ b/zones.c
@@ -216,23 +216,23 @@ fw3_load_zones(struct fw3_state *state, struct uci_package *p)
 
                if (zone->masq)
                {
-                       setbit(zone->flags[0], FW3_FLAG_SNAT);
+                       fw3_setbit(zone->flags[0], FW3_FLAG_SNAT);
                        zone->conntrack = true;
                }
 
                if (zone->custom_chains)
                {
-                       setbit(zone->flags[0], FW3_FLAG_SNAT);
-                       setbit(zone->flags[0], FW3_FLAG_DNAT);
+                       fw3_setbit(zone->flags[0], FW3_FLAG_SNAT);
+                       fw3_setbit(zone->flags[0], FW3_FLAG_DNAT);
                }
 
-               setbit(zone->flags[0], fw3_to_src_target(zone->policy_input));
-               setbit(zone->flags[0], zone->policy_forward);
-               setbit(zone->flags[0], zone->policy_output);
+               fw3_setbit(zone->flags[0], fw3_to_src_target(zone->policy_input));
+               fw3_setbit(zone->flags[0], zone->policy_forward);
+               fw3_setbit(zone->flags[0], zone->policy_output);
 
-               setbit(zone->flags[1], fw3_to_src_target(zone->policy_input));
-               setbit(zone->flags[1], zone->policy_forward);
-               setbit(zone->flags[1], zone->policy_output);
+               fw3_setbit(zone->flags[1], fw3_to_src_target(zone->policy_input));
+               fw3_setbit(zone->flags[1], zone->policy_forward);
+               fw3_setbit(zone->flags[1], zone->policy_output);
 
                list_add_tail(&zone->list, &state->zones);
        }
@@ -284,7 +284,7 @@ print_zone_chain(struct fw3_ipt_handle *handle, struct fw3_state *state,
                        continue;
 
                if (c->flag &&
-                   !hasbit(zone->flags[handle->family == FW3_FAMILY_V6], c->flag))
+                   !fw3_hasbit(zone->flags[handle->family == FW3_FAMILY_V6], c->flag))
                        continue;
 
                fw3_ipt_create_chain(handle, c->format, zone->name);
@@ -655,15 +655,15 @@ fw3_hotplug_zones(struct fw3_state *state, bool add)
 
        list_for_each_entry(z, &state->zones, list)
        {
-               if (add != hasbit(z->flags[0], FW3_FLAG_HOTPLUG))
+               if (add != fw3_hasbit(z->flags[0], FW3_FLAG_HOTPLUG))
                {
                        list_for_each_entry(d, &z->devices, list)
                                fw3_hotplug(add, z, d);
 
                        if (add)
-                               setbit(z->flags[0], FW3_FLAG_HOTPLUG);
+                               fw3_setbit(z->flags[0], FW3_FLAG_HOTPLUG);
                        else
-                               delbit(z->flags[0], FW3_FLAG_HOTPLUG);
+                               fw3_delbit(z->flags[0], FW3_FLAG_HOTPLUG);
                }
        }
 }