From: Josh Stone Date: Thu, 12 Apr 2012 19:51:24 +0000 (-0700) Subject: sdt_query: initialize probe_type/loc as unknown. X-Git-Tag: release-1.8~173 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=d61ea6024b0a465f786b11122c5bc73a11f84a93;p=systemtap.git sdt_query: initialize probe_type/loc as unknown. The fields, probe_type and probe_loc, are meaningless to start, and are later set as the queried module is examined. Commit 74fe61bc tried to make sure that all POD types in this class are initialized, but these two were essentially self-assigned. Gcc misses this uninitialized use, but clang caught it: CXX stap-tapsets.o ../tapsets.cxx:6058:38: error: field is uninitialized when used here [-Werror,-Wuninitialized] base_query(dw, params), probe_type(probe_type), probe_loc(probe_loc), base_probe(base_probe), ^ ../tapsets.cxx:6058:61: error: field is uninitialized when used here [-Werror,-Wuninitialized] base_query(dw, params), probe_type(probe_type), probe_loc(probe_loc), base_probe(base_probe), ^ Values for "unknown" are now added to these enum types to initialize with, and dealt with where needed. --- diff --git a/sdt_types.h b/sdt_types.h index 461da4c06..74ef02a38 100644 --- a/sdt_types.h +++ b/sdt_types.h @@ -18,7 +18,8 @@ typedef enum kprobe1_type = KPROBE1_TYPE, uprobe2_type = UPROBE2_TYPE, kprobe2_type = KPROBE2_TYPE, - uprobe3_type = UPROBE3_TYPE + uprobe3_type = UPROBE3_TYPE, + unknown_probe_type = -1, } stap_sdt_probe_type; typedef struct diff --git a/tapsets.cxx b/tapsets.cxx index 97cedc0c7..b998805a5 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -6009,7 +6009,7 @@ struct sdt_query : public base_query private: stap_sdt_probe_type probe_type; - enum {probe_section=0, note_section=1} probe_loc; + enum { probe_section=0, note_section=1, unknown_section=-1 } probe_loc; probe * base_probe; probe_point * base_loc; literal_map_t const & params; @@ -6055,7 +6055,8 @@ private: sdt_query::sdt_query(probe * base_probe, probe_point * base_loc, dwflpp & dw, literal_map_t const & params, vector & results, const string user_lib): - base_query(dw, params), probe_type(probe_type), probe_loc(probe_loc), base_probe(base_probe), + base_query(dw, params), probe_type(unknown_probe_type), + probe_loc(unknown_section), base_probe(base_probe), base_loc(base_loc), params(params), results(results), user_lib(user_lib), probe_scn_offset(0), probe_scn_addr(0), arg_count(0), base(0), pc(0), semaphore(0) @@ -6107,6 +6108,9 @@ sdt_query::handle_probe_entry() case kprobe2_type: clog << "kprobe2" << endl; break; + default: + clog << "unknown!" << endl; + break; } } @@ -6218,7 +6222,7 @@ sdt_query::handle_query_module() base = 0; dw.iterate_over_notes ((void*) this, &sdt_query::setup_note_probe_entry_callback); } - else + else if (probe_loc == probe_section) iterate_over_probe_entries (); }