Merge pull request #7385 from daverodgman/timing_alignment

Fix cast alignment warning in timing.c
This commit is contained in:
Dave Rodgman 2023-03-31 19:48:34 +01:00 committed by GitHub
commit dd48c6e3df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -39,7 +39,7 @@ extern "C" {
* \brief timer structure
*/
struct mbedtls_timing_hr_time {
unsigned char MBEDTLS_PRIVATE(opaque)[32];
uint64_t MBEDTLS_PRIVATE(opaque)[4];
};
/**

View File

@ -20,8 +20,20 @@
void timing_get_timer()
{
struct mbedtls_timing_hr_time time;
memset(&time, 0, sizeof(time));
(void) mbedtls_timing_get_timer(&time, 1);
/* Check that a non-zero time was written back */
int all_zero = 1;
for (size_t i = 0; i < sizeof(time); i++) {
all_zero &= ((unsigned char *) &time)[i] == 0;
}
TEST_ASSERT(!all_zero);
(void) mbedtls_timing_get_timer(&time, 0);
/* This goto is added to avoid warnings from the generated code. */
goto exit;
}