mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 11:18:43 +00:00
*: use array_size instead of raw division
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
parent
5b94ec5024
commit
97b5d752d7
@ -900,11 +900,10 @@ static int bgpTrapEstablished(struct peer *peer)
|
|||||||
|
|
||||||
oid_copy_addr(index, &addr, IN_ADDR_SIZE);
|
oid_copy_addr(index, &addr, IN_ADDR_SIZE);
|
||||||
|
|
||||||
smux_trap(bgp_variables, sizeof bgp_variables / sizeof(struct variable),
|
smux_trap(bgp_variables, array_size(bgp_variables), bgp_trap_oid,
|
||||||
bgp_trap_oid, sizeof bgp_trap_oid / sizeof(oid), bgp_oid,
|
array_size(bgp_trap_oid), bgp_oid,
|
||||||
sizeof bgp_oid / sizeof(oid), index, IN_ADDR_SIZE,
|
sizeof bgp_oid / sizeof(oid), index, IN_ADDR_SIZE,
|
||||||
bgpTrapList, sizeof bgpTrapList / sizeof(struct trap_object),
|
bgpTrapList, array_size(bgpTrapList), BGPESTABLISHED);
|
||||||
BGPESTABLISHED);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -920,11 +919,10 @@ static int bgpTrapBackwardTransition(struct peer *peer)
|
|||||||
|
|
||||||
oid_copy_addr(index, &addr, IN_ADDR_SIZE);
|
oid_copy_addr(index, &addr, IN_ADDR_SIZE);
|
||||||
|
|
||||||
smux_trap(bgp_variables, sizeof bgp_variables / sizeof(struct variable),
|
smux_trap(bgp_variables, array_size(bgp_variables), bgp_trap_oid,
|
||||||
bgp_trap_oid, sizeof bgp_trap_oid / sizeof(oid), bgp_oid,
|
array_size(bgp_trap_oid), bgp_oid,
|
||||||
sizeof bgp_oid / sizeof(oid), index, IN_ADDR_SIZE,
|
sizeof bgp_oid / sizeof(oid), index, IN_ADDR_SIZE,
|
||||||
bgpTrapList, sizeof bgpTrapList / sizeof(struct trap_object),
|
bgpTrapList, array_size(bgpTrapList), BGPBACKWARDTRANSITION);
|
||||||
BGPBACKWARDTRANSITION);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ static int bgp_vnc_config_write_debug(struct vty *vty)
|
|||||||
int write = 0;
|
int write = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < (sizeof(vncdebug) / sizeof(struct vnc_debug)); ++i) {
|
for (i = 0; i < array_size(vncdebug); ++i) {
|
||||||
if (conf_vnc_debug & vncdebug[i].bit) {
|
if (conf_vnc_debug & vncdebug[i].bit) {
|
||||||
vty_out(vty, "debug bgp vnc %s\n", vncdebug[i].name);
|
vty_out(vty, "debug bgp vnc %s\n", vncdebug[i].name);
|
||||||
write++;
|
write++;
|
||||||
|
@ -444,7 +444,7 @@ static int open_dlpi_dev(struct isis_circuit *circuit)
|
|||||||
struct strioctl sioc;
|
struct strioctl sioc;
|
||||||
|
|
||||||
pfil.Pf_Priority = 0;
|
pfil.Pf_Priority = 0;
|
||||||
pfil.Pf_FilterLen = sizeof(pf_filter) / sizeof(unsigned short);
|
pfil.Pf_FilterLen = array_size(pf_filter);
|
||||||
memcpy(pfil.Pf_Filter, pf_filter, sizeof(pf_filter));
|
memcpy(pfil.Pf_Filter, pf_filter, sizeof(pf_filter));
|
||||||
/* pfmod does not support transparent ioctls */
|
/* pfmod does not support transparent ioctls */
|
||||||
sioc.ic_cmd = PFIOCSETF;
|
sioc.ic_cmd = PFIOCSETF;
|
||||||
|
@ -80,7 +80,7 @@ struct zebra_privs_t isisd_privs = {
|
|||||||
.vty_group = VTY_GROUP,
|
.vty_group = VTY_GROUP,
|
||||||
#endif
|
#endif
|
||||||
.caps_p = _caps_p,
|
.caps_p = _caps_p,
|
||||||
.cap_num_p = sizeof(_caps_p) / sizeof(*_caps_p),
|
.cap_num_p = array_size(_caps_p),
|
||||||
.cap_num_i = 0};
|
.cap_num_i = 0};
|
||||||
|
|
||||||
/* isisd options */
|
/* isisd options */
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <zebra.h>
|
#include <zebra.h>
|
||||||
|
|
||||||
|
#include "memory.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "imsg.h"
|
#include "imsg.h"
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ static int available_fds(unsigned int n)
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
int ret, fds[256];
|
int ret, fds[256];
|
||||||
|
|
||||||
if (n > (sizeof(fds) / sizeof(fds[0])))
|
if (n > (unsigned int)array_size(fds))
|
||||||
return (1);
|
return (1);
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
@ -1358,13 +1358,10 @@ static int ospf6TrapNbrStateChange(struct ospf6_neighbor *on, int next_state,
|
|||||||
index[1] = on->ospf6_if->instance_id;
|
index[1] = on->ospf6_if->instance_id;
|
||||||
index[2] = ntohl(on->router_id);
|
index[2] = ntohl(on->router_id);
|
||||||
|
|
||||||
smux_trap(ospfv3_variables,
|
smux_trap(ospfv3_variables, array_size(ospfv3_variables),
|
||||||
sizeof ospfv3_variables / sizeof(struct variable),
|
ospfv3_trap_oid, array_size(ospfv3_trap_oid), ospfv3_oid,
|
||||||
ospfv3_trap_oid, sizeof ospfv3_trap_oid / sizeof(oid),
|
sizeof ospfv3_oid / sizeof(oid), index, 3, ospf6NbrTrapList,
|
||||||
ospfv3_oid, sizeof ospfv3_oid / sizeof(oid), index, 3,
|
array_size(ospf6NbrTrapList), NBRSTATECHANGE);
|
||||||
ospf6NbrTrapList,
|
|
||||||
sizeof ospf6NbrTrapList / sizeof(struct trap_object),
|
|
||||||
NBRSTATECHANGE);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1383,13 +1380,10 @@ static int ospf6TrapIfStateChange(struct ospf6_interface *oi, int next_state,
|
|||||||
index[0] = oi->interface->ifindex;
|
index[0] = oi->interface->ifindex;
|
||||||
index[1] = oi->instance_id;
|
index[1] = oi->instance_id;
|
||||||
|
|
||||||
smux_trap(ospfv3_variables,
|
smux_trap(ospfv3_variables, array_size(ospfv3_variables),
|
||||||
sizeof ospfv3_variables / sizeof(struct variable),
|
ospfv3_trap_oid, array_size(ospfv3_trap_oid), ospfv3_oid,
|
||||||
ospfv3_trap_oid, sizeof ospfv3_trap_oid / sizeof(oid),
|
sizeof ospfv3_oid / sizeof(oid), index, 2, ospf6IfTrapList,
|
||||||
ospfv3_oid, sizeof ospfv3_oid / sizeof(oid), index, 2,
|
array_size(ospf6IfTrapList), IFSTATECHANGE);
|
||||||
ospf6IfTrapList,
|
|
||||||
sizeof ospf6IfTrapList / sizeof(struct trap_object),
|
|
||||||
IFSTATECHANGE);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2590,13 +2590,10 @@ static void ospfTrapNbrStateChange(struct ospf_neighbor *on)
|
|||||||
oid_copy_addr(index, &(on->address.u.prefix4), IN_ADDR_SIZE);
|
oid_copy_addr(index, &(on->address.u.prefix4), IN_ADDR_SIZE);
|
||||||
index[IN_ADDR_SIZE] = 0;
|
index[IN_ADDR_SIZE] = 0;
|
||||||
|
|
||||||
smux_trap(ospf_variables,
|
smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,
|
||||||
sizeof ospf_variables / sizeof(struct variable),
|
array_size(ospf_trap_oid), ospf_oid,
|
||||||
ospf_trap_oid, sizeof ospf_trap_oid / sizeof(oid), ospf_oid,
|
|
||||||
sizeof ospf_oid / sizeof(oid), index, IN_ADDR_SIZE + 1,
|
sizeof ospf_oid / sizeof(oid), index, IN_ADDR_SIZE + 1,
|
||||||
ospfNbrTrapList,
|
ospfNbrTrapList, array_size(ospfNbrTrapList), NBRSTATECHANGE);
|
||||||
sizeof ospfNbrTrapList / sizeof(struct trap_object),
|
|
||||||
NBRSTATECHANGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ospfTrapVirtNbrStateChange(struct ospf_neighbor *on)
|
static void ospfTrapVirtNbrStateChange(struct ospf_neighbor *on)
|
||||||
@ -2608,12 +2605,10 @@ static void ospfTrapVirtNbrStateChange(struct ospf_neighbor *on)
|
|||||||
oid_copy_addr(index, &(on->address.u.prefix4), IN_ADDR_SIZE);
|
oid_copy_addr(index, &(on->address.u.prefix4), IN_ADDR_SIZE);
|
||||||
index[IN_ADDR_SIZE] = 0;
|
index[IN_ADDR_SIZE] = 0;
|
||||||
|
|
||||||
smux_trap(ospf_variables,
|
smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,
|
||||||
sizeof ospf_variables / sizeof(struct variable),
|
array_size(ospf_trap_oid), ospf_oid,
|
||||||
ospf_trap_oid, sizeof ospf_trap_oid / sizeof(oid), ospf_oid,
|
|
||||||
sizeof ospf_oid / sizeof(oid), index, IN_ADDR_SIZE + 1,
|
sizeof ospf_oid / sizeof(oid), index, IN_ADDR_SIZE + 1,
|
||||||
ospfVirtNbrTrapList,
|
ospfVirtNbrTrapList, array_size(ospfVirtNbrTrapList),
|
||||||
sizeof ospfVirtNbrTrapList / sizeof(struct trap_object),
|
|
||||||
VIRTNBRSTATECHANGE);
|
VIRTNBRSTATECHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2649,13 +2644,10 @@ static void ospfTrapIfStateChange(struct ospf_interface *oi)
|
|||||||
oid_copy_addr(index, &(oi->address->u.prefix4), IN_ADDR_SIZE);
|
oid_copy_addr(index, &(oi->address->u.prefix4), IN_ADDR_SIZE);
|
||||||
index[IN_ADDR_SIZE] = 0;
|
index[IN_ADDR_SIZE] = 0;
|
||||||
|
|
||||||
smux_trap(ospf_variables,
|
smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,
|
||||||
sizeof ospf_variables / sizeof(struct variable),
|
array_size(ospf_trap_oid), ospf_oid,
|
||||||
ospf_trap_oid, sizeof ospf_trap_oid / sizeof(oid), ospf_oid,
|
|
||||||
sizeof ospf_oid / sizeof(oid), index, IN_ADDR_SIZE + 1,
|
sizeof ospf_oid / sizeof(oid), index, IN_ADDR_SIZE + 1,
|
||||||
ospfIfTrapList,
|
ospfIfTrapList, array_size(ospfIfTrapList), IFSTATECHANGE);
|
||||||
sizeof ospfIfTrapList / sizeof(struct trap_object),
|
|
||||||
IFSTATECHANGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ospfTrapVirtIfStateChange(struct ospf_interface *oi)
|
static void ospfTrapVirtIfStateChange(struct ospf_interface *oi)
|
||||||
@ -2667,12 +2659,10 @@ static void ospfTrapVirtIfStateChange(struct ospf_interface *oi)
|
|||||||
oid_copy_addr(index, &(oi->address->u.prefix4), IN_ADDR_SIZE);
|
oid_copy_addr(index, &(oi->address->u.prefix4), IN_ADDR_SIZE);
|
||||||
index[IN_ADDR_SIZE] = 0;
|
index[IN_ADDR_SIZE] = 0;
|
||||||
|
|
||||||
smux_trap(ospf_variables,
|
smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,
|
||||||
sizeof ospf_variables / sizeof(struct variable),
|
array_size(ospf_trap_oid), ospf_oid,
|
||||||
ospf_trap_oid, sizeof ospf_trap_oid / sizeof(oid), ospf_oid,
|
|
||||||
sizeof ospf_oid / sizeof(oid), index, IN_ADDR_SIZE + 1,
|
sizeof ospf_oid / sizeof(oid), index, IN_ADDR_SIZE + 1,
|
||||||
ospfVirtIfTrapList,
|
ospfVirtIfTrapList, array_size(ospfVirtIfTrapList),
|
||||||
sizeof ospfVirtIfTrapList / sizeof(struct trap_object),
|
|
||||||
VIRTIFSTATECHANGE);
|
VIRTIFSTATECHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ struct zebra_privs_t pimd_privs = {
|
|||||||
.vty_group = VTY_GROUP,
|
.vty_group = VTY_GROUP,
|
||||||
#endif
|
#endif
|
||||||
.caps_p = _caps_p,
|
.caps_p = _caps_p,
|
||||||
.cap_num_p = sizeof(_caps_p) / sizeof(_caps_p[0]),
|
.cap_num_p = array_size(_caps_p),
|
||||||
.cap_num_i = 0};
|
.cap_num_i = 0};
|
||||||
|
|
||||||
static const struct frr_yang_module_info *pimd_yang_modules[] = {
|
static const struct frr_yang_module_info *pimd_yang_modules[] = {
|
||||||
|
@ -158,7 +158,7 @@ static void test_range_lookup(void)
|
|||||||
"1.16.160.0/19", "1.16.32.0/20",
|
"1.16.160.0/19", "1.16.32.0/20",
|
||||||
"1.16.32.0/21", "16.0.0.0/16"};
|
"1.16.32.0/21", "16.0.0.0/16"};
|
||||||
|
|
||||||
int num_prefixes = sizeof(prefixes) / sizeof(prefixes[0]);
|
int num_prefixes = array_size(prefixes);
|
||||||
|
|
||||||
for (int i = 0; i < num_prefixes; i++)
|
for (int i = 0; i < num_prefixes; i++)
|
||||||
add_node(table, prefixes[i]);
|
add_node(table, prefixes[i]);
|
||||||
|
@ -205,7 +205,7 @@ struct peer test_mp_list_peer[] = {
|
|||||||
{.local_as = 1, .as = 2}, {.local_as = 1, .as = 2},
|
{.local_as = 1, .as = 2}, {.local_as = 1, .as = 2},
|
||||||
{.local_as = 1, .as = 2},
|
{.local_as = 1, .as = 2},
|
||||||
};
|
};
|
||||||
int test_mp_list_peer_count = sizeof(test_mp_list_peer) / sizeof(struct peer);
|
int test_mp_list_peer_count = array_size(test_mp_list_peer);
|
||||||
struct attr test_mp_list_attr[4];
|
struct attr test_mp_list_attr[4];
|
||||||
struct bgp_path_info test_mp_list_info[] = {
|
struct bgp_path_info test_mp_list_info[] = {
|
||||||
{.peer = &test_mp_list_peer[0], .attr = &test_mp_list_attr[0]},
|
{.peer = &test_mp_list_peer[0], .attr = &test_mp_list_attr[0]},
|
||||||
@ -214,8 +214,7 @@ struct bgp_path_info test_mp_list_info[] = {
|
|||||||
{.peer = &test_mp_list_peer[3], .attr = &test_mp_list_attr[2]},
|
{.peer = &test_mp_list_peer[3], .attr = &test_mp_list_attr[2]},
|
||||||
{.peer = &test_mp_list_peer[4], .attr = &test_mp_list_attr[3]},
|
{.peer = &test_mp_list_peer[4], .attr = &test_mp_list_attr[3]},
|
||||||
};
|
};
|
||||||
int test_mp_list_info_count =
|
int test_mp_list_info_count = array_size(test_mp_list_info);
|
||||||
sizeof(test_mp_list_info) / sizeof(struct bgp_path_info);
|
|
||||||
|
|
||||||
static int setup_bgp_mp_list(testcase_t *t)
|
static int setup_bgp_mp_list(testcase_t *t)
|
||||||
{
|
{
|
||||||
@ -370,7 +369,7 @@ testcase_t *all_tests[] = {
|
|||||||
&test_bgp_path_info_mpath_update,
|
&test_bgp_path_info_mpath_update,
|
||||||
};
|
};
|
||||||
|
|
||||||
int all_tests_count = (sizeof(all_tests) / sizeof(testcase_t *));
|
int all_tests_count = array_size(all_tests);
|
||||||
|
|
||||||
/*=========================================================
|
/*=========================================================
|
||||||
* Test Driver Functions
|
* Test Driver Functions
|
||||||
|
@ -37,7 +37,7 @@ struct zebra_privs_t test_privs = {
|
|||||||
.vty_group = VTY_GROUP,
|
.vty_group = VTY_GROUP,
|
||||||
#endif
|
#endif
|
||||||
.caps_p = _caps_p,
|
.caps_p = _caps_p,
|
||||||
.cap_num_p = sizeof(_caps_p) / sizeof(_caps_p[0]),
|
.cap_num_p = array_size(_caps_p),
|
||||||
.cap_num_i = 0};
|
.cap_num_i = 0};
|
||||||
|
|
||||||
struct option longopts[] = {{"help", no_argument, NULL, 'h'},
|
struct option longopts[] = {{"help", no_argument, NULL, 'h'},
|
||||||
|
@ -478,7 +478,7 @@ static void test_iter_pause(void)
|
|||||||
const char *prefixes[] = {"1.0.1.0/24", "1.0.1.0/25", "1.0.1.128/25",
|
const char *prefixes[] = {"1.0.1.0/24", "1.0.1.0/25", "1.0.1.128/25",
|
||||||
"1.0.2.0/24", "2.0.0.0/8"};
|
"1.0.2.0/24", "2.0.0.0/8"};
|
||||||
|
|
||||||
num_prefixes = sizeof(prefixes) / sizeof(prefixes[0]);
|
num_prefixes = array_size(prefixes);
|
||||||
|
|
||||||
printf("\n\nTesting that route_table_iter_pause() works as expected\n");
|
printf("\n\nTesting that route_table_iter_pause() works as expected\n");
|
||||||
table = route_table_init();
|
table = route_table_init();
|
||||||
|
Loading…
Reference in New Issue
Block a user