From 0b831cabc6e5f210445d90c89996abc88169f01f Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Fri, 3 Mar 2023 21:15:28 -0500 Subject: [PATCH] Suppress Clang Static Analyzer warning about SNPRINTF_BLKPTR() Clang's static analyzer pointed out that if we can pass a -1 array index to copyname[copies] if there are no valid DVAs. This is an absurd situation, but it suggests that we are missing an assertion, so we add it. Reviewed-by: Brian Behlendorf Signed-off-by: Richard Yao Closes #14575 --- include/sys/spa.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/sys/spa.h b/include/sys/spa.h index c9d03bf64..ab07103fe 100644 --- a/include/sys/spa.h +++ b/include/sys/spa.h @@ -663,6 +663,7 @@ typedef struct blkptr { (u_longlong_t)DVA_GET_ASIZE(dva), \ ws); \ } \ + ASSERT3S(copies, >, 0); \ if (BP_IS_ENCRYPTED(bp)) { \ len += func(buf + len, size - len, \ "salt=%llx iv=%llx:%llx%c", \