From 950980b4c4f8b6441c0b6b3afe150437190a69b6 Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Mon, 6 Mar 2023 13:29:36 -0500 Subject: [PATCH] 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 Signed-off-by: Richard Yao Closes #14575 --- module/zfs/vdev.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c index 275d5cbbf5..4922067dc8 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;