]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: fix route-map YANG module on old gcc versions 5104/head
authorRafael Zalamena <rzalamena@opensourcerouting.org>
Wed, 5 Feb 2020 14:09:31 +0000 (11:09 -0300)
committerRafael Zalamena <rzalamena@opensourcerouting.org>
Wed, 5 Feb 2020 14:09:31 +0000 (11:09 -0300)
Copy the fix made in 'lib/if.c' to 'lib/routemap_northbound.c' so we can
have a working YANG model when compiled with GCC version less than 5.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
lib/routemap_northbound.c

index 3173a708e41e6031bfb060ca7a3899cb882123c8..78f2a5a018fcec108b27edc8f071280ea45d9cc9 100644 (file)
@@ -1224,7 +1224,32 @@ lib_route_map_entry_set_action_tag_destroy(enum nb_event event,
 }
 
 /* clang-format off */
+#if defined(__GNUC__) && ((__GNUC__ - 0) < 5) && !defined(__clang__)
+/*
+ * gcc versions before 5.x miscalculate the size for structs with variable
+ * length arrays (they just count it as size 0)
+ */
+struct frr_yang_module_info_sizen {
+       /* YANG module name. */
+       const char *name;
+
+       /* Northbound callbacks. */
+       const struct {
+               /* Data path of this YANG node. */
+               const char *xpath;
+
+               /* Callbacks implemented for this node. */
+               struct nb_callbacks cbs;
+
+               /* Priority - lower priorities are processed first. */
+               uint32_t priority;
+       } nodes[28];
+};
+
+const struct frr_yang_module_info_sizen frr_route_map_info_sizen asm("frr_route_map_info") = {
+#else
 const struct frr_yang_module_info frr_route_map_info = {
+#endif
        .name = "frr-route-map",
        .nodes = {
                {