Skip to content

libtests: drop two redundant memset()s#20649

Closed
vszakats wants to merge 2 commits intocurl:masterfrom
vszakats:ctidy12
Closed

libtests: drop two redundant memset()s#20649
vszakats wants to merge 2 commits intocurl:masterfrom
vszakats:ctidy12

Conversation

@vszakats
Copy link
Member

@vszakats vszakats commented Feb 20, 2026

Reported by clang-tidy bugprone-sizeof-expression.

Silencing:

tests/libtest/cli_h2_pausing.c:164:23: warning: suspicious usage of 'sizeof()' on an expression of pointer type [bugprone-sizeof-expression]
  164 |   memset(&resolve, 0, sizeof(resolve));
      |                       ^
tests/libtest/cli_upload_pausing.c:158:23: warning: suspicious usage of 'sizeof()' on an expression of pointer type [bugprone-sizeof-expression]
  158 |   memset(&resolve, 0, sizeof(resolve));
      |                       ^

Ref: https://clang.llvm.org/extra/clang-tidy/checks/bugprone/sizeof-expression.html

@github-actions github-actions bot added the tests label Feb 20, 2026
@vszakats
Copy link
Member Author

needs separate fix so that disabling typechecks via autotools/cmake also applies to examples.

This needs passing this option as a CPPFLAGS, instead of using curl_config.h.

vszakats added a commit that referenced this pull request Feb 20, 2026
To make it apply to examples. This in turn makes analyzers run quicker
and with fewer false positives.

It's a special disable option, having its effect via `curl/curl.h`.

Bug: #20649 (comment)
Follow-up to 9e6f1c5 #19637

Closes #20650
…xpression`

```
tests/libtest/cli_h2_pausing.c:164:23: warning: suspicious usage of 'sizeof()' on an expression of pointer type [bugprone-sizeof-expression]
  164 |   memset(&resolve, 0, sizeof(resolve));
      |                       ^
tests/libtest/cli_upload_pausing.c:158:23: warning: suspicious usage of 'sizeof()' on an expression of pointer type [bugprone-sizeof-expression]
  158 |   memset(&resolve, 0, sizeof(resolve));
      |                       ^
```

Ref: https://clang.llvm.org/extra/clang-tidy/checks/bugprone/sizeof-expression.html
@vszakats
Copy link
Member Author

False positive:

/home/runner/work/curl/curl/lib/hostip.c:516:38: error: suspicious usage of 'sizeof(A*)'; pointer to aggregate [bugprone-sizeof-expression,-warnings-as-errors]
  516 |     nodes = curlx_malloc(num_addrs * sizeof(*nodes));
      |                                      ^~~~~~~~~~~~~~
94 warnings generated.
Suppressed 93 warnings (93 in non-user code).

@vszakats
Copy link
Member Author

augment review

@augmentcode
Copy link

augmentcode bot commented Feb 20, 2026

🤖 Augment PR Summary

Summary: Removes redundant memset()-based pointer zeroing in two libtest CLI tests.

Why: Avoids clang-tidy bugprone-sizeof-expression warnings by relying on the existing resolve = NULL initialization.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

@vszakats vszakats changed the title libtests: drop redundant memset() via clang-tidy bugprone-sizeof-expression libtests: drop redundant memset() Feb 20, 2026
@vszakats vszakats changed the title libtests: drop redundant memset() libtests: drop redundant memset()s Feb 20, 2026
@vszakats vszakats changed the title libtests: drop redundant memset()s libtests: drop two redundant memset() Feb 20, 2026
@vszakats vszakats changed the title libtests: drop two redundant memset() libtests: drop two redundant memset()s Feb 20, 2026
@vszakats vszakats closed this in 947775a Feb 20, 2026
@vszakats vszakats deleted the ctidy12 branch February 20, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

1 participant