Skip to content

Commit c47bb19

Browse files
committed
address review feedback
1 parent 3fba076 commit c47bb19

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

src/wh_log_printf.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,15 @@ int whLogPrintf_AddEntry(void* c, const whLogEntry* entry)
8282
#endif
8383

8484
/* Format: [TIMESTAMP] [LEVEL] [FILE:LINE FUNC] MESSAGE */
85-
WOLFHSM_CFG_PRINTF(
85+
(void)WOLFHSM_CFG_PRINTF(
8686
"[%llu] [%s] [%s:%u %s] %.*s\n", (unsigned long long)entry->timestamp,
87-
wh_Log_LevelToString(entry->level), entry->file ? entry->file : "",
88-
entry->line, entry->function ? entry->function : "",
89-
(int)entry->msg_len, entry->msg);
87+
wh_Log_LevelToString(entry->level),
88+
(entry->file != NULL) ? entry->file : "", entry->line,
89+
(entry->function != NULL) ? entry->function : "",
90+
(entry->msg_len <= WOLFHSM_CFG_LOG_MSG_MAX)
91+
? (int)(entry->msg_len)
92+
: (int)WOLFHSM_CFG_LOG_MSG_MAX,
93+
entry->msg);
9094

9195
return WH_ERROR_OK;
9296
}

src/wh_server.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ int wh_Server_HandleRequestMessage(whServerContext* server)
410410
default:
411411
/* Unknown group. Return empty packet */
412412
rc = WH_ERROR_NOTIMPL;
413+
data = NULL;
413414
size = 0;
414415
}
415416

@@ -447,9 +448,9 @@ int wh_Server_HandleRequestMessage(whServerContext* server)
447448
"SendResponse failed for (group=%d, action=%d, seq=%d): %d", group,
448449
action, seq, rc);
449450

450-
/* Always return success when we processed a request, so no handler
451-
* error can terminate the server's request processing loop. */
452-
rc = WH_ERROR_OK;
451+
/* Handler errors are logged above via handlerRc but don't affect
452+
* return code. Errors from SendResponse are propagated back to the
453+
* caller in rc */
453454
}
454455
else if (rc != WH_ERROR_NOTREADY) {
455456
/* Log error code from processing request, if present */

wolfhsm/wh_log_printf.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@
3333

3434
/* Printf configuration structure */
3535
typedef struct whLogPrintfConfig_t {
36-
int logIfNotDebug; /* When true, always log regardless of WOLFHSM_CFG_DEBUG
37-
*/
36+
int logIfNotDebug; /* When non-zero, log entries are printed even if
37+
* WOLFHSM_CFG_DEBUG is not defined. When zero, entries
38+
* are only printed if WOLFHSM_CFG_DEBUG is defined. This
39+
* flag applies to all log levels */
3840
} whLogPrintfConfig;
3941

4042
/* Printf context structure */

0 commit comments

Comments
 (0)