-
Notifications
You must be signed in to change notification settings - Fork 23
Logging: part 2 #262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging: part 2 #262
Conversation
errors to HandleRequestMessage, which should never fail based on these codes
55062fa to
ade0b5a
Compare
ade0b5a to
7d2d372
Compare
There was a problem hiding this 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 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
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Had a single concern about always squashing error code within server handler.
dgarske
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice PR! Tests out with customer ST SR6 hardware. Thank you Brett
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