Skip to content

clang-tidy: extend checks, fix fallouts - #1844

Closed
vszakats wants to merge 39 commits into
libssh2:masterfrom
vszakats:clangtidymore
Closed

vszakats wants to merge 39 commits into
libssh2:masterfrom
vszakats:clangtidymore

Conversation

@vszakats

@vszakats vszakats commented Apr 10, 2026 •

Copy link
Copy Markdown
Member
  • bump to newest clang-tidy (v20) in CI.
  • enable more checks.
  • disable picky warnings when used with gcc compiler.
  • blowfish: delete unused code.
  • blowfish: delete redundant static function prototypes.
  • fix fallouts:
    • add missing parentheses in macro values.
    • drop redundant parentheses.
    • drop useless return.
    • move assigments out of if expressions.
    • sync arguments names between prototype and implementation.
    • suppress false positives.

https://github.com/libssh2/libssh2/pull/1844/files?w=1

@vszakats
vszakats force-pushed the clangtidymore branch 4 times, most recently from 190fd50 to ef25f2a Compare April 10, 2026 18:06
vszakats added 26 commits April 10, 2026 22:03
bugprone-macro-parentheses 2

bugprone-macro-parentheses 1a

bugprone-macro-parentheses 1

longline
readability-redundant-parentheses
bugprone-macro-parentheses 4 priv

bugprone-macro-parentheses 5 priv

bugprone-macro-parentheses 6 priv

bugprone-macro-parentheses 7 priv

bugprone-macro-parentheses 8 priv

bugprone-macro-parentheses 7 priv

bugprone-macro-parentheses 7 priv

bugprone-macro-parentheses 7 priv

bugprone-macro-parentheses 7 priv
readability-named-parameter
[16/136] Building C object src/CMakeFiles/libssh2_static.dir/userauth_kbd_packet.c.o
src/userauth_kbd_packet.c:102:44: warning: an assignment within an 'if' condition is bug-prone [bugprone-assignment-in-if-condition]
  102 |        (session->userauth_kybd_num_prompts = tmp_u32) != tmp_u32) {
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
src/userauth_kbd_packet.c:102:44: note: if it should be an assignment, move it out of the 'if' condition
src/userauth_kbd_packet.c:102:44: note: if it is meant to be an equality check, change '=' to '=='

Follow-up to 6dc42e9 libssh2#953
```
/home/runner/work/libssh2/libssh2/src/channel.c:1421:13: error: the result from calling 'memcpy' is not null-terminated [bugprone-not-null-terminated-result,-warnings-as-errors]
 1421 |             memcpy(s, auth_cookie, cookie_len);
      |             ^~~~~~               ~~~~~~~~~~~~
      |             strcpy (char *)
```
@vszakats vszakats closed this in 6e47049 Apr 10, 2026
@vszakats
vszakats deleted the clangtidymore branch April 10, 2026 21:18
vszakats added a commit that referenced this pull request Apr 29, 2026
Also:
- apply minor whitespace fixes.
- VMS/man2help.c: clarify `if` expression, drop redundant `else`
  expression.

Follow-up to 6e47049 #1844

Closes #1898
vszakats added a commit to vszakats/libssh2 that referenced this pull request Jun 20, 2026
vszakats added a commit that referenced this pull request Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant