From: Karel Zak Date: Thu, 24 Apr 2025 16:32:35 +0000 (+0200) Subject: libmount: avoid calling memset() unnecessarily X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e96e6ed9cce4cbaf3b9ca6e61d0b0ee070685e9;p=thirdparty%2Futil-linux.git libmount: avoid calling memset() unnecessarily This is primarily to satisfy static analyzers, as memset() is defined as a non-null function (although it does nothing when bufsiz=0). Signed-off-by: Karel Zak --- diff --git a/libmount/src/fs_statmount.c b/libmount/src/fs_statmount.c index 3993c7b69..4e98dd775 100644 --- a/libmount/src/fs_statmount.c +++ b/libmount/src/fs_statmount.c @@ -360,7 +360,10 @@ int mnt_fs_fetch_statmount(struct libmnt_fs *fs, uint64_t mask) if (fs->stmnt) { DBG(FS, ul_debugobj(fs, " reuse libmnt_stmnt")); - memset(fs->stmnt->buf, 0, fs->stmnt->bufsiz); + + /* note that sys_statmount (re)allocates the buffer */ + if (fs->stmnt->buf && fs->stmnt->bufsiz > 0) + memset(fs->stmnt->buf, 0, fs->stmnt->bufsiz); rc = ul_statmount(fs->uniq_id, 0, mask, &fs->stmnt->buf, &fs->stmnt->bufsiz, 0);