]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Suppress Clang Static Analyzer warning about SNPRINTF_BLKPTR()
authorRichard Yao <richard.yao@alumni.stonybrook.edu>
Sat, 4 Mar 2023 02:15:28 +0000 (21:15 -0500)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 8 Mar 2023 21:51:26 +0000 (13:51 -0800)
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

include/sys/spa.h

index c9d03bf645a90fdd9a431cae1c95644e30c87096..ab07103fe8ba685b3d01f846e73b4f6e06efdbda 100644 (file)
@@ -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",                 \