Conversation
errors to HandleRequestMessage, which should never fail based on these codes
55062fa to
ade0b5a
Compare
ade0b5a to
7d2d372
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces the second phase of the logging framework integration, refactoring server request handlers to enforce uniform error handling and adding a new printf-based logging backend for console output.
Key Changes:
- Refactors all server request handlers to return actual error codes (instead of unconditionally returning OK) which are then logged centrally in
wh_Server_HandleRequestMessage, preventing handler failures from terminating the server - Adds a new
wh_log_printfbackend providing ephemeral console-based logging - Introduces
wh_Log_LevelToString()utility function to eliminate code duplication across logging backends
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| wolfhsm/wh_log_printf.h | New header defining the printf logging backend interface with context and configuration structures |
| src/wh_log_printf.c | Implementation of printf logging backend with conditional logging based on debug configuration |
| wolfhsm/wh_log.h | Adds declaration for new wh_Log_LevelToString() utility function |
| src/wh_log.c | Implements wh_Log_LevelToString() to convert log level enums to string representations |
| port/posix/posix_log_file.c | Refactored to use shared wh_Log_LevelToString() instead of local implementation |
| wolfhsm/wh_error.h | Updates comment for WH_ERROR_NOHANDLER to clarify its general purpose |
| src/wh_server.c | Centralizes request handler error logging and ensures handlers never terminate the server |
| src/wh_server_keystore.c | Removes conditional error suppression logic; handlers now return actual error codes for centralized logging |
| src/wh_server_crypto.c | Removes error suppression logic that unconditionally returned OK |
| src/wh_server_counter.c | Removes TODOs and error suppression comments |
| src/wh_server_she.c | Returns actual error codes instead of unconditionally returning success |
Comments suppressed due to low confidence (1)
src/wh_server_keystore.c:1564
- When ret != WH_ERROR_OK, resp.len and resp.label are not set, leaving them uninitialized. The response structure should either be initialized with = {0} on line 1542, or these fields should be explicitly zeroed in the error path to avoid sending uninitialized data to the client.
if (ret == WH_ERROR_OK) {
resp.len = req.key.sz;
memcpy(resp.label, meta->label, sizeof(meta->label));
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7d2d372 to
3fba076
Compare
billphipps
previously requested changes
Dec 17, 2025
Contributor
billphipps
left a comment
There was a problem hiding this comment.
Looks good! Had a single concern about always squashing error code within server handler.
dgarske
approved these changes
Dec 18, 2025
Contributor
dgarske
left a comment
There was a problem hiding this comment.
Very nice PR! Tests out with customer ST SR6 hardware. Thank you Brett
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Further integration of the new logging framework, with some associated refactors and a new back end.
wh_Server_HandleRequestMessage).wh_Server_HandleRequestMessagenow observes handler error codes and acts as a centralized point for logging failures. A response is always sent to the client, and no error is ever propagated to the caller, ensuring handler errors cannot terminate the server.printflogging backend for ephemeral console-based logs