fix(clang): fix performance-no-int-to-ptr for tests
To keep inline with table 10.14 of the FF-A 1.1 BETA0 specification
"Constituent memory region descriptor" we keep the address field
in the ffa_memory_region_constituent struct as a uint64_t to ensure
it is always 8 bytes. This means we will have to have integer to pointer
conversions but for the cases of this in the buffer manipulation tests
we will permit this.
Signed-off-by: Daniel Boulby <daniel.boulby@arm.com>
Change-Id: I6688af1c8cd3d959e0808f7568f190218d8aa52d
diff --git a/test/hftest/power_mgmt.c b/test/hftest/power_mgmt.c
index 5326ab0..b9cec24 100644
--- a/test/hftest/power_mgmt.c
+++ b/test/hftest/power_mgmt.c
@@ -22,6 +22,11 @@
static noreturn void cpu_entry(uintptr_t arg)
{
+ /*
+ * The function prototype must match the entry function so we permit the
+ * int to pointer conversion.
+ */
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
struct cpu_start_state *s = (struct cpu_start_state *)arg;
struct cpu_start_state s_copy;
diff --git a/test/vmapi/primary_only/faults.c b/test/vmapi/primary_only/faults.c
index 75fa4d3..68ea823 100644
--- a/test/vmapi/primary_only/faults.c
+++ b/test/vmapi/primary_only/faults.c
@@ -31,6 +31,11 @@
*/
static void rx_reader(uintptr_t arg)
{
+ /*
+ * The function prototype must match the entry function so we permit the
+ * int to pointer conversion.
+ */
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
struct state *s = (struct state *)arg;
sl_unlock(&s->lock);
diff --git a/test/vmapi/primary_only/primary_only.c b/test/vmapi/primary_only/primary_only.c
index cd5baea..cb34a9b 100644
--- a/test/vmapi/primary_only/primary_only.c
+++ b/test/vmapi/primary_only/primary_only.c
@@ -62,6 +62,11 @@
*/
static void vm_cpu_entry(uintptr_t arg)
{
+ /*
+ * The function prototype must match the entry function so we permit the
+ * int to pointer conversion.
+ */
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
struct spinlock *lock = (struct spinlock *)arg;
dlog("Second CPU started.\n");
@@ -92,6 +97,11 @@
*/
static void vm_cpu_entry_stop(uintptr_t arg)
{
+ /*
+ * The function prototype must match the entry function so we permit the
+ * int to pointer conversion.
+ */
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
struct spinlock *lock = (struct spinlock *)arg;
dlog("Second CPU started.\n");
diff --git a/test/vmapi/primary_with_secondaries/memory_sharing.c b/test/vmapi/primary_with_secondaries/memory_sharing.c
index e8b7ef2..90e6d5a 100644
--- a/test/vmapi/primary_with_secondaries/memory_sharing.c
+++ b/test/vmapi/primary_with_secondaries/memory_sharing.c
@@ -681,6 +681,7 @@
ASSERT_NE(memory_region->receivers[0].composite_memory_region_offset,
0);
composite = ffa_memory_region_get_composite(memory_region, 0);
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
ptr = (uint8_t *)composite->constituents[0].address;
for (int i = 0; i < PAGE_SIZE; ++i) {
ASSERT_EQ(ptr[i], 0);
@@ -716,6 +717,7 @@
ASSERT_NE(memory_region->receivers[0].composite_memory_region_offset,
0);
composite = ffa_memory_region_get_composite(memory_region, 0);
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
ptr = (uint8_t *)composite->constituents[0].address;
for (int i = 0; i < PAGE_SIZE; ++i) {
ASSERT_EQ(ptr[i], 0);
diff --git a/test/vmapi/primary_with_secondaries/run_race.c b/test/vmapi/primary_with_secondaries/run_race.c
index 69fdd89..4a1df71 100644
--- a/test/vmapi/primary_with_secondaries/run_race.c
+++ b/test/vmapi/primary_with_secondaries/run_race.c
@@ -67,6 +67,11 @@
*/
static void vm_cpu_entry(uintptr_t arg)
{
+ /*
+ * The function prototype must match the entry function so we permit the
+ * int to pointer conversion.
+ */
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
struct cpu_state *state = (struct cpu_state *)arg;
run_loop(state->mb);
diff --git a/test/vmapi/primary_with_secondaries/services/memory.c b/test/vmapi/primary_with_secondaries/services/memory.c
index 6f3beb6..b8f592c 100644
--- a/test/vmapi/primary_with_secondaries/services/memory.c
+++ b/test/vmapi/primary_with_secondaries/services/memory.c
@@ -38,6 +38,7 @@
HF_MAILBOX_SIZE);
struct ffa_composite_memory_region *composite =
ffa_memory_region_get_composite(memory_region, 0);
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
uint8_t *ptr = (uint8_t *)composite->constituents[0].address;
ASSERT_EQ(memory_region->receiver_count, 1);
@@ -121,6 +122,7 @@
struct ffa_composite_memory_region *composite =
ffa_memory_region_get_composite(memory_region, 0);
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
ptr = (uint8_t *)composite->constituents[0].address;
/* Check that one has access to the shared region. */
@@ -166,7 +168,9 @@
composite = ffa_memory_region_get_composite(memory_region, 0);
/* Choose which constituent we want to test. */
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
index = *(uint8_t *)composite->constituents[0].address;
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
ptr = (uint8_t *)composite->constituents[index].address;
/*
@@ -200,7 +204,9 @@
composite = ffa_memory_region_get_composite(memory_region, 0);
/* Choose which constituent we want to test. */
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
index = *(uint8_t *)composite->constituents[0].address;
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
ptr = (uint8_t *)composite->constituents[index].address;
/*
@@ -232,6 +238,7 @@
ASSERT_EQ(sender, HF_PRIMARY_VM_ID);
exception_setup(NULL, exception_handler_yield_data_abort);
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
ptr = (uint8_t *)composite->constituents[0].address;
/* Donate memory to next VM. */
@@ -309,6 +316,7 @@
retrieve_memory_from_message(recv_buf, send_buf, ret, NULL,
memory_region, HF_MAILBOX_SIZE);
composite = ffa_memory_region_get_composite(memory_region, 0);
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
ptr = (uint8_t *)composite->constituents[0].address;
ptr[0] = 'd';
@@ -388,6 +396,7 @@
* Check that we can read and write every page that was shared.
*/
for (i = 0; i < composite->constituent_count; ++i) {
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
uint8_t *ptr = (uint8_t *)constituents[i].address;
uint32_t count = constituents[i].page_count;
size_t j;
@@ -431,12 +440,14 @@
/* ASSERT_TRUE isn't enough for clang-analyze. */
CHECK(composite != NULL);
constituents = composite->constituents;
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
first_ptr = (uint8_t *)constituents[0].address;
/*
* Check that we can read and write every page that was shared.
*/
for (i = 0; i < composite->constituent_count; ++i) {
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
uint8_t *ptr = (uint8_t *)constituents[i].address;
uint32_t count = constituents[i].page_count;
size_t j;
@@ -481,6 +492,7 @@
memory_region, HF_MAILBOX_SIZE);
composite = ffa_memory_region_get_composite(memory_region, 0);
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
ptr = (uint8_t *)composite->constituents[0].address;
/* Check that we have access to the shared region. */
@@ -612,6 +624,7 @@
CHECK(composite != NULL);
constituents = composite->constituents;
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
ptr = (uint64_t *)constituents[0].address;
/*
@@ -690,6 +703,7 @@
struct ffa_memory_region_constituent constituent_copy =
composite->constituents[0];
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
ptr = (uint8_t *)constituent_copy.address;
/* Check that we have read access. */
@@ -732,6 +746,7 @@
composite = ffa_memory_region_get_composite(memory_region, 0);
constituent_copy = composite->constituents[0];
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
ptr = (uint8_t *)constituent_copy.address;
/* Check that we have read access. */