From dc6fb81f4ed866cec02e592df3444052c440e24d Mon Sep 17 00:00:00 2001 From: Anda Nicolae Date: Wed, 9 May 2018 14:06:20 +0300 Subject: [PATCH] Coverity issues in contrail-common repo - Variable fp going out of scope leaks the storage it points to in misc_utils.cc:MiscUtils::GetPlatformInfo - Missing return statement in t_cpp_generator.cc:generate_sandesh_base_name - Missing return statement in sandesh_message_builder.cc:SandeshSyslogMessage::Parse - Missing return statement in sandesh_server.cc:SandeshServer::Initialize Change-Id: I02c25ec037c73a1d4e3024e257558a4f81310a49 Closes-Bug: #1770142 Signed-off-by: Anda Nicolae --- base/misc_utils.cc | 1 + sandesh/compiler/generate/t_cpp_generator.cc | 3 ++- sandesh/library/cpp/sandesh_message_builder.cc | 1 + sandesh/library/cpp/sandesh_server.cc | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/base/misc_utils.cc b/base/misc_utils.cc index f0c537e1..66619530 100644 --- a/base/misc_utils.cc +++ b/base/misc_utils.cc @@ -202,6 +202,7 @@ bool MiscUtils::GetPlatformInfo(std::string &distro, std::string &code_name) { } else { return false; } + fclose(fp); #endif return true; } diff --git a/sandesh/compiler/generate/t_cpp_generator.cc b/sandesh/compiler/generate/t_cpp_generator.cc index 2b3432a7..31681536 100755 --- a/sandesh/compiler/generate/t_cpp_generator.cc +++ b/sandesh/compiler/generate/t_cpp_generator.cc @@ -1857,8 +1857,9 @@ string generate_sandesh_base_name(t_sandesh* tsandesh, bool type) { return "SandeshFlow"; } } + } else { + return ""; } - } /** diff --git a/sandesh/library/cpp/sandesh_message_builder.cc b/sandesh/library/cpp/sandesh_message_builder.cc index cb18c0c3..0c2d240f 100644 --- a/sandesh/library/cpp/sandesh_message_builder.cc +++ b/sandesh/library/cpp/sandesh_message_builder.cc @@ -151,6 +151,7 @@ bool SandeshSyslogMessage::Parse(const uint8_t *xml_msg, size_t size) { message_node_ = xdoc_.first_child(); message_type_ = message_node_.name(); size_ = size; + return true; } // SandeshMessageBuilder diff --git a/sandesh/library/cpp/sandesh_server.cc b/sandesh/library/cpp/sandesh_server.cc index b7dd9533..8b4d623f 100644 --- a/sandesh/library/cpp/sandesh_server.cc +++ b/sandesh/library/cpp/sandesh_server.cc @@ -132,6 +132,7 @@ bool SandeshServer::Initialize(short port) { SANDESH_LOG(ERROR, "Process EXITING: TCP Server initialization failed for port " << port); exit(1); } + return true; } int SandeshServer::AllocConnectionIndex() {