From: Jérémie Galarneau Date: Tue, 12 Mar 2024 19:57:31 +0000 (-0400) Subject: Clean-up: sessiond: use empty() instead of comparing size to 0 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=20c4b46aee1a984bc558b483826c1078f24d35e9;p=lttng-tools.git Clean-up: sessiond: use empty() instead of comparing size to 0 Harmonize the project's coding style a little by favoring the use of the 'empty()' methood of containers rather than comparing their size to 0. Signed-off-by: Jérémie Galarneau Change-Id: I22e6b7fe4d94d8f43362fe119b4ca6d480587291 --- diff --git a/src/bin/lttng-sessiond/ctf2-trace-class-visitor.cpp b/src/bin/lttng-sessiond/ctf2-trace-class-visitor.cpp index 8da98591d..71a2e48d2 100644 --- a/src/bin/lttng-sessiond/ctf2-trace-class-visitor.cpp +++ b/src/bin/lttng-sessiond/ctf2-trace-class-visitor.cpp @@ -165,7 +165,7 @@ private: _fragment["alignment"] = type.alignment; _fragment["preferred-display-base"] = (unsigned int) type.base_; - if (type.roles_.size() > 0) { + if (!type.roles_.empty()) { json::json role_array = json::json::array(); for (const auto role : type.roles_) { @@ -201,7 +201,7 @@ private: _fragment["alignment"] = type.alignment; _fragment["preferred-display-base"] = (unsigned int) type.base_; - if (type.roles_.size() > 0) { + if (!type.roles_.empty()) { if (std::is_signed::value) { LTTNG_THROW_ERROR( @@ -278,7 +278,7 @@ private: _fragment["type"] = "static-length-blob"; _fragment["length"] = type.length_bytes; - if (type.roles_.size() > 0) { + if (!type.roles_.empty()) { auto role_array = json::json::array(); for (const auto role : type.roles_) { diff --git a/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp b/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp index c30f47efb..83f4a2427 100644 --- a/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp +++ b/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp @@ -566,7 +566,7 @@ private: void visit(const lst::static_length_array_type& type) final { if (type.alignment != 0) { - LTTNG_ASSERT(_current_field_name.size() > 0); + LTTNG_ASSERT(!_current_field_name.empty()); _description += lttng::format( "struct {{ }} align({alignment}) {field_name}_padding;\n", fmt::arg("alignment", type.alignment), @@ -587,7 +587,7 @@ private: * could wrap nested sequences in structures, which * would allow us to express alignment constraints. */ - LTTNG_ASSERT(_current_field_name.size() > 0); + LTTNG_ASSERT(!_current_field_name.empty()); _description += lttng::format( "struct {{ }} align({alignment}) {field_name}_padding;\n", fmt::arg("alignment", type.alignment), @@ -676,7 +676,7 @@ private: void visit_variant(const lst::variant_type& type) { if (type.alignment != 0) { - LTTNG_ASSERT(_current_field_name.size() > 0); + LTTNG_ASSERT(!_current_field_name.empty()); _description += lttng::format( "struct {{ }} align({alignment}) {field_name}_padding;\n", fmt::arg("alignment", type.alignment),