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/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
 }
 
 /**