Skip to content

Commit

Permalink
Clean-up: sessiond: use empty() instead of comparing size to 0
Browse files Browse the repository at this point in the history
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 <[email protected]>
Change-Id: I22e6b7fe4d94d8f43362fe119b4ca6d480587291
  • Loading branch information
jgalar committed Mar 12, 2024
1 parent d83ba9b commit 20c4b46
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/bin/lttng-sessiond/ctf2-trace-class-visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class field_visitor : public lttng::sessiond::trace::field_visitor,
_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_) {
Expand Down Expand Up @@ -201,7 +201,7 @@ class field_visitor : public lttng::sessiond::trace::field_visitor,
_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<typename EnumerationType::mapping::range_t::
range_integer_t>::value) {
LTTNG_THROW_ERROR(
Expand Down Expand Up @@ -278,7 +278,7 @@ class field_visitor : public lttng::sessiond::trace::field_visitor,
_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_) {
Expand Down
6 changes: 3 additions & 3 deletions src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ class tsdl_field_visitor : public lttng::sessiond::trace::field_visitor,
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),
Expand All @@ -587,7 +587,7 @@ class tsdl_field_visitor : public lttng::sessiond::trace::field_visitor,
* 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),
Expand Down Expand Up @@ -676,7 +676,7 @@ class tsdl_field_visitor : public lttng::sessiond::trace::field_visitor,
void visit_variant(const lst::variant_type<MappingIntegerType>& 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),
Expand Down

0 comments on commit 20c4b46

Please sign in to comment.