Skip to content

Commit

Permalink
unit tests: fix pointer casts on 32 bit systems.
Browse files Browse the repository at this point in the history
Conversions of max uint64 numbers to pointers did produce compile
errors on 32bit systems. A cast to size_t is now added before the
casting to a pointer.

Signed-off-by: Juergen Repp <[email protected]>
  • Loading branch information
JuergenReppSIT committed Feb 3, 2024
1 parent 0337d45 commit dc578da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion test/unit/esys-vendor.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ static TSS2_RC tcti_fake_recv(
UNUSED(tctiContext);
UNUSED(timeout);

const char *id = (const char*)mock();
/* Use size_t to cast 64 bit number to pointer (needed for 32 bit systems) */
const char *id = (const char*)(size_t)mock();

get_response(id, response, size);
return TSS2_RC_SUCCESS;
Expand Down
6 changes: 4 additions & 2 deletions test/unit/tcti-spidev.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ int __wrap_ioctl(int fd, unsigned long request, struct spi_ioc_transfer *tr)
assert_int_equal(tr->bits_per_word, 8);

size_t len = tr->len;
uint8_t *tx_buf = (uint8_t *) tr->tx_buf;
uint8_t *rx_buf = (uint8_t *) tr->rx_buf;

/* Use size_t to cast 64 bit number to pointer (needed for 32 bit systems) */
uint8_t *tx_buf = (uint8_t *)(size_t) tr->tx_buf;
uint8_t *rx_buf = (uint8_t *)(size_t) tr->rx_buf;

static tpm_state_t tpm_state = TPM_DID_VID_HEAD;

Expand Down

0 comments on commit dc578da

Please sign in to comment.