diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2017-06-20 23:56:50 +0000 |
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2017-06-21 15:22:21 +0000 |
| commit | 56b40679304df9c4bfcfd5764af24f1d35b86142 (patch) | |
| tree | 755de54cbc890545f73efe5f1f4d1843506d1860 /ripd/rip_interface.c | |
| parent | d368cd48b94cb9a22b9733200d8cfd94c71338ce (diff) | |
*: simplify log message lookup
log.c provides functionality for associating a constant (typically a
protocol constant) with a string and finding the string given the
constant. However this is highly delicate code that is extremely prone
to stack overflows and off-by-one's due to requiring the developer to
always remember to update the array size constant and to do so correctly
which, as shown by example, is never a good idea.b
The original goal of this code was to try to implement lookups in O(1)
time without a linear search through the message array. Since this code
is used 99% of the time for debugs, it's worth the 5-6 additional cmp's
worst case if it means we avoid explitable bugs due to oversights...
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'ripd/rip_interface.c')
| -rw-r--r-- | ripd/rip_interface.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c index fce5d97dc2..4abf8dc8b1 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -58,6 +58,7 @@ const struct message ri_version_msg[] = {RI_RIP_VERSION_2, "2"}, {RI_RIP_VERSION_1_AND_2, "1 2"}, {RI_RIP_VERSION_NONE, "none"}, + { 0 } }; extern struct zebra_privs_t ripd_privs; @@ -1905,12 +1906,12 @@ rip_interface_config_write (struct vty *vty) /* RIP version setting. */ if (ri->ri_send != RI_RIP_UNSPEC) vty_out (vty, " ip rip send version %s%s", - lookup (ri_version_msg, ri->ri_send), + lookup_msg(ri_version_msg, ri->ri_send, NULL), VTY_NEWLINE); if (ri->ri_receive != RI_RIP_UNSPEC) vty_out (vty, " ip rip receive version %s%s", - lookup (ri_version_msg, ri->ri_receive), + lookup_msg(ri_version_msg, ri->ri_receive, NULL), VTY_NEWLINE); if (ri->v2_broadcast) |
