You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by al...@apache.org on 2024/04/25 15:44:22 UTC
(kudu) 02/02: [util] fix TidyBot warnings in ScopedTracer
This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
commit b2a6fe26266e170b5e885d1ddac6a5f03ded1759
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Wed Apr 24 19:03:27 2024 -0700
[util] fix TidyBot warnings in ScopedTracer
This patch removes superfluous constructs from ScopedTracer, addressing
warnings output by CLANG tidy, e.g.:
2024-04-24 18:49:17,524 INFO: src/kudu/util/debug/trace_event.h:1379:3: warning: 5 uninitialized fields at the end of the constructor call [
clang-analyzer-optin.cplusplus.UninitializedObject]
ScopedTracer() : p_data_(nullptr) {}
^
...
This patch doesn't contain any functional modifications.
Change-Id: I0e2f8578180955d0c8c788a0ee160deefba6a3ca
Reviewed-on: http://gerrit.cloudera.org:8080/21352
Reviewed-by: Mahesh Reddy <mr...@cloudera.com>
Reviewed-by: Yingchun Lai <la...@apache.org>
Tested-by: Alexey Serbin <al...@apache.org>
---
src/kudu/util/debug/trace_event.h | 34 ++++++++++++++--------------------
1 file changed, 14 insertions(+), 20 deletions(-)
diff --git a/src/kudu/util/debug/trace_event.h b/src/kudu/util/debug/trace_event.h
index f43b48de3..4994ed047 100644
--- a/src/kudu/util/debug/trace_event.h
+++ b/src/kudu/util/debug/trace_event.h
@@ -1375,37 +1375,31 @@ static inline kudu::debug::TraceEventHandle AddTraceEvent(
// Used by TRACE_EVENTx macros. Do not use directly.
class ScopedTracer {
public:
- // Note: members of data_ intentionally left uninitialized. See Initialize.
- ScopedTracer() : p_data_(nullptr) {}
+ ScopedTracer()
+ : category_group_enabled_(nullptr),
+ name_(nullptr),
+ event_handle_({ 0, 0, 0 }) {
+ }
~ScopedTracer() {
- if (p_data_ && *data_.category_group_enabled)
+ if (category_group_enabled_) {
TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(
- data_.category_group_enabled, data_.name, data_.event_handle);
+ category_group_enabled_, name_, event_handle_);
+ }
}
void Initialize(const unsigned char* category_group_enabled,
const char* name,
kudu::debug::TraceEventHandle event_handle) {
- data_.category_group_enabled = category_group_enabled;
- data_.name = name;
- data_.event_handle = event_handle;
- p_data_ = &data_;
+ category_group_enabled_ = category_group_enabled;
+ name_ = name;
+ event_handle_ = event_handle;
}
private:
- // This Data struct workaround is to avoid initializing all the members
- // in Data during construction of this object, since this object is always
- // constructed, even when tracing is disabled. If the members of Data were
- // members of this class instead, compiler warnings occur about potential
- // uninitialized accesses.
- struct Data {
- const unsigned char* category_group_enabled;
- const char* name;
- kudu::debug::TraceEventHandle event_handle;
- };
- Data* p_data_;
- Data data_;
+ const unsigned char* category_group_enabled_;
+ const char* name_;
+ kudu::debug::TraceEventHandle event_handle_;
};
// Used by TRACE_EVENT_BINARY_EFFICIENTx macro. Do not use directly.