From 47b994049fd105f54a887e19ec0669e9084b7cf2 Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Sat, 11 Mar 2023 13:17:59 -0500 Subject: [PATCH] Silence clang static analyzer warnings about stored stack addresses Clang's static analyzer complains that nvs_xdr() and nvs_native() functions return pointers to stack memory. That is technically true, but the pointers are stored in stack memory from the caller's stack frame, are not read by the caller and are deallocated when the caller returns, so this is harmless. We set the pointers to NULL to silence the warnings. Reviewed-by: Tino Reichardt Reviewed-by: Brian Behlendorf Signed-off-by: Richard Yao Closes #14612 --- include/os/linux/spl/rpc/xdr.h | 3 --- module/nvpair/nvpair.c | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/include/os/linux/spl/rpc/xdr.h b/include/os/linux/spl/rpc/xdr.h index 1c03a42a99..b00f3542fc 100644 --- a/include/os/linux/spl/rpc/xdr.h +++ b/include/os/linux/spl/rpc/xdr.h @@ -75,9 +75,6 @@ struct xdr_bytesrec { void xdrmem_create(XDR *xdrs, const caddr_t addr, const uint_t size, const enum xdr_op op); -/* Currently not needed. If needed later, we'll add it to struct xdr_ops */ -#define xdr_destroy(xdrs) ((void) 0) - #define xdr_control(xdrs, req, info) \ (xdrs)->x_ops->xdr_control((xdrs), (req), (info)) diff --git a/module/nvpair/nvpair.c b/module/nvpair/nvpair.c index c8161f116b..c494056c5c 100644 --- a/module/nvpair/nvpair.c +++ b/module/nvpair/nvpair.c @@ -2808,7 +2808,7 @@ nvs_native_create(nvstream_t *nvs, nvs_native_t *native, char *buf, static void nvs_native_destroy(nvstream_t *nvs) { - (void) nvs; + nvs->nvs_private = NULL; } static int @@ -3189,7 +3189,7 @@ nvs_xdr_destroy(nvstream_t *nvs) switch (nvs->nvs_op) { case NVS_OP_ENCODE: case NVS_OP_DECODE: - xdr_destroy((XDR *)nvs->nvs_private); + nvs->nvs_private = NULL; break; default: break;