]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: fix some misc SA warnings
authorMark Stapp <mjs@voltanet.io>
Fri, 26 Feb 2021 16:16:09 +0000 (11:16 -0500)
committerMark Stapp <mjs@voltanet.io>
Fri, 26 Feb 2021 16:16:09 +0000 (11:16 -0500)
- clippy.c: fix valid memleak
- defun_lex.l: suppress warnings in generated code
- northbound_cli.c: suppress warning in eldritch libyang macro

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
lib/clippy.c
lib/defun_lex.l
lib/northbound_cli.c

index 2e09c24c66f8531bc149bb7fbdd1fb9e4e9faef0..d37d06054c7a1882d798382ec19f75bd9740ac64 100644 (file)
@@ -51,7 +51,8 @@ int main(int argc, char **argv)
 #if PY_VERSION_HEX >= 0x03040000 /* 3.4 */
        Py_SetStandardStreamEncoding("UTF-8", NULL);
 #endif
-       Py_SetProgramName(wconv(argv[0]));
+       char *name = wconv(argv[0]);
+       Py_SetProgramName(name);
        PyImport_AppendInittab("_clippy", command_py_init);
 
        Py_Initialize();
@@ -93,6 +94,7 @@ int main(int argc, char **argv)
        for (int i = 1; i < argc; i++)
                free(wargv[i - 1]);
 #endif
+       free(name);
        free(wargv);
        return 0;
 }
index bc5fbd24d9c7fb639b668b95500fa804025deb4e..af506f13d6ec3b84a981a67a3f26cf24f56b13fc 100644 (file)
@@ -80,6 +80,8 @@ static void extendbuf(char **what, const char *arg)
 }
 #define extend(x) extendbuf(&value, x)
 
+#ifndef __clang_analyzer__
+
 %}
 
 ID             [A-Za-z0-9_]+
@@ -157,6 +159,8 @@ SPECIAL             [(),]
 
 %%
 
+#endif /* __clang_analyzer__ */
+
 static int yylex_clr(char **retbuf)
 {
        int rv = def_yylex();
index 6ce520149ab058756860d6274b91ac5d4ee1a9f4..9e26fab28c227be3715c24148328e2389f153121 100644 (file)
@@ -595,7 +595,19 @@ void nb_cli_show_dnode_cmds(struct vty *vty, struct lyd_node *root,
                                (*nb_node->cbs.cli_show_end)(vty, parent);
                }
 
+               /*
+                * There is a possible path in this macro that ends up
+                * dereferencing child->parent->parent. We just null checked
+                * child->parent by checking (ly_iter_next_up(child) != NULL)
+                * above.
+                *
+                * I am not sure whether it is possible for the other
+                * conditions within this macro guarding the problem
+                * dereference to be satisfied when child->parent == NULL.
+                */
+#ifndef __clang_analyzer__
                LY_TREE_DFS_END(root, next, child);
+#endif
        }
 }