From 81428663d0e913bdd75c468ab320b7753aa519b6 Mon Sep 17 00:00:00 2001 From: Brett Nicholas <7547222+bigbrett@users.noreply.github.com> Date: Thu, 4 Apr 2024 08:01:54 -0600 Subject: [PATCH] Quick post-merge fixes: - Renamed WH_ERROR_NO_HANDLER to WH_ERROR_NOHANDLER - Removed WH_ACTION_MAX - Add prototype for busy wait CheckRegistered to header. --- src/wh_client.c | 2 +- src/wh_server_customcb.c | 2 +- test/wh_test_clientserver.c | 4 ++-- wolfhsm/wh_client.h | 4 +++- wolfhsm/wh_error.h | 2 +- wolfhsm/wh_message.h | 1 - 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/wh_client.c b/src/wh_client.c index 9a87124d..00ccf285 100644 --- a/src/wh_client.c +++ b/src/wh_client.c @@ -277,7 +277,7 @@ int wh_Client_CustomCbCheckRegisteredResponse(whClientContext* c, uint16_t* outI return WH_ERROR_ABORTED; } - if (resp.err != WH_ERROR_OK && resp.err != WH_ERROR_NO_HANDLER) { + if (resp.err != WH_ERROR_OK && resp.err != WH_ERROR_NOHANDLER) { /* error codes that aren't related to the query should be fatal */ return WH_ERROR_ABORTED; } diff --git a/src/wh_server_customcb.c b/src/wh_server_customcb.c index 5685b7bb..ed396b23 100644 --- a/src/wh_server_customcb.c +++ b/src/wh_server_customcb.c @@ -63,7 +63,7 @@ int wh_Server_HandleCustomCbRequest(whServerContext* server, uint16_t magic, else { /* No callback was registered, populate response error. We must * return success to ensure the "error" response is sent */ - resp.err = WH_ERROR_NO_HANDLER; + resp.err = WH_ERROR_NOHANDLER; } /* tag response with requested callback ID for client-side bookkeeping*/ diff --git a/test/wh_test_clientserver.c b/test/wh_test_clientserver.c index 560d1a46..fd71cf15 100644 --- a/test/wh_test_clientserver.c +++ b/test/wh_test_clientserver.c @@ -82,13 +82,13 @@ static int _testCallbacks(whServerContext* server, whClientContext* client) WH_TEST_RETURN_ON_FAIL(wh_Server_HandleRequestMessage(server)); WH_TEST_RETURN_ON_FAIL(wh_Client_CustomCbCheckRegisteredResponse(client, &outId, &respErr)); WH_TEST_ASSERT_RETURN(outId == req.id); - WH_TEST_ASSERT_RETURN(respErr == WH_ERROR_NO_HANDLER); + WH_TEST_ASSERT_RETURN(respErr == WH_ERROR_NOHANDLER); /* Test that calling an unregistered callback returns error */ WH_TEST_RETURN_ON_FAIL(wh_Client_CustomCbRequest(client, &req)); WH_TEST_RETURN_ON_FAIL(wh_Server_HandleRequestMessage(server)); WH_TEST_RETURN_ON_FAIL(wh_Client_CustomCbResponse(client, &resp)); - WH_TEST_ASSERT_RETURN(resp.err == WH_ERROR_NO_HANDLER); + WH_TEST_ASSERT_RETURN(resp.err == WH_ERROR_NOHANDLER); /* Register a custom callback */ WH_TEST_RETURN_ON_FAIL( diff --git a/wolfhsm/wh_client.h b/wolfhsm/wh_client.h index cf7beedc..12b2e734 100644 --- a/wolfhsm/wh_client.h +++ b/wolfhsm/wh_client.h @@ -186,8 +186,10 @@ int wh_Client_CustomCbResponse(whClientContext* c, whMessageCustomCb_Response *r int wh_Client_CustomCheckRegisteredRequest(whClientContext* c, uint32_t id); /* Processes a server response to callback query. OutId is set to the ID of the * received query. ResponseError is set to WH_ERROR_OK if the callback is - * registered, and WH_ERROR_NO_HANDLER if not */ + * registered, and WH_ERROR_NOHANDLER if not */ int wh_Client_CustomCbCheckRegisteredResponse(whClientContext* c, uint16_t* outId, int* responseError); +/* Blocking call to check if a callback is registered */ +int wh_Client_CustomCbCheckRegistered(whClientContext* c, uint16_t id, int* responseError); #endif /* WOLFHSM_WH_CLIENT_H_ */ diff --git a/wolfhsm/wh_error.h b/wolfhsm/wh_error.h index d49ac946..c45fec3a 100644 --- a/wolfhsm/wh_error.h +++ b/wolfhsm/wh_error.h @@ -26,7 +26,7 @@ enum { WH_ERROR_NOSPACE = -415, /* No available space */ /* Custom-callback status returns */ - WH_ERROR_NO_HANDLER = -420, /* No handler registered for action */ + WH_ERROR_NOHANDLER = -420, /* No handler registered for action */ }; #endif /* WOLFHSM_WH_ERROR_H_ */ diff --git a/wolfhsm/wh_message.h b/wolfhsm/wh_message.h index 3b794d41..157dd9d5 100644 --- a/wolfhsm/wh_message.h +++ b/wolfhsm/wh_message.h @@ -25,7 +25,6 @@ enum { WH_MESSAGE_ACTION_MASK = 0x00FF, /* 255 subtypes per group*/ WH_MESSAGE_ACTION_NONE = 0x0000, /* No action. Invalid. */ - WH_MESSAGE_ACTION_MAX = 0x00FF, /* Max action value */ }; /* Construct the message kind based on group and action */