From: Jérémie Galarneau Date: Sat, 14 Jan 2023 04:56:05 +0000 (-0500) Subject: clang-tidy: add readability-simplify-boolean-expr X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=e0252788784c4c7392e5105aed0eaf745798482e;p=lttng-tools.git clang-tidy: add readability-simplify-boolean-expr Signed-off-by: Jérémie Galarneau Change-Id: I2dc131c79b9014fe4d20a58ec83d69bd6986bb85 --- diff --git a/.clang-tidy b/.clang-tidy index 666624f20..ff404e436 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -78,7 +78,8 @@ Checks: '-*, modernize-use-using, performance-*, -performance-no-int-to-ptr, - readability-redundant-member-init' + readability-redundant-member-init. + readability-simplify-boolean-expr' FormatStyle: 'file' CheckOptions: - key: bugprone-assert-side-effect.AssertMacros diff --git a/src/bin/lttng-relayd/tracefile-array.cpp b/src/bin/lttng-relayd/tracefile-array.cpp index b59e2aea1..91baa74aa 100644 --- a/src/bin/lttng-relayd/tracefile-array.cpp +++ b/src/bin/lttng-relayd/tracefile-array.cpp @@ -168,9 +168,5 @@ bool tracefile_array_seq_in_file(struct tracefile_array *tfa, uint64_t file_inde if (seq == -1ULL) { return false; } - if (seq >= tfa->tf[file_index].seq_tail && seq <= tfa->tf[file_index].seq_head) { - return true; - } else { - return false; - } + return seq >= tfa->tf[file_index].seq_tail && seq <= tfa->tf[file_index].seq_head; } diff --git a/src/bin/lttng-sessiond/field.hpp b/src/bin/lttng-sessiond/field.hpp index da1514f90..fdebe3acc 100644 --- a/src/bin/lttng-sessiond/field.hpp +++ b/src/bin/lttng-sessiond/field.hpp @@ -500,8 +500,6 @@ private: return false; } - return true; - return std::equal(a.cbegin(), a.cend(), b.cbegin(), [](const choice& choice_a, const choice& choice_b) { return choice_a.first == choice_b.first && diff --git a/src/bin/lttng-sessiond/manage-consumer.cpp b/src/bin/lttng-sessiond/manage-consumer.cpp index 702bd5050..e1d67f5bb 100644 --- a/src/bin/lttng-sessiond/manage-consumer.cpp +++ b/src/bin/lttng-sessiond/manage-consumer.cpp @@ -453,10 +453,7 @@ bool launch_consumer_management_thread(struct consumer_data *consumer_data) } wait_until_thread_is_ready(notifiers); lttng_thread_put(thread); - if (notifiers->initialization_result) { - return false; - } - return true; + return notifiers->initialization_result == 0; error: cleanup_consumer_management_thread(notifiers); error_alloc: diff --git a/src/common/runas.cpp b/src/common/runas.cpp index 7651470c8..07d9e171f 100644 --- a/src/common/runas.cpp +++ b/src/common/runas.cpp @@ -380,7 +380,7 @@ static int _mkdirat_recursive(struct run_as_data *data, struct run_as_ret *ret_v /* Safe to call as we have transitioned to the requested uid/gid. */ ret_value->u.ret = lttng_directory_handle_create_subdirectory_recursive(handle, path, mode); ret_value->_errno = errno; - ret_value->_error = (ret_value->u.ret) ? true : false; + ret_value->_error = (ret_value->u.ret) != 0; lttng_directory_handle_put(handle); end: return ret_value->u.ret; @@ -407,7 +407,7 @@ static int _mkdirat(struct run_as_data *data, struct run_as_ret *ret_value) /* Safe to call as we have transitioned to the requested uid/gid. */ ret_value->u.ret = lttng_directory_handle_create_subdirectory(handle, path, mode); ret_value->_errno = errno; - ret_value->_error = (ret_value->u.ret) ? true : false; + ret_value->_error = (ret_value->u.ret) != 0; lttng_directory_handle_put(handle); end: return ret_value->u.ret; @@ -462,7 +462,7 @@ static int _unlink(struct run_as_data *data, struct run_as_ret *ret_value) ret_value->u.ret = lttng_directory_handle_unlink_file(handle, data->u.unlink.path); ret_value->_errno = errno; - ret_value->_error = (ret_value->u.ret) ? true : false; + ret_value->_error = (ret_value->u.ret) != 0; lttng_directory_handle_put(handle); end: return ret_value->u.ret; @@ -485,7 +485,7 @@ static int _rmdir(struct run_as_data *data, struct run_as_ret *ret_value) ret_value->u.ret = lttng_directory_handle_remove_subdirectory(handle, data->u.rmdir.path); ret_value->_errno = errno; - ret_value->_error = (ret_value->u.ret) ? true : false; + ret_value->_error = (ret_value->u.ret) != 0; lttng_directory_handle_put(handle); end: return ret_value->u.ret; @@ -509,7 +509,7 @@ static int _rmdir_recursive(struct run_as_data *data, struct run_as_ret *ret_val ret_value->u.ret = lttng_directory_handle_remove_subdirectory_recursive( handle, data->u.rmdir.path, data->u.rmdir.flags); ret_value->_errno = errno; - ret_value->_error = (ret_value->u.ret) ? true : false; + ret_value->_error = (ret_value->u.ret) != 0; lttng_directory_handle_put(handle); end: return ret_value->u.ret; @@ -544,7 +544,7 @@ end: lttng_directory_handle_put(old_handle); lttng_directory_handle_put(new_handle); ret_value->_errno = errno; - ret_value->_error = (ret_value->u.ret) ? true : false; + ret_value->_error = (ret_value->u.ret) != 0; return ret_value->u.ret; } diff --git a/tests/unit/test_relayd_backward_compat_group_by_session.cpp b/tests/unit/test_relayd_backward_compat_group_by_session.cpp index 11ba8b032..527d41ac9 100644 --- a/tests/unit/test_relayd_backward_compat_group_by_session.cpp +++ b/tests/unit/test_relayd_backward_compat_group_by_session.cpp @@ -201,7 +201,7 @@ int main() if (!result && tests[i].is_valid) { fprintf(stderr, "Failed to get result\n"); goto loop; - } else if (!result && tests[i].is_valid == false) { + } else if (!result && !tests[i].is_valid) { pass("Returned null as expected"); goto loop; }