8000 libmount: avoid calling memset() unnecessarily · util-linux/util-linux@9e96e6e · GitHub
[go: up one dir, main page]

Skip to content

Commit 9e96e6e

Browse files
committed
libmount: avoid calling memset() unnecessarily
This is primarily to satisfy static analyzers, as memset() 8000 is defined as a non-null function (although it does nothing when bufsiz=0). Signed-off-by: Karel Zak <kzak@redhat.com>
1 parent b3bb829 commit 9e96e6e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

libmount/src/fs_statmount.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,10 @@ int mnt_fs_fetch_statmount(struct libmnt_fs *fs, uint64_t mask)
360360

361361
if (fs->stmnt) {
362362
DBG(FS, ul_debugobj(fs, " reuse libmnt_stmnt"));
363-
memset(fs->stmnt->buf, 0, fs->stmnt->bufsiz);
363+
364+
/* note that sys_statmount (re)allocates the buffer */
365+
if (fs->stmnt->buf && fs->stmnt->bufsiz > 0)
366+
memset(fs->stmnt->buf, 0, fs->stmnt->bufsiz);
364367

365368
rc = ul_statmount(fs->uniq_id, 0, mask,
366369
&fs->stmnt->buf, &fs->stmnt->bufsiz, 0);

0 commit comments

Comments
 (0)
0