Skip to content

clang-tidy: avoid/silence bugprone-not-null-terminated-result#20723

Closed
vszakats wants to merge 3 commits intocurl:masterfrom
vszakats:ctidymemcpy
Closed

clang-tidy: avoid/silence bugprone-not-null-terminated-result#20723
vszakats wants to merge 3 commits intocurl:masterfrom
vszakats:ctidymemcpy

Conversation

@vszakats
Copy link
Member

@vszakats vszakats commented Feb 25, 2026

Prefer sizeof() over strlen(), static const variables over macros.
Add a couple of NOLINTs to silence false positives.

Also sync similar code patterns between libtests.

Cherry-picked from #20720

```
/home/runner/work/curl/curl/tests/server/mqttd.c:354:3: error: the result from calling 'memcpy' is not null-terminated [bugprone-not-null-terminated-result,-warnings-as-errors]
  354 |   memcpy(&packet[3 + encodedlen], topic, topiclen);
      |   ^~~~~~                               ~~~~~~~~~~
      |   strcpy  (char *)
/home/runner/work/curl/curl/tests/server/rtspd.c:320:19: error: the result from calling 'memcpy' is not null-terminated [bugprone-not-null-terminated-result,-warnings-as-errors]
  320 |                   memcpy(rtp_scratch + 4 + i, RTP_DATA, RTP_DATA_SIZE);
      |                   ^~~~~~                              ~~~~~~~~~~~~~~~
      |                   strcpy
```
https://github.com/curl/curl/actions/runs/22405414997/job/64863682328?pr=20720
@github-actions github-actions bot added the tests label Feb 25, 2026
@vszakats vszakats changed the title clang-tidy: silence/avoid bugprone-not-null-terminated-result clang-tidy: avoid/silence bugprone-not-null-terminated-result Feb 25, 2026
@vszakats vszakats marked this pull request as draft February 25, 2026 20:40
@vszakats vszakats marked this pull request as ready for review February 25, 2026 21:10
@vszakats vszakats closed this in 725c560 Feb 25, 2026
@vszakats vszakats deleted the ctidymemcpy branch February 25, 2026 21:11
vszakats added a commit that referenced this pull request Feb 26, 2026
Also:
- imap-append: silence false positive (seen on Linux only).
  Follow-up to b1f853a #20731
  Follow-up to 725c560 #20723

Closes #20743
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant