Skip to content

Commit

Permalink
Use LIBSPDM_ARRAY_SIZE
Browse files Browse the repository at this point in the history
And scope the typedef to the function in which it's used.

Signed-off-by: Steven Bellock <[email protected]>
  • Loading branch information
steven-bellock authored and jyao1 committed Feb 9, 2024
1 parent 79e97e5 commit 788239e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions library/spdm_responder_lib/libspdm_rsp_receive_send.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
/**
* Copyright Notice:
* Copyright 2021-2022 DMTF. All rights reserved.
* Copyright 2021-2024 DMTF. All rights reserved.
* License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
**/

#include "internal/libspdm_responder_lib.h"
#include "internal/libspdm_secured_message_lib.h"

typedef struct {
uint8_t request_response_code;
libspdm_get_spdm_response_func get_response_func;
} libspdm_get_response_struct_t;

/**
* Return the GET_SPDM_RESPONSE function via request code.
*
Expand All @@ -23,6 +18,11 @@ libspdm_get_spdm_response_func libspdm_get_response_func_via_request_code(uint8_
{
size_t index;

typedef struct {
uint8_t request_response_code;
libspdm_get_spdm_response_func get_response_func;
} libspdm_get_response_struct_t;

libspdm_get_response_struct_t get_response_struct[] = {
{ SPDM_GET_VERSION, libspdm_get_response_version },
{ SPDM_GET_CAPABILITIES, libspdm_get_response_capabilities },
Expand Down Expand Up @@ -90,7 +90,7 @@ libspdm_get_spdm_response_func libspdm_get_response_func_via_request_code(uint8_
#endif /*LIBSPDM_ENABLE_VENDOR_DEFINED_MESSAGES*/
};

for (index = 0; index < sizeof(get_response_struct) / sizeof(get_response_struct[0]); index++) {
for (index = 0; index < LIBSPDM_ARRAY_SIZE(get_response_struct); index++) {
if (request_code == get_response_struct[index].request_response_code) {
return get_response_struct[index].get_response_func;
}
Expand Down

0 comments on commit 788239e

Please sign in to comment.