aboutsummaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorRichard Yao <[email protected]>2023-03-06 13:29:36 -0500
committerBrian Behlendorf <[email protected]>2023-03-08 13:52:24 -0800
commit950980b4c4f8b6441c0b6b3afe150437190a69b6 (patch)
tree41efa2dfadc649d3656e4b1d4df769dc2227ffc1 /module
parent37edc7ea9881a0fcd3df67fe1e29d22ee4deb7a9 (diff)
Suppress clang static analyzer warning in vdev_stat_update()
63652e154643cfe596fe077c13de0e7be34dd863 added unnecessary branches in `vdev_stat_update()` to suppress an ASAN false positive the breaks ztest. This had the downside of causing false positive reports in both Coverity and Clang's static analyzer. vd is never NULL, so we add a preprocessor check to only apply the workaround when compiling with ASAN support. Reported-by: Coverity (CID-1524583) Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Richard Yao <[email protected]> Closes #14575
Diffstat (limited to 'module')
-rw-r--r--module/zfs/vdev.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c
index 275d5cbbf..4922067dc 100644
--- a/module/zfs/vdev.c
+++ b/module/zfs/vdev.c
@@ -4700,8 +4700,14 @@ vdev_stat_update(zio_t *zio, uint64_t psize)
vdev_t *vd = zio->io_vd ? zio->io_vd : rvd;
vdev_t *pvd;
uint64_t txg = zio->io_txg;
+/* Suppress ASAN false positive */
+#ifdef __SANITIZE_ADDRESS__
vdev_stat_t *vs = vd ? &vd->vdev_stat : NULL;
vdev_stat_ex_t *vsx = vd ? &vd->vdev_stat_ex : NULL;
+#else
+ vdev_stat_t *vs = &vd->vdev_stat;
+ vdev_stat_ex_t *vsx = &vd->vdev_stat_ex;
+#endif
zio_type_t type = zio->io_type;
int flags = zio->io_flags;