Clang reports potiential leak of memory pointed to by 'pname'.
We already free the previous subporgram name when setting the
new subprogram name, and once the running thread exits, the
name of the process will be free by the system.  Thus, we don't
need to explicitly free it, so exclude the clang analyzer as a
workaround.

Signed-off-by: William Tu <[email protected]>
---
 lib/util.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/util.c b/lib/util.c
index a26cd51dcf6d..7153e8b8a5b6 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -534,6 +534,7 @@ get_subprogram_name(void)
 void
 set_subprogram_name(const char *subprogram_name)
 {
+#ifndef __clang_analyzer__
     char *pname = xstrdup(subprogram_name ? subprogram_name : program_name);
     free(subprogram_name_set(pname));
 
@@ -544,6 +545,7 @@ set_subprogram_name(const char *subprogram_name)
 #elif HAVE_PTHREAD_SET_NAME_NP
     pthread_set_name_np(pthread_self(), pname);
 #endif
+#endif
 }
 
 unsigned int
-- 
2.7.4

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to