diff options
-rw-r--r-- | babeld/babel_main.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_attr.c | 5 | ||||
-rw-r--r-- | bgpd/bgp_main.c | 4 | ||||
-rw-r--r-- | bgpd/bgp_open.c | 8 | ||||
-rw-r--r-- | isisd/isis_main.c | 2 | ||||
-rw-r--r-- | lib/buffer.c | 2 | ||||
-rw-r--r-- | lib/log.c | 24 | ||||
-rw-r--r-- | lib/sigevent.c | 9 | ||||
-rw-r--r-- | lib/sigevent.h | 1 | ||||
-rw-r--r-- | ospf6d/ospf6_main.c | 2 | ||||
-rw-r--r-- | ospf6d/ospf6_message.c | 3 | ||||
-rw-r--r-- | ospfd/ospf_api.c | 4 | ||||
-rw-r--r-- | ospfd/ospf_main.c | 4 | ||||
-rw-r--r-- | ripd/rip_main.c | 2 | ||||
-rw-r--r-- | ripngd/ripng_main.c | 2 | ||||
-rw-r--r-- | tests/test-sig.c | 2 | ||||
-rw-r--r-- | vtysh/vtysh.c | 21 | ||||
-rw-r--r-- | watchquagga/watchquagga.c | 3 | ||||
-rw-r--r-- | zebra/main.c | 4 | ||||
-rw-r--r-- | zebra/rt_netlink.c | 2 | ||||
-rw-r--r-- | zebra/test_main.c | 2 | ||||
-rw-r--r-- | zebra/zebra_rib.c | 2 |
22 files changed, 51 insertions, 59 deletions
diff --git a/babeld/babel_main.c b/babeld/babel_main.c index 2f3b5552..7b1d8799 100644 --- a/babeld/babel_main.c +++ b/babeld/babel_main.c @@ -444,7 +444,7 @@ babel_init_signals(void) }, }; - signal_init (master, Q_SIGC(babel_signals), babel_signals); + signal_init (master, array_size(babel_signals), babel_signals); } static void diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 2d82acc2..cdc99ab3 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -62,7 +62,7 @@ static const struct message attr_str [] = { BGP_ATTR_AS4_AGGREGATOR, "AS4_AGGREGATOR" }, { BGP_ATTR_AS_PATHLIMIT, "AS_PATHLIMIT" }, }; -static const int attr_str_max = sizeof(attr_str)/sizeof(attr_str[0]); +static const int attr_str_max = array_size(attr_str); static const struct message attr_flag_str[] = { @@ -72,8 +72,7 @@ static const struct message attr_flag_str[] = /* bgp_attr_flags_diagnose() relies on this bit being last in this list */ { BGP_ATTR_FLAG_EXTLEN, "Extended Length" }, }; -static const size_t attr_flag_str_max = - sizeof (attr_flag_str) / sizeof (attr_flag_str[0]); +static const size_t attr_flag_str_max = array_size(attr_flag_str); static struct hash *cluster_hash; diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index 0f1d4829..1ff1ac95 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -135,7 +135,7 @@ struct zebra_privs_t bgpd_privs = .vty_group = VTY_GROUP, #endif .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, }; @@ -422,7 +422,7 @@ main (int argc, char **argv) /* Initializations. */ srand (time (NULL)); - signal_init (master, Q_SIGC(bgp_signals), bgp_signals); + signal_init (master, array_size(bgp_signals), bgp_signals); zprivs_init (&bgpd_privs); cmd_init (1); vty_init (master); diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c index 0326d01b..d045dde5 100644 --- a/bgpd/bgp_open.c +++ b/bgpd/bgp_open.c @@ -187,8 +187,7 @@ static const struct message orf_type_str[] = { ORF_TYPE_PREFIX, "Prefixlist" }, { ORF_TYPE_PREFIX_OLD, "Prefixlist (old)" }, }; -static const int orf_type_str_max - = sizeof(orf_type_str)/sizeof(orf_type_str[0]); +static const int orf_type_str_max = array_size(orf_type_str); static const struct message orf_mode_str[] = { @@ -196,8 +195,7 @@ static const struct message orf_mode_str[] = { ORF_MODE_SEND, "Send" }, { ORF_MODE_BOTH, "Both" }, }; -static const int orf_mode_str_max - = sizeof(orf_mode_str)/sizeof(orf_mode_str[0]); +static const int orf_mode_str_max = array_size(orf_mode_str); static int bgp_capability_orf_entry (struct peer *peer, struct capability_header *hdr) @@ -449,7 +447,7 @@ static const struct message capcode_str[] = { CAPABILITY_CODE_REFRESH_OLD, "Route Refresh (Old)" }, { CAPABILITY_CODE_ORF_OLD, "ORF (Old)" }, }; -static const int capcode_str_max = sizeof(capcode_str)/sizeof(capcode_str[0]); +static const int capcode_str_max = array_size(capcode_str); /* Minimum sizes for length field of each cap (so not inc. the header) */ static const size_t cap_minsizes[] = diff --git a/isisd/isis_main.c b/isisd/isis_main.c index f5266aa2..dcbc3de9 100644 --- a/isisd/isis_main.c +++ b/isisd/isis_main.c @@ -325,7 +325,7 @@ main (int argc, char **argv, char **envp) * initializations */ zprivs_init (&isisd_privs); - signal_init (master, Q_SIGC (isisd_signals), isisd_signals); + signal_init (master, array_size (isisd_signals), isisd_signals); cmd_init (1); vty_init (master); memory_init (); diff --git a/lib/buffer.c b/lib/buffer.c index f19a9e0c..45e2e1c5 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -262,7 +262,7 @@ buffer_flush_window (struct buffer *b, int fd, int width, int height, /* For erase and more data add two to b's buffer_data count.*/ if (b->head->next == NULL) { - iov_alloc = sizeof(small_iov)/sizeof(small_iov[0]); + iov_alloc = array_size(small_iov); iov = small_iov; } else @@ -443,8 +443,8 @@ zlog_backtrace_sigsafe(int priority, void *program_counter) #define LOC s,buf+sizeof(buf)-s #ifdef HAVE_GLIBC_BACKTRACE - if (((size = backtrace(array,sizeof(array)/sizeof(array[0]))) <= 0) || - ((size_t)size > sizeof(array)/sizeof(array[0]))) + if (((size = backtrace(array,array_size(array)) <= 0) || + ((size_t)size > array_size(array)))) return; #define DUMP(FD) { \ @@ -526,12 +526,12 @@ zlog_backtrace(int priority) int size, i; char **strings; - if (((size = backtrace(array,sizeof(array)/sizeof(array[0]))) <= 0) || - ((size_t)size > sizeof(array)/sizeof(array[0]))) + if (((size = backtrace(array,array_size(array))) <= 0) || + ((size_t)size > array_size(array))) { zlog_err("Cannot get backtrace, returned invalid # of frames %d " "(valid range is between 1 and %lu)", - size, (unsigned long)(sizeof(array)/sizeof(array[0]))); + size, (unsigned long)(array_size(array))); return; } zlog(NULL, priority, "Backtrace for %d stack frames:", size); @@ -636,7 +636,7 @@ openzlog (const char *progname, zlog_proto_t protocol, zl->syslog_options = syslog_flags; /* Set default logging levels. */ - for (i = 0; i < sizeof(zl->maxlvl)/sizeof(zl->maxlvl[0]); i++) + for (i = 0; i < array_size(zl->maxlvl); i++) zl->maxlvl[i] = ZLOG_DISABLED; zl->maxlvl[ZLOG_DEST_MONITOR] = LOG_DEBUG; zl->default_lvl = LOG_DEBUG; @@ -855,14 +855,14 @@ zroute_lookup(u_int zroute) { u_int i; - if (zroute >= sizeof(route_types)/sizeof(route_types[0])) + if (zroute >= array_size(route_types)) { zlog_err("unknown zebra route type: %u", zroute); return &unknown; } if (zroute == route_types[zroute].type) return &route_types[zroute]; - for (i = 0; i < sizeof(route_types)/sizeof(route_types[0]); i++) + for (i = 0; i < array_size(route_types); i++) { if (zroute == route_types[i].type) { @@ -890,7 +890,7 @@ zebra_route_char(u_int zroute) const char * zserv_command_string (unsigned int command) { - if (command >= sizeof(command_types)/sizeof(command_types[0])) + if (command >= array_size(command_types)) { zlog_err ("unknown zserv command type: %u", command); return unknown.string; @@ -898,21 +898,17 @@ zserv_command_string (unsigned int command) return command_types[command].string; } -#define RTSIZE (sizeof(route_types)/sizeof(route_types[0])) - int proto_name2num(const char *s) { unsigned i; - for (i=0; i<RTSIZE; ++i) + for (i=0; i<array_size(route_types); ++i) if (strcasecmp(s, route_types[i].string) == 0) return route_types[i].type; return -1; } -#undef RTSIZE - int proto_redistnum(int afi, const char *s) { diff --git a/lib/sigevent.c b/lib/sigevent.c index 30e9a3d1..7d08fd97 100644 --- a/lib/sigevent.c +++ b/lib/sigevent.c @@ -22,6 +22,7 @@ #include <zebra.h> #include <sigevent.h> #include <log.h> +#include <memory.h> #ifdef SA_SIGINFO #ifdef HAVE_UCONTEXT_H @@ -266,13 +267,13 @@ trap_default_signals(void) #endif ); } sigmap[] = { - { core_signals, sizeof(core_signals)/sizeof(core_signals[0]), core_handler}, - { exit_signals, sizeof(exit_signals)/sizeof(exit_signals[0]), exit_handler}, - { ignore_signals, sizeof(ignore_signals)/sizeof(ignore_signals[0]), NULL}, + { core_signals, array_size(core_signals), core_handler}, + { exit_signals, array_size(exit_signals), exit_handler}, + { ignore_signals, array_size(ignore_signals), NULL}, }; u_int i; - for (i = 0; i < sizeof(sigmap)/sizeof(sigmap[0]); i++) + for (i = 0; i < array_size(sigmap); i++) { u_int j; diff --git a/lib/sigevent.h b/lib/sigevent.h index 62b944a7..248fa2c0 100644 --- a/lib/sigevent.h +++ b/lib/sigevent.h @@ -27,7 +27,6 @@ #include <thread.h> #define QUAGGA_SIGNAL_TIMER_INTERVAL 2L -#define Q_SIGC(sig) (sizeof(sig)/sizeof(sig[0])) struct quagga_signal_t { diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index d3ef0a6a..1bdf52fb 100644 --- a/ospf6d/ospf6_main.c +++ b/ospf6d/ospf6_main.c @@ -308,7 +308,7 @@ main (int argc, char *argv[], char *envp[]) LOG_DAEMON); zprivs_init (&ospf6d_privs); /* initialize zebra libraries */ - signal_init (master, Q_SIGC(ospf6_signals), ospf6_signals); + signal_init (master, array_size(ospf6_signals), ospf6_signals); cmd_init (1); vty_init (master); memory_init (); diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c index 01d61263..5edb70ce 100644 --- a/ospf6d/ospf6_message.c +++ b/ospf6d/ospf6_message.c @@ -58,8 +58,7 @@ static const struct message ospf6_message_type_str [] = { OSPF6_MESSAGE_TYPE_LSUPDATE, "LSUpdate" }, { OSPF6_MESSAGE_TYPE_LSACK, "LSAck" }, }; -static const size_t ospf6_message_type_str_max = - sizeof (ospf6_message_type_str) / sizeof (ospf6_message_type_str[0]); +static const size_t ospf6_message_type_str_max = array_size(ospf6_message_type_str); /* Minimum (besides the standard OSPF packet header) lengths for OSPF packets of particular types, offset is the "type" field. */ diff --git a/ospfd/ospf_api.c b/ospfd/ospf_api.c index fc3b51dd..74a49e3b 100644 --- a/ospfd/ospf_api.c +++ b/ospfd/ospf_api.c @@ -155,7 +155,7 @@ ospf_api_typename (int msgtype) { MSG_NSM_CHANGE, "NSM change", }, }; - int i, n = sizeof (NameTab) / sizeof (NameTab[0]); + int i, n = array_size(NameTab); const char *name = NULL; for (i = 0; i < n; i++) @@ -187,7 +187,7 @@ ospf_api_errname (int errcode) { OSPF_API_UNDEF, "Undefined", }, }; - int i, n = sizeof (NameTab) / sizeof (NameTab[0]); + int i, n = array_size(NameTab); const char *name = NULL; for (i = 0; i < n; i++) diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c index bad674b6..1448c7d8 100644 --- a/ospfd/ospf_main.c +++ b/ospfd/ospf_main.c @@ -68,7 +68,7 @@ struct zebra_privs_t ospfd_privs = .vty_group = VTY_GROUP, #endif .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 }; @@ -285,7 +285,7 @@ main (int argc, char **argv) /* Library inits. */ zprivs_init (&ospfd_privs); - signal_init (master, Q_SIGC(ospf_signals), ospf_signals); + signal_init (master, array_size(ospf_signals), ospf_signals); cmd_init (1); debug_init (); vty_init (master); diff --git a/ripd/rip_main.c b/ripd/rip_main.c index ccb5fa01..6a9fa71d 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -275,7 +275,7 @@ main (int argc, char **argv) /* Library initialization. */ zprivs_init (&ripd_privs); - signal_init (master, Q_SIGC(ripd_signals), ripd_signals); + signal_init (master, array_size(ripd_signals), ripd_signals); cmd_init (1); vty_init (master); memory_init (); diff --git a/ripngd/ripng_main.c b/ripngd/ripng_main.c index f4a62440..20225b7d 100644 --- a/ripngd/ripng_main.c +++ b/ripngd/ripng_main.c @@ -272,7 +272,7 @@ main (int argc, char **argv) /* Library inits. */ zprivs_init (&ripngd_privs); - signal_init (master, Q_SIGC(ripng_signals), ripng_signals); + signal_init (master, array_size(ripng_signals), ripng_signals); cmd_init (1); vty_init (master); memory_init (); diff --git a/tests/test-sig.c b/tests/test-sig.c index 63aab6f0..fe428dea 100644 --- a/tests/test-sig.c +++ b/tests/test-sig.c @@ -43,7 +43,7 @@ int main (void) { master = thread_master_create (); - signal_init (master, Q_SIGC(sigs), sigs); + signal_init (master, array_size(sigs), sigs); zlog_default = openzlog("testsig", ZLOG_NONE, LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON); diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 431c08e2..e3709e07 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -61,7 +61,6 @@ struct vtysh_client { .fd = -1, .name = "babeld", .flag = VTYSH_BABELD, .path = BABEL_VTYSH_PATH}, }; -#define VTYSH_INDEX_MAX (sizeof(vtysh_client)/sizeof(vtysh_client[0])) /* We need direct access to ripd to implement vtysh_exit_ripd_only. */ static struct vtysh_client *ripd_client = NULL; @@ -374,7 +373,7 @@ vtysh_execute_func (const char *line, int pager) if (! strcmp(cmd->string,"configure terminal")) { - for (i = 0; i < VTYSH_INDEX_MAX; i++) + for (i = 0; i < array_size(vtysh_client); i++) { cmd_stat = vtysh_client_execute(&vtysh_client[i], line, fp); if (cmd_stat == CMD_WARNING) @@ -413,7 +412,7 @@ vtysh_execute_func (const char *line, int pager) } cmd_stat = CMD_SUCCESS; - for (i = 0; i < VTYSH_INDEX_MAX; i++) + for (i = 0; i < array_size(vtysh_client); i++) { if (cmd->daemon & vtysh_client[i].flag) { @@ -525,7 +524,7 @@ vtysh_config_from_file (struct vty *vty, FILE *fp) u_int i; int cmd_stat = CMD_SUCCESS; - for (i = 0; i < VTYSH_INDEX_MAX; i++) + for (i = 0; i < array_size(vtysh_client); i++) { if (cmd->daemon & vtysh_client[i].flag) { @@ -1354,7 +1353,7 @@ DEFUN (vtysh_show_memory, int ret = CMD_SUCCESS; char line[] = "show memory\n"; - for (i = 0; i < VTYSH_INDEX_MAX; i++) + for (i = 0; i < array_size(vtysh_client); i++) if ( vtysh_client[i].fd >= 0 ) { fprintf (stdout, "Memory statistics for %s:\n", @@ -1377,7 +1376,7 @@ DEFUN (vtysh_show_logging, int ret = CMD_SUCCESS; char line[] = "show logging\n"; - for (i = 0; i < VTYSH_INDEX_MAX; i++) + for (i = 0; i < array_size(vtysh_client); i++) if ( vtysh_client[i].fd >= 0 ) { fprintf (stdout,"Logging configuration for %s:\n", @@ -1733,7 +1732,7 @@ DEFUN (vtysh_write_terminal, VTY_NEWLINE); vty_out (vty, "!%s", VTY_NEWLINE); - for (i = 0; i < VTYSH_INDEX_MAX; i++) + for (i = 0; i < array_size(vtysh_client); i++) ret = vtysh_client_config (&vtysh_client[i], line); /* Integrate vtysh specific configuration. */ @@ -1807,7 +1806,7 @@ write_config_integrated(void) return CMD_SUCCESS; } - for (i = 0; i < VTYSH_INDEX_MAX; i++) + for (i = 0; i < array_size(vtysh_client); i++) ret = vtysh_client_config (&vtysh_client[i], line); vtysh_config_dump (fp); @@ -1844,7 +1843,7 @@ DEFUN (vtysh_write_memory, fprintf (stdout,"Building Configuration...\n"); - for (i = 0; i < VTYSH_INDEX_MAX; i++) + for (i = 0; i < array_size(vtysh_client); i++) ret = vtysh_client_execute (&vtysh_client[i], line, stdout); fprintf (stdout,"[OK]\n"); @@ -1934,7 +1933,7 @@ DEFUN (vtysh_show_daemons, { u_int i; - for (i = 0; i < VTYSH_INDEX_MAX; i++) + for (i = 0; i < array_size(vtysh_client); i++) if ( vtysh_client[i].fd >= 0 ) vty_out(vty, " %s", vtysh_client[i].name); vty_out(vty, "%s", VTY_NEWLINE); @@ -2184,7 +2183,7 @@ vtysh_connect_all(const char *daemon_name) int rc = 0; int matches = 0; - for (i = 0; i < VTYSH_INDEX_MAX; i++) + for (i = 0; i < array_size(vtysh_client); i++) { if (!daemon_name || !strcmp(daemon_name, vtysh_client[i].name)) { diff --git a/watchquagga/watchquagga.c b/watchquagga/watchquagga.c index b57fd3ae..c1c88921 100644 --- a/watchquagga/watchquagga.c +++ b/watchquagga/watchquagga.c @@ -27,6 +27,7 @@ #include <getopt.h> #include <sys/un.h> #include <sys/wait.h> +#include <memory.h> #ifndef MIN #define MIN(X,Y) (((X) <= (Y)) ? (X) : (Y)) @@ -1279,7 +1280,7 @@ main(int argc, char **argv) gs.restart.interval = gs.min_restart_interval; master = thread_master_create(); - signal_init (master, Q_SIGC(my_signals), my_signals); + signal_init (master, array_size(my_signals), my_signals); srandom(time(NULL)); { diff --git a/zebra/main.c b/zebra/main.c index 5b5265f2..50ac224e 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -104,7 +104,7 @@ struct zebra_privs_t zserv_privs = .vty_group = VTY_GROUP, #endif .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 }; @@ -313,7 +313,7 @@ main (int argc, char **argv) zprivs_init (&zserv_privs); /* Vty related initialize. */ - signal_init (zebrad.master, Q_SIGC(zebra_signals), zebra_signals); + signal_init (zebrad.master, array_size(zebra_signals), zebra_signals); cmd_init (1); vty_init (zebrad.master); memory_init (); diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 15475e20..ab28ad27 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -1985,7 +1985,7 @@ static void netlink_install_filter (int sock, __u32 pid) }; struct sock_fprog prog = { - .len = sizeof(filter) / sizeof(filter[0]), + .len = array_size(filter), .filter = filter, }; diff --git a/zebra/test_main.c b/zebra/test_main.c index 70a1a3a6..a9518637 100644 --- a/zebra/test_main.c +++ b/zebra/test_main.c @@ -280,7 +280,7 @@ main (int argc, char **argv) zebrad.master = thread_master_create (); /* Vty related initialize. */ - signal_init (zebrad.master, Q_SIGC(zebra_signals), zebra_signals); + signal_init (zebrad.master, array_size(zebra_signals), zebra_signals); cmd_init (1); vty_init (zebrad.master); memory_init (); diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index b8a47031..0e29e616 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -1546,7 +1546,7 @@ rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p, /* Set default distance by route type. */ if (distance == 0) { - if ((unsigned)type >= sizeof(route_info) / sizeof(route_info[0])) + if ((unsigned)type >= array_size(route_info)) distance = 150; else distance = route_info[type].distance; |