clang-tidy: add readability-simplify-boolean-expr
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 14 Jan 2023 04:56:05 +0000 (23:56 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 17 Jan 2023 03:40:21 +0000 (22:40 -0500)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I2dc131c79b9014fe4d20a58ec83d69bd6986bb85

.clang-tidy
src/bin/lttng-relayd/tracefile-array.cpp
src/bin/lttng-sessiond/field.hpp
src/bin/lttng-sessiond/manage-consumer.cpp
src/common/runas.cpp
tests/unit/test_relayd_backward_compat_group_by_session.cpp

index 666624f20cf8766f00af6f43283a97a9104b6aea..ff404e436ee757432a73352111a6e5bcc95bd9d6 100644 (file)
@@ -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
index b59e2aea17c8e493827cdf40cb1ffa9ffb28e09c..91baa74aa9f6e0248db2e61ffd236e8069af63b0 100644 (file)
@@ -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;
 }
index da1514f90825a7c37b2fba4d133e43b10faaba28..fdebe3acc3bd24ca69b52f71bf0b259363dd1920 100644 (file)
@@ -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 &&
index 702bd5050cb884972ffff0dc1642ae24c96957bc..e1d67f5bb0e3126cf9fc0ea61a3fb8931e56fa82 100644 (file)
@@ -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:
index 7651470c8c57336f5f2c995c886d60f02e143e78..07d9e171f0a0cf941c78cec5c928af2da9158469 100644 (file)
@@ -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;
 }
 
index 11ba8b032ed5207cbc8f0d58812a1e68c282a27d..527d41ac920041bc0c8631f137aa0d70be442878 100644 (file)
@@ -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;
                }
This page took 0.037669 seconds and 4 git commands to generate.