Skip to content

tidy clang-tidy#1002

Open
ejohnstown wants to merge 6 commits into
wolfSSL:masterfrom
ejohnstown:tidy-tidy
Open

tidy clang-tidy#1002
ejohnstown wants to merge 6 commits into
wolfSSL:masterfrom
ejohnstown:tidy-tidy

Conversation

@ejohnstown
Copy link
Copy Markdown
Contributor

@ejohnstown ejohnstown commented Jun 4, 2026

Clean up clang-tidy findings across wolfSSH. The checks set initially flagged 378 issues across six categories; this branch clears all of them. Build is clean (exit 0); no functional or wire-protocol changes.

  • Add parameter names to function declarations -- name the parameters in public/internal-header function decls and the few forward decls in .c files; clears all 360 readability-named-parameter findings. Prototypes that exceeded 80 columns after the names were added are re-wrapped using the existing 8-space continuation style.
  • Remove redundant preprocessor guard -- drop the inner #ifdef WOLFSSH_CERTS inside DoUserAuthRequestRsaCert (the surrounding function is already under the same guard); clears readability-redundant-preprocessor.
  • Move unsafe call out of signal handler -- drop fprintf from wolfsshd's interruptCatch and log "Closing down wolfSSHD" from the main accept loop after quit is observed; annotate sftpclient's wolfSSH_SFTP_Interrupt call with NOLINT since it is a single byte store; clears both bugprone-signal-handler findings.
  • Use reentrant time conversion in SFTP -- SFTP_CreateLongName switches from XGMTIME (gmtime) to WLOCALTIME, which expands to localtime_r/localtime_s per platform; clears concurrency-mt-unsafe. Server will provide localtimes for ls -l output, except for Zephyr which only provides UTC.
  • Tighten SCP timestamp bounds check -- in ParseTimestamp, move ++idx out of the || conditions and tighten the bound from > bufSz to >= bufSz; clears both bugprone-inc-dec-in-conditions findings and fixes a one-past-the-end read.
  • Bound sshd Include directive recursion -- track include depth on WOLFSSHD_CONFIG, reject loads past WOLFSSHD_MAX_INCLUDE_DEPTH (16), and annotate the four functions in the include cycle with NOLINTNEXTLINE pointing at the bound; clears all 8 misc-no-recursion findings. Adds a test for the recursion depth.

Copilot AI review requested due to automatic review settings June 4, 2026 21:13
@ejohnstown ejohnstown requested a review from padelsbach June 4, 2026 21:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR is a clang-tidy cleanup pass across wolfSSH, focused on eliminating diagnostics (primarily readability-named-parameter) while also addressing a few correctness/safety findings (signal-handler safety, SFTP time conversion reentrancy, SCP bounds check, and sshd config include recursion).

Changes:

  • Add parameter names to many public/internal header prototypes and a few forward declarations, rewrapping long prototypes to match existing continuation style.
  • Improve safety/correctness in a few targeted areas: remove redundant preprocessor guarding, avoid logging from a signal handler, use reentrant time conversion for SFTP longname creation, and tighten an SCP timestamp bounds check.
  • Bound Include recursion in wolfsshd configuration loading via a tracked include depth and a maximum depth constant.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
wolfssh/wolfscp.h Names parameters in SCP API declarations; rewraps long prototypes.
wolfssh/ssh.h Names parameters in core public API declarations and callback setters.
wolfssh/port.h Names parameters for select portability-layer prototypes (stdio + string + pread/pwrite).
wolfssh/log.h Names parameters in the public logging API signature.
wolfssh/internal.h Names parameters in internal APIs (channels, I/O handlers, packet helpers, SCP helpers).
wolfssh/agent.h Names parameters in agent API/internal declarations and rewraps long prototypes.
src/wolfsftp.c Switches SFTP longname time conversion to WLOCALTIME and simplifies preprocessor guards.
src/wolfscp.c Refactors SCP timestamp parsing to avoid inc/dec inside conditions and tightens bounds.
src/log.c Updates default logging callback forward-declaration parameter names/wrapping.
src/internal.c Removes redundant inner #ifdef WOLFSSH_CERTS inside an already-guarded function.
examples/sftpclient/sftpclient.c Annotates wolfSSH_SFTP_Interrupt() call in signal handler with NOLINT.
examples/scpclient/scpclient.h Names the thread entry parameter in the example header prototype.
apps/wolfsshd/wolfsshd.c Removes fprintf from signal handler; logs shutdown message from main loop.
apps/wolfsshd/test/test_configuration.c Names the fmt parameter in the test logger prototype.
apps/wolfsshd/configuration.c Adds include-depth tracking + maximum recursion bound; annotates bounded recursion with NOLINTNEXTLINE.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread wolfssh/port.h Outdated
Comment thread src/wolfsftp.c
Comment thread apps/wolfsshd/configuration.c Outdated
Comment thread apps/wolfsshd/configuration.c
Comment thread src/wolfsftp.c
@ejohnstown ejohnstown force-pushed the tidy-tidy branch 2 times, most recently from c522ffd to 03988ef Compare June 5, 2026 22:05
Clean up clang-tidy readability-named-parameter findings
across wolfSSH headers and sources.
Cleanup clang-tidy readability-redundant-preprocessor finding.
Cleanup clang-tidy bugprone-signal-handler findings.
- wolfsshd: drop fprintf from interruptCatch; the main accept
  loop logs "Closing down wolfSSHD" after seeing quit set.
- sftpclient: annotate wolfSSH_SFTP_Interrupt call in
  sig_handler with NOLINT, since the function is only a single
  byte store and is safe to call from a signal handler.
Cleanup clang-tidy concurrency-mt-unsafe finding. Note, this
originally used gmtime which provided UTC based time values. Now,
the wolfSFTP server will provide localtimes for file timestamps.
The exception is Zephyr, which only provides UTC times.

- SFTP_CreateLongName: switch from XGMTIME (gmtime) to
  WLOCALTIME, which expands to localtime_r/localtime_s
  per platform.
- Note in the Zephyr WLOCALTIME macro that gmtime_r is used
  because Zephyr's minimal libc does not provide localtime_r.
Cleanup clang-tidy bugprone-inc-dec-in-conditions finding.

- ParseTimestamp: move ++idx out of the || conditions
  and tighten the bound from > bufSz to >= bufSz.
Cleanup clang-tidy misc-no-recursion finding.

- wolfSSHD_ConfigLoad: track depth on WOLFSSHD_CONFIG
  and reject loads past WOLFSSHD_MAX_INCLUDE_DEPTH (16).
- HandleInclude, HandleConfigOption, ParseConfigLine,
  wolfSSHD_ConfigLoad: annotate the call cycle with
  NOLINTNEXTLINE pointing at the bound.
- Add a recursive configuration test.
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.

4 participants