summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2021-04-23 12:04:58 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2021-04-23 12:06:35 +0200
commit1f8031f79a5f2af850d20dfff193e4d0571cb8d3 (patch)
treefdd3c88e8182b136650977972f9e6a478fcca29e
parentb38f1fd03dacfcd2536d96379f575156d3844ee9 (diff)
*: make sure `config.h` or `zebra.h` is first
`config.h` has all the defines from autoconf, which may include things that switch behavior of other included headers (e.g. _GNU_SOURCE enabling prototypes for additional functions.) So, the first include in any `.c` file must be either `config.h` (with the appropriate guard) or `zebra.h` (which includes `config.h` first thing.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
-rw-r--r--bgpd/bgp_conditional_adv.c2
-rw-r--r--bgpd/bgp_nb.c2
-rw-r--r--bgpd/bgp_nb_config.c2
-rw-r--r--bgpd/bgp_routemap_nb.c2
-rw-r--r--bgpd/bgp_routemap_nb_config.c2
-rw-r--r--bgpd/bgp_trace.c2
-rw-r--r--eigrpd/eigrp_metric.c2
-rw-r--r--lib/libfrr_trace.c2
-rw-r--r--lib/link_state.c2
-rw-r--r--lib/routing_nb.c2
-rw-r--r--lib/routing_nb_config.c2
-rw-r--r--ospf6d/ospf6_routemap_nb.c2
-rw-r--r--ospf6d/ospf6_routemap_nb_config.c2
-rw-r--r--ospfd/ospf_routemap_nb.c2
-rw-r--r--ospfd/ospf_routemap_nb_config.c2
-rw-r--r--pathd/path_cli.c2
-rw-r--r--pathd/path_debug.c2
-rw-r--r--pathd/path_pcep_config.c2
-rw-r--r--pathd/path_pcep_debug.c2
-rw-r--r--pathd/path_zebra.c2
-rw-r--r--pceplib/pcep_msg_messages.c4
-rw-r--r--pceplib/pcep_msg_messages_encoding.c4
-rw-r--r--pceplib/pcep_msg_object_error_types.c4
-rw-r--r--pceplib/pcep_msg_objects.c4
-rw-r--r--pceplib/pcep_msg_objects_encoding.c4
-rw-r--r--pceplib/pcep_msg_tlvs.c4
-rw-r--r--pceplib/pcep_msg_tools.c4
-rw-r--r--pceplib/pcep_session_logic.c4
-rw-r--r--pceplib/pcep_session_logic_counters.c4
-rw-r--r--pceplib/pcep_session_logic_loop.c4
-rw-r--r--pceplib/pcep_session_logic_states.c4
-rw-r--r--pceplib/pcep_socket_comm_loop.c4
-rw-r--r--pceplib/pcep_socket_comm_mock.c4
-rw-r--r--pceplib/pcep_timers.c4
-rw-r--r--pceplib/pcep_timers_event_loop.c4
-rw-r--r--pceplib/pcep_utils_double_linked_list.c4
-rw-r--r--pceplib/pcep_utils_logging.c4
-rw-r--r--pceplib/pcep_utils_memory.c4
-rw-r--r--pceplib/pcep_utils_ordered_list.c4
-rw-r--r--pceplib/pcep_utils_queue.c4
-rw-r--r--pceplib/test/pcep_msg_messages_test.c4
-rw-r--r--pceplib/test/pcep_msg_messages_tests.c4
-rw-r--r--pceplib/test/pcep_msg_object_error_types_test.c4
-rw-r--r--pceplib/test/pcep_msg_objects_test.c4
-rw-r--r--pceplib/test/pcep_msg_tools_test.c4
-rw-r--r--pceplib/test/pcep_pcc_api_test.c4
-rw-r--r--pceplib/test/pcep_pcc_api_tests.c4
-rw-r--r--pceplib/test/pcep_session_logic_loop_test.c4
-rw-r--r--pceplib/test/pcep_session_logic_states_test.c4
-rw-r--r--pceplib/test/pcep_session_logic_test.c4
-rw-r--r--pceplib/test/pcep_session_logic_tests.c4
-rw-r--r--pceplib/test/pcep_socket_comm_loop_test.c4
-rw-r--r--pceplib/test/pcep_socket_comm_test.c4
-rw-r--r--pceplib/test/pcep_socket_comm_tests.c4
-rw-r--r--pceplib/test/pcep_timers_event_loop_test.c4
-rw-r--r--pceplib/test/pcep_timers_test.c4
-rw-r--r--pceplib/test/pcep_timers_tests.c4
-rw-r--r--pceplib/test/pcep_utils_counters_test.c4
-rw-r--r--pceplib/test/pcep_utils_double_linked_list_test.c4
-rw-r--r--pceplib/test/pcep_utils_memory_test.c4
-rw-r--r--pceplib/test/pcep_utils_ordered_list_test.c4
-rw-r--r--pceplib/test/pcep_utils_queue_test.c4
-rw-r--r--pceplib/test/pcep_utils_tests.c4
-rw-r--r--pimd/pim_nb_config.c2
-rw-r--r--python/firstheader.py92
-rw-r--r--staticd/static_nb.c2
-rw-r--r--staticd/static_nb_config.c2
-rw-r--r--zebra/zebra_routemap_nb.c2
68 files changed, 296 insertions, 16 deletions
diff --git a/bgpd/bgp_conditional_adv.c b/bgpd/bgp_conditional_adv.c
index b9ea26e862..6e80765f86 100644
--- a/bgpd/bgp_conditional_adv.c
+++ b/bgpd/bgp_conditional_adv.c
@@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <zebra.h>
+
#include "bgpd/bgp_conditional_adv.h"
#include "bgpd/bgp_vty.h"
diff --git a/bgpd/bgp_nb.c b/bgpd/bgp_nb.c
index 2547439499..21810b634d 100644
--- a/bgpd/bgp_nb.c
+++ b/bgpd/bgp_nb.c
@@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <zebra.h>
+
#include "northbound.h"
#include "libfrr.h"
#include "bgpd/bgp_nb.h"
diff --git a/bgpd/bgp_nb_config.c b/bgpd/bgp_nb_config.c
index 94ff362d1a..25a677fc7b 100644
--- a/bgpd/bgp_nb_config.c
+++ b/bgpd/bgp_nb_config.c
@@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <zebra.h>
+
#include "northbound.h"
#include "libfrr.h"
#include "log.h"
diff --git a/bgpd/bgp_routemap_nb.c b/bgpd/bgp_routemap_nb.c
index fc59122184..b165c5d0ee 100644
--- a/bgpd/bgp_routemap_nb.c
+++ b/bgpd/bgp_routemap_nb.c
@@ -18,6 +18,8 @@
*/
+#include <zebra.h>
+
#include "lib/command.h"
#include "lib/log.h"
#include "lib/northbound.h"
diff --git a/bgpd/bgp_routemap_nb_config.c b/bgpd/bgp_routemap_nb_config.c
index ec6284273e..ff08c16a82 100644
--- a/bgpd/bgp_routemap_nb_config.c
+++ b/bgpd/bgp_routemap_nb_config.c
@@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <zebra.h>
+
#include "lib/command.h"
#include "lib/log.h"
#include "lib/northbound.h"
diff --git a/bgpd/bgp_trace.c b/bgpd/bgp_trace.c
index 2ebc63b6b5..02afbeb46f 100644
--- a/bgpd/bgp_trace.c
+++ b/bgpd/bgp_trace.c
@@ -1,4 +1,6 @@
#define TRACEPOINT_CREATE_PROBES
#define TRACEPOINT_DEFINE
+#include <zebra.h>
+
#include "bgp_trace.h"
diff --git a/eigrpd/eigrp_metric.c b/eigrpd/eigrp_metric.c
index 2b05db71d5..ea62f9d1be 100644
--- a/eigrpd/eigrp_metric.c
+++ b/eigrpd/eigrp_metric.c
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <zebra.h>
+
#include "eigrpd/eigrp_structs.h"
#include "eigrpd/eigrpd.h"
#include "eigrpd/eigrp_types.h"
diff --git a/lib/libfrr_trace.c b/lib/libfrr_trace.c
index 2f300e6ee1..59320322ca 100644
--- a/lib/libfrr_trace.c
+++ b/lib/libfrr_trace.c
@@ -1,4 +1,6 @@
#define TRACEPOINT_CREATE_PROBES
#define TRACEPOINT_DEFINE
+#include <zebra.h>
+
#include "libfrr_trace.h"
diff --git a/lib/link_state.c b/lib/link_state.c
index 8606f8eb09..afeb89c592 100644
--- a/lib/link_state.c
+++ b/lib/link_state.c
@@ -22,6 +22,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <zebra.h>
+
#include "if.h"
#include "linklist.h"
#include "log.h"
diff --git a/lib/routing_nb.c b/lib/routing_nb.c
index 0160354a7e..6238fb055d 100644
--- a/lib/routing_nb.c
+++ b/lib/routing_nb.c
@@ -16,6 +16,8 @@
* with this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <zebra.h>
+
#include "northbound.h"
#include "libfrr.h"
#include "routing_nb.h"
diff --git a/lib/routing_nb_config.c b/lib/routing_nb_config.c
index f66f32015d..594ad6c9e8 100644
--- a/lib/routing_nb_config.c
+++ b/lib/routing_nb_config.c
@@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <zebra.h>
+
#include "northbound.h"
#include "libfrr.h"
#include "vrf.h"
diff --git a/ospf6d/ospf6_routemap_nb.c b/ospf6d/ospf6_routemap_nb.c
index b710fefbdf..faa992e026 100644
--- a/ospf6d/ospf6_routemap_nb.c
+++ b/ospf6d/ospf6_routemap_nb.c
@@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <zebra.h>
+
#include "lib/northbound.h"
#include "lib/routemap.h"
#include "ospf6_routemap_nb.h"
diff --git a/ospf6d/ospf6_routemap_nb_config.c b/ospf6d/ospf6_routemap_nb_config.c
index 3c7741e473..cd0a3260d5 100644
--- a/ospf6d/ospf6_routemap_nb_config.c
+++ b/ospf6d/ospf6_routemap_nb_config.c
@@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <zebra.h>
+
#include "lib/command.h"
#include "lib/log.h"
#include "lib/northbound.h"
diff --git a/ospfd/ospf_routemap_nb.c b/ospfd/ospf_routemap_nb.c
index 1f6b0ef78c..e53d009a55 100644
--- a/ospfd/ospf_routemap_nb.c
+++ b/ospfd/ospf_routemap_nb.c
@@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <zebra.h>
+
#include "lib/northbound.h"
#include "lib/routemap.h"
#include "ospf_routemap_nb.h"
diff --git a/ospfd/ospf_routemap_nb_config.c b/ospfd/ospf_routemap_nb_config.c
index bfb18c5e08..9026795425 100644
--- a/ospfd/ospf_routemap_nb_config.c
+++ b/ospfd/ospf_routemap_nb_config.c
@@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <zebra.h>
+
#include "lib/command.h"
#include "lib/log.h"
#include "lib/northbound.h"
diff --git a/pathd/path_cli.c b/pathd/path_cli.c
index cf14aa8c61..ecb667f985 100644
--- a/pathd/path_cli.c
+++ b/pathd/path_cli.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <zebra.h>
+
#include <float.h>
#include <math.h>
#include <zebra.h>
diff --git a/pathd/path_debug.c b/pathd/path_debug.c
index df0550715a..eec5707396 100644
--- a/pathd/path_debug.c
+++ b/pathd/path_debug.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <zebra.h>
+
#include <string.h>
#include <stdbool.h>
#include <time.h>
diff --git a/pathd/path_pcep_config.c b/pathd/path_pcep_config.c
index 107475bec9..aacbca4ae9 100644
--- a/pathd/path_pcep_config.c
+++ b/pathd/path_pcep_config.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <zebra.h>
+
#include <northbound.h>
#include <yang.h>
#include <printfrr.h>
diff --git a/pathd/path_pcep_debug.c b/pathd/path_pcep_debug.c
index d222371bbb..370484dc1b 100644
--- a/pathd/path_pcep_debug.c
+++ b/pathd/path_pcep_debug.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <zebra.h>
+
#include <string.h>
#include <stdbool.h>
#include <time.h>
diff --git a/pathd/path_zebra.c b/pathd/path_zebra.c
index 276bc9289c..8c9357460f 100644
--- a/pathd/path_zebra.c
+++ b/pathd/path_zebra.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <zebra.h>
+
#include "thread.h"
#include "log.h"
#include "lib_errors.h"
diff --git a/pceplib/pcep_msg_messages.c b/pceplib/pcep_msg_messages.c
index ec2a237f30..9bbfc5372b 100644
--- a/pceplib/pcep_msg_messages.c
+++ b/pceplib/pcep_msg_messages.c
@@ -25,6 +25,10 @@
* This is the implementation of a High Level PCEP message API.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <string.h>
#include <arpa/inet.h>
#include <stdarg.h>
diff --git a/pceplib/pcep_msg_messages_encoding.c b/pceplib/pcep_msg_messages_encoding.c
index 7c8e1b3a1f..e90ca1cfd8 100644
--- a/pceplib/pcep_msg_messages_encoding.c
+++ b/pceplib/pcep_msg_messages_encoding.c
@@ -25,6 +25,10 @@
* Encoding and decoding for PCEP messages.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
diff --git a/pceplib/pcep_msg_object_error_types.c b/pceplib/pcep_msg_object_error_types.c
index a4fd8151cd..c72dfd7061 100644
--- a/pceplib/pcep_msg_object_error_types.c
+++ b/pceplib/pcep_msg_object_error_types.c
@@ -19,6 +19,10 @@
* Author : Brady Johnson <brady@voltanet.io>
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include "pcep_msg_object_error_types.h"
diff --git a/pceplib/pcep_msg_objects.c b/pceplib/pcep_msg_objects.c
index 6c943ddc2a..e253fcc540 100644
--- a/pceplib/pcep_msg_objects.c
+++ b/pceplib/pcep_msg_objects.c
@@ -25,6 +25,10 @@
* This is the implementation of a High Level PCEP message object API.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <string.h>
#include <arpa/inet.h>
#include <stdarg.h>
diff --git a/pceplib/pcep_msg_objects_encoding.c b/pceplib/pcep_msg_objects_encoding.c
index c4089ba5ec..9ab96f7bce 100644
--- a/pceplib/pcep_msg_objects_encoding.c
+++ b/pceplib/pcep_msg_objects_encoding.c
@@ -25,6 +25,10 @@
* Encoding and decoding for PCEP Objects.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <string.h>
diff --git a/pceplib/pcep_msg_tlvs.c b/pceplib/pcep_msg_tlvs.c
index 9c84e71ee1..6298ed4b8d 100644
--- a/pceplib/pcep_msg_tlvs.c
+++ b/pceplib/pcep_msg_tlvs.c
@@ -25,6 +25,10 @@
* This is the implementation of a High Level PCEP message object TLV API.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
diff --git a/pceplib/pcep_msg_tools.c b/pceplib/pcep_msg_tools.c
index e190d2a850..8f32f2c537 100644
--- a/pceplib/pcep_msg_tools.c
+++ b/pceplib/pcep_msg_tools.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <errno.h>
#include <stdio.h>
#include <string.h>
diff --git a/pceplib/pcep_session_logic.c b/pceplib/pcep_session_logic.c
index 52655914c6..2ec2fd72a8 100644
--- a/pceplib/pcep_session_logic.c
+++ b/pceplib/pcep_session_logic.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <errno.h>
#include <limits.h>
#include <pthread.h>
diff --git a/pceplib/pcep_session_logic_counters.c b/pceplib/pcep_session_logic_counters.c
index a6bd41b4f1..fceb15af76 100644
--- a/pceplib/pcep_session_logic_counters.c
+++ b/pceplib/pcep_session_logic_counters.c
@@ -25,6 +25,10 @@
* PCEP session logic counters configuration.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdio.h>
#include <time.h>
diff --git a/pceplib/pcep_session_logic_loop.c b/pceplib/pcep_session_logic_loop.c
index 269aa1e07e..4b855c06cd 100644
--- a/pceplib/pcep_session_logic_loop.c
+++ b/pceplib/pcep_session_logic_loop.c
@@ -20,6 +20,10 @@
*
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <pthread.h>
#include <stdbool.h>
#include <stdio.h>
diff --git a/pceplib/pcep_session_logic_states.c b/pceplib/pcep_session_logic_states.c
index 3beceefad0..3e9c701a62 100644
--- a/pceplib/pcep_session_logic_states.c
+++ b/pceplib/pcep_session_logic_states.c
@@ -20,6 +20,10 @@
*
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <pthread.h>
#include <stdbool.h>
#include <stdio.h>
diff --git a/pceplib/pcep_socket_comm_loop.c b/pceplib/pcep_socket_comm_loop.c
index d58409c4f3..d9a6b9ae48 100644
--- a/pceplib/pcep_socket_comm_loop.c
+++ b/pceplib/pcep_socket_comm_loop.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <errno.h>
#include <stdbool.h>
#include <stddef.h>
diff --git a/pceplib/pcep_socket_comm_mock.c b/pceplib/pcep_socket_comm_mock.c
index 069d0cf998..7a9511e315 100644
--- a/pceplib/pcep_socket_comm_mock.c
+++ b/pceplib/pcep_socket_comm_mock.c
@@ -27,6 +27,10 @@
* created.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <netinet/in.h>
#include <stdbool.h>
#include <stdlib.h>
diff --git a/pceplib/pcep_timers.c b/pceplib/pcep_timers.c
index d0a2349d05..4c06d2b3f7 100644
--- a/pceplib/pcep_timers.c
+++ b/pceplib/pcep_timers.c
@@ -25,6 +25,10 @@
* Implementation of public API timer functions.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <limits.h>
#include <pthread.h>
#include <stddef.h>
diff --git a/pceplib/pcep_timers_event_loop.c b/pceplib/pcep_timers_event_loop.c
index 932a53eb2a..8984496717 100644
--- a/pceplib/pcep_timers_event_loop.c
+++ b/pceplib/pcep_timers_event_loop.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <errno.h>
#include <stddef.h>
#include <stdbool.h>
diff --git a/pceplib/pcep_utils_double_linked_list.c b/pceplib/pcep_utils_double_linked_list.c
index acdcee0598..696e46632a 100644
--- a/pceplib/pcep_utils_double_linked_list.c
+++ b/pceplib/pcep_utils_double_linked_list.c
@@ -20,6 +20,10 @@
*
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stddef.h>
#include <string.h>
diff --git a/pceplib/pcep_utils_logging.c b/pceplib/pcep_utils_logging.c
index 65e1abbc03..0286c23078 100644
--- a/pceplib/pcep_utils_logging.c
+++ b/pceplib/pcep_utils_logging.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdarg.h>
#include <stdio.h>
#include "pcep_utils_logging.h"
diff --git a/pceplib/pcep_utils_memory.c b/pceplib/pcep_utils_memory.c
index 7362e3433b..c564705f66 100644
--- a/pceplib/pcep_utils_memory.c
+++ b/pceplib/pcep_utils_memory.c
@@ -20,6 +20,10 @@
*
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <string.h>
diff --git a/pceplib/pcep_utils_ordered_list.c b/pceplib/pcep_utils_ordered_list.c
index f5c7f70240..81eb614494 100644
--- a/pceplib/pcep_utils_ordered_list.c
+++ b/pceplib/pcep_utils_ordered_list.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdio.h>
#include <string.h>
diff --git a/pceplib/pcep_utils_queue.c b/pceplib/pcep_utils_queue.c
index e8c3f2be0e..627533d01b 100644
--- a/pceplib/pcep_utils_queue.c
+++ b/pceplib/pcep_utils_queue.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
diff --git a/pceplib/test/pcep_msg_messages_test.c b/pceplib/test/pcep_msg_messages_test.c
index b8984a42bc..61fa94047b 100644
--- a/pceplib/test/pcep_msg_messages_test.c
+++ b/pceplib/test/pcep_msg_messages_test.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <CUnit/CUnit.h>
diff --git a/pceplib/test/pcep_msg_messages_tests.c b/pceplib/test/pcep_msg_messages_tests.c
index bd85a16530..f24a797f77 100644
--- a/pceplib/test/pcep_msg_messages_tests.c
+++ b/pceplib/test/pcep_msg_messages_tests.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>
#include <CUnit/TestDB.h>
diff --git a/pceplib/test/pcep_msg_object_error_types_test.c b/pceplib/test/pcep_msg_object_error_types_test.c
index 7275eaf098..b1463751d6 100644
--- a/pceplib/test/pcep_msg_object_error_types_test.c
+++ b/pceplib/test/pcep_msg_object_error_types_test.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdio.h>
#include <CUnit/CUnit.h>
diff --git a/pceplib/test/pcep_msg_objects_test.c b/pceplib/test/pcep_msg_objects_test.c
index a4c069945c..e0814de543 100644
--- a/pceplib/test/pcep_msg_objects_test.c
+++ b/pceplib/test/pcep_msg_objects_test.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <CUnit/CUnit.h>
diff --git a/pceplib/test/pcep_msg_tools_test.c b/pceplib/test/pcep_msg_tools_test.c
index ff5fc62390..787df2fd7a 100644
--- a/pceplib/test/pcep_msg_tools_test.c
+++ b/pceplib/test/pcep_msg_tools_test.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
diff --git a/pceplib/test/pcep_pcc_api_test.c b/pceplib/test/pcep_pcc_api_test.c
index c227dc1a3d..4adbb6374e 100644
--- a/pceplib/test/pcep_pcc_api_test.c
+++ b/pceplib/test/pcep_pcc_api_test.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <netdb.h> // gethostbyname
#include <pthread.h>
#include <stdlib.h>
diff --git a/pceplib/test/pcep_pcc_api_tests.c b/pceplib/test/pcep_pcc_api_tests.c
index 04895d6340..5d9e92c1d3 100644
--- a/pceplib/test/pcep_pcc_api_tests.c
+++ b/pceplib/test/pcep_pcc_api_tests.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>
#include <CUnit/TestDB.h>
diff --git a/pceplib/test/pcep_session_logic_loop_test.c b/pceplib/test/pcep_session_logic_loop_test.c
index 3a40f59bb9..d68b200549 100644
--- a/pceplib/test/pcep_session_logic_loop_test.c
+++ b/pceplib/test/pcep_session_logic_loop_test.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
diff --git a/pceplib/test/pcep_session_logic_states_test.c b/pceplib/test/pcep_session_logic_states_test.c
index f75c16e397..24741fa345 100644
--- a/pceplib/test/pcep_session_logic_states_test.c
+++ b/pceplib/test/pcep_session_logic_states_test.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <string.h>
diff --git a/pceplib/test/pcep_session_logic_test.c b/pceplib/test/pcep_session_logic_test.c
index 66db4fbaea..503e77c20e 100644
--- a/pceplib/test/pcep_session_logic_test.c
+++ b/pceplib/test/pcep_session_logic_test.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <string.h>
#include <time.h>
diff --git a/pceplib/test/pcep_session_logic_tests.c b/pceplib/test/pcep_session_logic_tests.c
index 67bf6e22ef..9a15390c1b 100644
--- a/pceplib/test/pcep_session_logic_tests.c
+++ b/pceplib/test/pcep_session_logic_tests.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>
#include <CUnit/TestDB.h>
diff --git a/pceplib/test/pcep_socket_comm_loop_test.c b/pceplib/test/pcep_socket_comm_loop_test.c
index 94f0983ca7..748cf433e6 100644
--- a/pceplib/test/pcep_socket_comm_loop_test.c
+++ b/pceplib/test/pcep_socket_comm_loop_test.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <pthread.h>
#include <stdlib.h>
diff --git a/pceplib/test/pcep_socket_comm_test.c b/pceplib/test/pcep_socket_comm_test.c
index 35afbcbb13..0ab38bf96e 100644
--- a/pceplib/test/pcep_socket_comm_test.c
+++ b/pceplib/test/pcep_socket_comm_test.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <netinet/in.h>
#include <CUnit/CUnit.h>
diff --git a/pceplib/test/pcep_socket_comm_tests.c b/pceplib/test/pcep_socket_comm_tests.c
index 293678f1a7..6a5839d3d0 100644
--- a/pceplib/test/pcep_socket_comm_tests.c
+++ b/pceplib/test/pcep_socket_comm_tests.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>
#include <CUnit/TestDB.h>
diff --git a/pceplib/test/pcep_timers_event_loop_test.c b/pceplib/test/pcep_timers_event_loop_test.c
index ae63601df2..79ed84bfeb 100644
--- a/pceplib/test/pcep_timers_event_loop_test.c
+++ b/pceplib/test/pcep_timers_event_loop_test.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <CUnit/CUnit.h>
diff --git a/pceplib/test/pcep_timers_test.c b/pceplib/test/pcep_timers_test.c
index 9d9e0f6c1b..e5be90a8ed 100644
--- a/pceplib/test/pcep_timers_test.c
+++ b/pceplib/test/pcep_timers_test.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdbool.h>
#include <CUnit/CUnit.h>
diff --git a/pceplib/test/pcep_timers_tests.c b/pceplib/test/pcep_timers_tests.c
index adfea17e29..f3aa8307a7 100644
--- a/pceplib/test/pcep_timers_tests.c
+++ b/pceplib/test/pcep_timers_tests.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>
#include <CUnit/TestDB.h>
diff --git a/pceplib/test/pcep_utils_counters_test.c b/pceplib/test/pcep_utils_counters_test.c
index 6f53e4d400..bcdce36188 100644
--- a/pceplib/test/pcep_utils_counters_test.c
+++ b/pceplib/test/pcep_utils_counters_test.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <CUnit/CUnit.h>
diff --git a/pceplib/test/pcep_utils_double_linked_list_test.c b/pceplib/test/pcep_utils_double_linked_list_test.c
index d2600e66c4..4eb85816b9 100644
--- a/pceplib/test/pcep_utils_double_linked_list_test.c
+++ b/pceplib/test/pcep_utils_double_linked_list_test.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <CUnit/CUnit.h>
#include "pcep_utils_double_linked_list.h"
diff --git a/pceplib/test/pcep_utils_memory_test.c b/pceplib/test/pcep_utils_memory_test.c
index b0b528f084..0958626a0c 100644
--- a/pceplib/test/pcep_utils_memory_test.c
+++ b/pceplib/test/pcep_utils_memory_test.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <stdint.h>
diff --git a/pceplib/test/pcep_utils_ordered_list_test.c b/pceplib/test/pcep_utils_ordered_list_test.c
index fe9ee58825..d20f5e68af 100644
--- a/pceplib/test/pcep_utils_ordered_list_test.c
+++ b/pceplib/test/pcep_utils_ordered_list_test.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <CUnit/CUnit.h>
#include "pcep_utils_ordered_list.h"
diff --git a/pceplib/test/pcep_utils_queue_test.c b/pceplib/test/pcep_utils_queue_test.c
index 1731457789..061dfbf37b 100644
--- a/pceplib/test/pcep_utils_queue_test.c
+++ b/pceplib/test/pcep_utils_queue_test.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <CUnit/CUnit.h>
#include "pcep_utils_queue.h"
diff --git a/pceplib/test/pcep_utils_tests.c b/pceplib/test/pcep_utils_tests.c
index 452b9fa09c..ad9f76933a 100644
--- a/pceplib/test/pcep_utils_tests.c
+++ b/pceplib/test/pcep_utils_tests.c
@@ -21,6 +21,10 @@
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>
#include <CUnit/TestDB.h>
diff --git a/pimd/pim_nb_config.c b/pimd/pim_nb_config.c
index f64adc6254..cf712bfbca 100644
--- a/pimd/pim_nb_config.c
+++ b/pimd/pim_nb_config.c
@@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <zebra.h>
+
#include "pimd.h"
#include "pim_nb.h"
#include "lib/northbound_cli.h"
diff --git a/python/firstheader.py b/python/firstheader.py
index bf50f33a33..892e9da8d6 100644
--- a/python/firstheader.py
+++ b/python/firstheader.py
@@ -1,30 +1,90 @@
-#
# check that the first header included in C files is either
# zebra.h or config.h
#
+# Copyright (C) 2020 David Lamparter for NetDEF, Inc.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; see the file COPYING; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-import sys, os, re, subprocess
+import sys
+import os
+import re
+import subprocess
+import argparse
+
+argp = argparse.ArgumentParser(description="include fixer")
+argp.add_argument("--autofix", action="store_const", const=True)
+argp.add_argument("--warn-empty", action="store_const", const=True)
+argp.add_argument("--pipe", action="store_const", const=True)
include_re = re.compile('^#\s*include\s+["<]([^ ">]+)[">]', re.M)
-errors = 0
+ignore = [
+ lambda fn: fn.startswith("tools/"),
+ lambda fn: fn
+ in [
+ "lib/elf_py.c",
+ ],
+]
+
+
+def run(args):
+ out = []
+
+ files = subprocess.check_output(["git", "ls-files"]).decode("ASCII")
+ for fn in files.splitlines():
+ if not fn.endswith(".c"):
+ continue
+ if max([i(fn) for i in ignore]):
+ continue
+
+ with open(fn, "r") as fd:
+ data = fd.read()
-files = subprocess.check_output(["git", "ls-files"]).decode("ASCII")
-for fn in files.splitlines():
- if not fn.endswith(".c"):
- continue
- if fn.startswith("tools/"):
- continue
- with open(fn, "r") as fd:
- data = fd.read()
m = include_re.search(data)
if m is None:
- # sys.stderr.write('no #include in %s?\n' % (fn))
+ if args.warn_empty:
+ sys.stderr.write("no #include in %s?\n" % (fn))
continue
if m.group(1) in ["config.h", "zebra.h", "lib/zebra.h"]:
continue
- sys.stderr.write("%s: %s\n" % (fn, m.group(0)))
- errors += 1
-if errors:
- sys.exit(1)
+ if args.autofix:
+ sys.stderr.write("%s: %s - fixing\n" % (fn, m.group(0)))
+ if fn.startswith("pceplib/"):
+ insert = '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif\n\n'
+ else:
+ insert = "#include <zebra.h>\n\n"
+
+ pos = m.span()[0]
+
+ data = data[:pos] + insert + data[pos:]
+ with open(fn + ".new", "w") as fd:
+ fd.write(data)
+ os.rename(fn + ".new", fn)
+ else:
+ sys.stderr.write("%s: %s\n" % (fn, m.group(0)))
+ out.append(fn)
+
+ if len(out):
+ if args.pipe:
+ # for "vim `firstheader.py`"
+ print("\n".join(out))
+ return 1
+ return 0
+
+
+if __name__ == "__main__":
+ args = argp.parse_args()
+ sys.exit(run(args))
diff --git a/staticd/static_nb.c b/staticd/static_nb.c
index a2a14751cf..aa9076aa88 100644
--- a/staticd/static_nb.c
+++ b/staticd/static_nb.c
@@ -16,6 +16,8 @@
* with this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <zebra.h>
+
#include "northbound.h"
#include "libfrr.h"
#include "static_nb.h"
diff --git a/staticd/static_nb_config.c b/staticd/static_nb_config.c
index db154992f9..e78f5172a3 100644
--- a/staticd/static_nb_config.c
+++ b/staticd/static_nb_config.c
@@ -16,6 +16,8 @@
* with this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <zebra.h>
+
#include "northbound.h"
#include "libfrr.h"
#include "log.h"
diff --git a/zebra/zebra_routemap_nb.c b/zebra/zebra_routemap_nb.c
index c82c34dd53..9da4589501 100644
--- a/zebra/zebra_routemap_nb.c
+++ b/zebra/zebra_routemap_nb.c
@@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <zebra.h>
+
#include "northbound.h"
#include "libfrr.h"
#include "zebra_routemap_nb.h"