]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/command_py.c
Merge pull request #11076 from routingrocks/vrrp_master_ad_cli
[mirror_frr.git] / lib / command_py.c
index 58b7982665571a927b3cb0951ed622b2573f95a9..6301eec5e8ee1c6ee2604125bdccc79e222fc962 100644 (file)
  * memory leak or SEGV for things that haven't been well-tested.
  */
 
+/* This file is "exempt" from having
+#include "config.h"
+ * as the first include statement because Python.h also does environment
+ * setup & these trample over each other.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 #include <Python.h>
 #include "structmember.h"
 #include <string.h>
@@ -191,21 +200,30 @@ static PyObject *graph_to_pyobj(struct wrap_graph *wgraph,
        if (gn->data) {
                struct cmd_token *tok = gn->data;
                switch (tok->type) {
-#define item(x) case x: wrap->type = #x; break;
-                       item(WORD_TKN)                // words
-                               item(VARIABLE_TKN)    // almost anything
-                               item(RANGE_TKN)       // integer range
-                               item(IPV4_TKN)  // IPV4 addresses
-                               item(IPV4_PREFIX_TKN) // IPV4 network prefixes
-                               item(IPV6_TKN)  // IPV6 prefixes
-                               item(IPV6_PREFIX_TKN) // IPV6 network prefixes
-                               item(MAC_TKN)    // MAC address
-                               item(MAC_PREFIX_TKN)  // MAC address with mask
-
-                               /* plumbing types */
-                               item(FORK_TKN) item(JOIN_TKN) item(START_TKN)
-                                       item(END_TKN) default
-                               : wrap->type = "???";
+#define item(x)                                                                \
+       case x:                                                                \
+               wrap->type = #x;                                               \
+               break /* no semicolon */
+
+                       item(WORD_TKN);        // words
+                       item(VARIABLE_TKN);    // almost anything
+                       item(RANGE_TKN);       // integer range
+                       item(IPV4_TKN);        // IPV4 addresses
+                       item(IPV4_PREFIX_TKN); // IPV4 network prefixes
+                       item(IPV6_TKN);        // IPV6 prefixes
+                       item(IPV6_PREFIX_TKN); // IPV6 network prefixes
+                       item(MAC_TKN);         // MAC address
+                       item(MAC_PREFIX_TKN);  // MAC address with mask
+
+                       /* plumbing types */
+                       item(FORK_TKN);
+                       item(JOIN_TKN);
+                       item(START_TKN);
+                       item(END_TKN);
+                       item(NEG_ONLY_TKN);
+#undef item
+               default:
+                       wrap->type = "???";
                }
 
                wrap->deprecated = (tok->attr == CMD_ATTR_DEPRECATED);
@@ -321,6 +339,7 @@ static struct PyModuleDef pymoddef_clippy = {
        } while (0)
 #endif
 
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
 PyMODINIT_FUNC command_py_init(void)
 {
        PyObject *pymod;
@@ -338,5 +357,7 @@ PyMODINIT_FUNC command_py_init(void)
        PyModule_AddObject(pymod, "GraphNode", (PyObject *)&typeobj_graph_node);
        Py_INCREF(&typeobj_graph);
        PyModule_AddObject(pymod, "Graph", (PyObject *)&typeobj_graph);
+       if (!elf_py_init(pymod))
+               initret(NULL);
        initret(pymod);
 }