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

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 15f7220

Browse files
committed
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 <kzak@redhat.com> (cherry picked from commit 9e96e6e)
1 parent d828cc2 commit 15f7220

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

libmount/src/fs_statmount.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,11 @@ 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);
367+
364368
rc = sys_statmount(fs->uniq_id, 0, mask,
365369
&fs->stmnt->buf, &fs->stmnt->bufsiz, 0);
366370
buf = fs->stmnt->buf;

0 commit comments

Comments
 (0)
0