9pfs: fail local_statfs() earlier
PATCH 1/1 9pfs: fail local_statfs() earlier
If we cannot open the given path, we can return right away instead of passing -1 to fstatfs() and close(). This will make Coverity happy.
(Coverity issue CID1371729)
--- hw/9pfs/9p-local.c | 3 +++ 1 file changed, 3 insertions(+)
hw/9pfs/9p-local.c +3 -0
@@ -1053,6 +1053,9 @@ static int local_statfs(FsContext *s, V9fsPath *fs_path, struct statfs *stbuf)int fd, ret; fd =local_open_nofollow (s, fs_path->data,O_RDONLY ,0 ); +if (fd ==-1 ) { +return -1 ; + } ret =fstatfs (fd, stbuf);close_preserve_errno (fd);return ret;
Quoted 15 lines · Greg Kurz
If we cannot open the given path, we can return right away instead of passing -1 to
fstatfs()andclose(). This will make Coverity happy.(Coverity issue CID1371729)
Signed-off-by Greg Kurz <[email protected]>--- hw/9pfs/9p-local.c | 3 +++ 1 file changed, 3 insertions(+)hw/9pfs/9p-local.c +0
-0
hw/9pfs/9p-local.c static int local_statfs(FsContext *s, V9fsPath *fs_path, struct statfs *stbuf) · line 1061
Quoted 9 lines
hw/9pfs/9p-local.c +3
-0@@ -1053,6 +1053,9 @@ static int local_statfs(FsContext *s, V9fsPath *fs_path, struct statfs *stbuf)int fd, ret; fd =local_open_nofollow (s, fs_path->data,O_RDONLY ,0 ); +if (fd ==-1 ) { +return -1 ; + } ret =fstatfs (fd, stbuf);close_preserve_errno (fd);return ret;
Regards,
Daniel
Signature · 3 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :|
Quoted 9 lines · Greg Kurz
If we cannot open the given path, we can return right away instead of passing -1 to
fstatfs()andclose(). This will make Coverity happy.(Coverity issue CID1371729)
Signed-off-by Greg Kurz <[email protected]>--- hw/9pfs/9p-local.c | 3 +++ 1 file changed, 3 insertions(+)
No difference in end-user observable behavior, but arguably nicer (and always more efficient to avoid unneeded syscalls).
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 6 lines · Greg Kurz
If we cannot open the given path, we can return right away instead of passing -1 to
fstatfs()andclose(). This will make Coverity happy.(Coverity issue CID1371729)
Signed-off-by Greg Kurz <[email protected]>
Quoted 20 lines
--- hw/9pfs/9p-local.c | 3 +++ 1 file changed, 3 insertions(+)hw/9pfs/9p-local.c +3
-0@@ -1053,6 +1053,9 @@ static int local_statfs(FsContext *s, V9fsPath *fs_path, struct statfs *stbuf)int fd, ret; fd =local_open_nofollow (s, fs_path->data,O_RDONLY ,0 ); +if (fd ==-1 ) { +return -1 ; + } ret =fstatfs (fd, stbuf);close_preserve_errno (fd);return ret;