Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/arch/arm/plat-rockchip/platform_rk3588.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Copyright (c) 2024, Rockchip, Inc. All rights reserved.
*/

#include <assert.h>
#include <common.h>
#include <drivers/rockchip_otp.h>
#include <io.h>
Expand Down Expand Up @@ -199,6 +200,7 @@ static TEE_Result persist_huk(struct tee_hw_unique_key *hwkey)
{
TEE_Result res = TEE_SUCCESS;
uint32_t buffer[ROCKCHIP_OTP_HUK_SIZE] = { };
static_assert(sizeof(buffer) == sizeof(hwkey->data));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs an empty line above to separate from variable definitions.

Suggestion:

	TEE_Result res = TEE_SUCCESS;
	uint32_t buffer[ROCKCHIP_OTP_HUK_SIZE] = { };

	static_assert(sizeof(buffer) == sizeof(hwkey->data));
	memcpy(buffer, hwkey->data, HW_UNIQUE_KEY_LENGTH);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially, I was putting the static_assert next to the memcpy, too. In this case, the compiler is warning about mixing declarations and code. (In this instance, the compiler is not warning, because the static_assert is still above the code, but in read_huk it's not.) I didn't look deeper into the macro expansion, but it seems that static_assert somehow expands to a declaration.

Should I ignore the compiler warning?


memcpy(buffer, hwkey->data, HW_UNIQUE_KEY_LENGTH);

Expand All @@ -216,6 +218,7 @@ static TEE_Result read_huk(struct tee_hw_unique_key *hwkey)
{
TEE_Result res = TEE_SUCCESS;
uint32_t buffer[ROCKCHIP_OTP_HUK_SIZE] = { };
static_assert(sizeof(buffer) == sizeof(hwkey->data));
bool key_is_empty = true;
size_t i = 0;

Expand Down
Loading