]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
unit1654: fix clang-tidy `bugprone-redundant-branch-condition`
authorViktor Szakats <commit@vsz.me>
Wed, 18 Feb 2026 16:43:14 +0000 (17:43 +0100)
committerViktor Szakats <commit@vsz.me>
Fri, 20 Feb 2026 16:33:35 +0000 (17:33 +0100)
```
tests/unit/unit1654.c:41:5: warning: redundant condition 'result' [bugprone-redundant-branch-condition]
   41 |     fail_if(result, "Curl_altsvc_load");
      |     ^
tests/libtest/unitcheck.h:29:5: note: expanded from macro 'fail_if'
   29 |     if(expr) {                                                         \
      |     ^
```

Ref: https://clang.llvm.org/extra/clang-tidy/checks/bugprone/redundant-branch-condition.html

Closes #20648

.clang-tidy.yml
tests/unit/unit1654.c

index 63d171c7667c4be7f0a05e9a2b872b41c95d9075..a23e3d26cc6588e474ea8f3a9fa1ec96117604f7 100644 (file)
@@ -10,6 +10,7 @@ Checks:
   - -clang-analyzer-security.insecureAPI.bzero  # for FD_ZERO() (seen on macOS)
   - -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling
   - -clang-diagnostic-nullability-extension
+  - bugprone-redundant-branch-condition
   - bugprone-suspicious-realloc-usage
   - misc-const-correctness
   - misc-header-include-cycle
index 8d14a119877e3a49b2100fd6d969b0df619bb509..b2987e8693385c915052bfc7d0820293e3842c8e 100644 (file)
@@ -37,16 +37,14 @@ static CURLcode test_unit1654(const char *arg)
   struct altsvcinfo *asi = Curl_altsvc_init();
   abort_if(!asi, "Curl_altsvc_i");
   result = Curl_altsvc_load(asi, arg);
-  if(result) {
-    fail_if(result, "Curl_altsvc_load");
+  fail_if(result, "Curl_altsvc_load");
+  if(result)
     goto fail;
-  }
   curl_global_init(CURL_GLOBAL_ALL);
   curl = curl_easy_init();
-  if(!curl) {
-    fail_if(!curl, "curl_easy_init");
+  fail_if(!curl, "curl_easy_init");
+  if(!curl)
     goto fail;
-  }
   fail_unless(Curl_llist_count(&asi->list) == 4, "wrong number of entries");
   curl_msnprintf(outname, sizeof(outname), "%s-out", arg);