[PATCH 2/5] kern/vfs_syscalls.c: kern_readlinkat: Don't set return value to uninitialized value

Conrad Meyer cemeyer at uw.edu
Wed Mar 12 00:20:03 UTC 2014


Struct auio is only initialized in one branch, but we use it to set
retval always. This isn't actually a problem because the other case is
an error return, so the retval is discarded.

However, fixing this reduces Clang static analysis pings, improving code
smell.

Signed-off-by: Conrad Meyer <conrad.meyer at isilon.com>
---
 sys/kern/vfs_syscalls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 4be9738..f680d43 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -2553,9 +2553,9 @@ kern_readlinkat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
 		auio.uio_td = td;
 		auio.uio_resid = count;
 		error = VOP_READLINK(vp, &auio, td->td_ucred);
+		td->td_retval[0] = count - auio.uio_resid;
 	}
 	vput(vp);
-	td->td_retval[0] = count - auio.uio_resid;
 	return (error);
 }
 
-- 
1.8.5.3



More information about the freebsd-hackers mailing list