]> git.proxmox.com Git - mirror_frr.git/commit - lib/log.c
*: simplify log message lookup
authorQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 20 Jun 2017 23:56:50 +0000 (23:56 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Wed, 21 Jun 2017 15:22:21 +0000 (15:22 +0000)
commit56b40679304df9c4bfcfd5764af24f1d35b86142
tree755de54cbc890545f73efe5f1f4d1843506d1860
parentd368cd48b94cb9a22b9733200d8cfd94c71338ce
*: 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>
33 files changed:
bgpd/bgp_attr.c
bgpd/bgp_debug.c
bgpd/bgp_debug.h
bgpd/bgp_fsm.c
bgpd/bgp_open.c
bgpd/bgp_packet.c
bgpd/bgp_vty.c
bgpd/bgpd.h
bgpd/rfapi/rfapi_import.c
eigrpd/eigrp_dump.c
eigrpd/eigrp_hello.c
eigrpd/eigrp_packet.c
lib/grammar_sandbox.c
lib/log.c
lib/log.h
nhrpd/nhrp_vty.c
ospf6d/ospf6_message.c
ospfclient/ospfclient.c
ospfd/ospf_dump.c
ospfd/ospf_dump_api.c
ospfd/ospf_flood.c
ospfd/ospf_ism.c
ospfd/ospf_lsa.c
ospfd/ospf_nsm.c
ospfd/ospf_packet.c
ospfd/ospf_snmp.c
ospfd/ospf_vty.c
ospfd/ospfd.c
ripd/rip_interface.c
ripd/ripd.c
zebra/kernel_netlink.c
zebra/kernel_socket.c
zebra/rt_socket.c