fix(clang): misc-no-recursion
Also remove __clang_analyzer__ ifndefs for the more
precise //NOLINTNEXTLINE
Signed-off-by: Daniel Boulby <daniel.boulby@arm.com>
Change-Id: I01496921a98e393b165c68d27d77d345b5bfa4b9
diff --git a/src/arch/aarch64/pl011/pl011.c b/src/arch/aarch64/pl011/pl011.c
index 079ad9d..d23083c 100644
--- a/src/arch/aarch64/pl011/pl011.c
+++ b/src/arch/aarch64/pl011/pl011.c
@@ -95,6 +95,10 @@
MM_MODE_R | MM_MODE_W | MM_MODE_D, ppool);
}
+/*
+ * Since the recursion is only one level disable the clang tidy recursion check
+ */
+// NOLINTNEXTLINE(misc-no-recursion)
void plat_console_putchar(char c)
{
/* Print a carriage-return as well. */
diff --git a/src/mm.c b/src/mm.c
index 80b6d51..6f15748 100644
--- a/src/mm.c
+++ b/src/mm.c
@@ -173,6 +173,7 @@
* Frees all page-table-related memory associated with the given pte at the
* given level, including any subtables recursively.
*/
+// NOLINTNEXTLINE(misc-no-recursion)
static void mm_free_page_pte(pte_t pte, uint8_t level, struct mpool *ppool)
{
struct mm_page_table *table;
@@ -354,6 +355,7 @@
* levels, but the recursion is bound by the maximum number of levels in a page
* table.
*/
+// NOLINTNEXTLINE(misc-no-recursion)
static bool mm_map_level(ptable_addr_t begin, ptable_addr_t end, paddr_t pa,
uint64_t attrs, struct mm_page_table *table,
uint8_t level, int flags, struct mpool *ppool,
@@ -556,6 +558,7 @@
* Writes the given table to the debug log, calling itself recursively to
* write sub-tables.
*/
+// NOLINTNEXTLINE(misc-no-recursion)
static void mm_dump_table_recursive(struct mm_page_table *table, uint8_t level,
int max_level)
{
@@ -630,6 +633,7 @@
* Defragments the given PTE by recursively replacing any tables with blocks or
* absent entries where possible.
*/
+// NOLINTNEXTLINE(misc-no-recursion)
static void mm_ptable_defrag_entry(ptable_addr_t base_addr, pte_t *entry,
uint8_t level, int flags,
struct mpool *ppool, uint16_t id)
@@ -747,6 +751,7 @@
*
* Returns true if the whole range has the same attributes and false otherwise.
*/
+// NOLINTNEXTLINE(misc-no-recursion)
static bool mm_ptable_get_attrs_level(struct mm_page_table *table,
ptable_addr_t begin, ptable_addr_t end,
uint8_t level, bool got_attrs,
diff --git a/src/std.c b/src/std.c
index 7a2db2d..2fce4c1 100644
--- a/src/std.c
+++ b/src/std.c
@@ -35,19 +35,17 @@
void memset_s(void *dest, rsize_t destsz, int ch, rsize_t count)
{
- CHECK_OR_FILL(dest != NULL, dest, destsz, ch);
-
- /* Check count <= destsz <= RSIZE_MAX. */
- CHECK_OR_FILL(destsz <= RSIZE_MAX, dest, destsz, ch);
- CHECK_OR_FILL(count <= destsz, dest, destsz, ch);
+ if (dest == NULL || destsz > RSIZE_MAX) {
+ panic("memset_s failed as either dest == NULL "
+ "or destsz > RSIZE_MAX.\n");
+ }
/*
* Clang analyzer doesn't like us calling unsafe memory functions, so
* make it ignore this call.
*/
-#ifndef __clang_analyzer__
- memset(dest, ch, count);
-#endif
+ // NOLINTNEXTLINE
+ memset(dest, ch, (count <= destsz ? count : destsz));
}
void memcpy_s(void *dest, rsize_t destsz, const void *src, rsize_t count)
@@ -71,9 +69,12 @@
CHECK_OR_ZERO_FILL(d < s || d >= (s + count), dest, destsz);
CHECK_OR_ZERO_FILL(d > s || s >= (d + count), dest, destsz);
-#ifndef __clang_analyzer__
+ /*
+ * Clang analyzer doesn't like us calling unsafe memory functions, so
+ * make it ignore this call.
+ */
+ // NOLINTNEXTLINE
memcpy(dest, src, count);
-#endif
}
void memmove_s(void *dest, rsize_t destsz, const void *src, rsize_t count)
@@ -85,9 +86,12 @@
CHECK_OR_ZERO_FILL(destsz <= RSIZE_MAX, dest, destsz);
CHECK_OR_ZERO_FILL(count <= destsz, dest, destsz);
-#ifndef __clang_analyzer__
+ /*
+ * Clang analyzer doesn't like us calling unsafe memory functions, so
+ * make it ignore this call.
+ */
+ // NOLINTNEXTLINE
memmove(dest, src, count);
-#endif
}
/**