From b3104a15ba1d52619f1455a72addb5f4dca86351 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Mon, 13 Jul 2015 17:41:41 -0400 Subject: [PATCH] coverity fixes: uninitialized class members Pro tip: POD class members need explicit initialization. --- dwflpp.h | 2 ++ session.cxx | 2 ++ session.h | 8 +++++--- tapsets.cxx | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/dwflpp.h b/dwflpp.h index b43642ce0..c117cc617 100644 --- a/dwflpp.h +++ b/dwflpp.h @@ -181,6 +181,8 @@ struct loc2c_context { Dwarf_Die *die; Dwarf_Addr pc; +public: + loc2c_context(): die(0), pc(0) {} }; struct dwflpp diff --git a/session.cxx b/session.cxx index f55cb332d..c9896a2db 100644 --- a/session.cxx +++ b/session.cxx @@ -96,6 +96,7 @@ systemtap_session::systemtap_session (): suppressed_warnings(0), suppressed_errors(0), warningerr_count(0), + target_namespaces_pid(0), last_token (0) { struct utsname buf; @@ -283,6 +284,7 @@ systemtap_session::systemtap_session (const systemtap_session& other, suppressed_warnings(0), suppressed_errors(0), warningerr_count(0), + target_namespaces_pid(0), last_token (0) { release = kernel_release = kern; diff --git a/session.h b/session.h index 787b8dc2d..f1291bc53 100644 --- a/session.h +++ b/session.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2005-2014 Red Hat Inc. +// Copyright (C) 2005-2015 Red Hat Inc. // // This file is part of systemtap, and is free software. You can // redistribute it and/or modify it under the terms of the GNU General @@ -339,7 +339,6 @@ public: std::vector unused_globals; std::vector unused_probes; // see also *_probes groups below std::vector unused_functions; - // XXX: vector<*> instead please? // resolved/compiled regular expressions for the run std::map dfas; @@ -414,6 +413,8 @@ public: translator_output* op_create_auxiliary(bool trailer_p = false); + int target_namespaces_pid; + const token* last_token; void print_token (std::ostream& o, const token* tok); void print_error (const semantic_error& e); @@ -445,7 +446,8 @@ public: bool is_user_file (const std::string& name); bool is_primary_probe (derived_probe *dp); - int target_namespaces_pid; + // NB: It is very important for all of the above (and below) fields + // to be cleared in the systemtap_session ctor (session.cxx). }; struct exit_exception: public std::runtime_error diff --git a/tapsets.cxx b/tapsets.cxx index 54f9d3d02..2a50fbd92 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -425,7 +425,7 @@ symbol_table func_info *get_func_containing_address(Dwarf_Addr addr); func_info *get_first_func(); - symbol_table(module_info *mi) : mod_info(mi) {} + symbol_table(module_info *mi) : mod_info(mi), opd_section(SHN_UNDEF) {} ~symbol_table(); }; -- 2.43.5