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 <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14575
This commit is contained in:
Richard Yao 2023-03-03 21:15:28 -05:00 committed by Brian Behlendorf
parent a4240a8ac7
commit 0b831cabc6
1 changed files with 1 additions and 0 deletions

View File

@ -663,6 +663,7 @@ typedef struct blkptr {
(u_longlong_t)DVA_GET_ASIZE(dva), \ (u_longlong_t)DVA_GET_ASIZE(dva), \
ws); \ ws); \
} \ } \
ASSERT3S(copies, >, 0); \
if (BP_IS_ENCRYPTED(bp)) { \ if (BP_IS_ENCRYPTED(bp)) { \
len += func(buf + len, size - len, \ len += func(buf + len, size - len, \
"salt=%llx iv=%llx:%llx%c", \ "salt=%llx iv=%llx:%llx%c", \