tools/virtiofsd: Fix warning reported by Clang static code analyzer
v2 cover tools/virtiofsd: Fix warning reported by Clang static code analyzer
Since v1:
- Addressed Ján Tomko review comment
- Added Ján Tomko R-b tag
Philippe Mathieu-Daudé (3):
tools/virtiofsd/passthrough_ll: Remove unneeded variable assignment tools/virtiofsd/passthrough_ll: Remove unneeded variable assignment tools/virtiofsd/fuse_lowlevel: Fix fuse_out_header::error value
tools/virtiofsd/fuse_lowlevel.c | 2 +- tools/virtiofsd/passthrough_ll.c | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-)
Signature · 1 line
2.21.1
PATCH v2 2/3 tools/virtiofsd/passthrough_ll: Remove unneeded variable assignment
Fix warning reported by Clang static code analyzer:
CC tools/virtiofsd/passthrough_ll.o
tools/virtiofsd/passthrough_ll.c:925:9: warning: Value stored to 'newfd' is never read
newfd = -1;
^ ~~
tools/virtiofsd/passthrough_ll.c:942:9: warning: Value stored to 'newfd' is never read
newfd = -1;
^ ~~---
v2: do not set newfd, use it (jtomko)
--- tools/virtiofsd/passthrough_ll.c | 2 -- 1 file changed, 2 deletions(-)
tools/virtiofsd/passthrough_ll.c +0 -2
@@ -922,7 +922,6 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name, inode =lo_find (lo, &e->attr);if (inode) {close (newfd); - newfd =-1 ; }else { inode =calloc (1 ,sizeof (struct lo_inode ));if (!inode) {
@@ -939,7 +938,6 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name, inode->nlookup =1 ; inode->fd = newfd; - newfd =-1 ; inode->key.ino = e->attr.st_ino; inode->key.dev = e->attr.st_dev;pthread_mutex_init (&inode->plock_mutex,NULL );
Signature · 1 line
2.21.1
PATCH v2 1/3 tools/virtiofsd/passthrough_ll: Remove unneeded variable assignment
In reply to Philippe Mathieu-DaudéFix warning reported by Clang static code analyzer:
CC tools/virtiofsd/passthrough_ll.o
tools/virtiofsd/passthrough_ll.c:1083:5: warning: Value stored to 'saverr' is never read
saverr = ENOMEM;
^ ~~~~~~--- tools/virtiofsd/passthrough_ll.c | 2 -- 1 file changed, 2 deletions(-)
tools/virtiofsd/passthrough_ll.c +0 -2
@@ -1080,8 +1080,6 @@ static void lo_mknod_symlink(fuse_req_t req, fuse_ino_t parent,return ; } - saverr =ENOMEM ; - saverr =lo_change_cred (req, &old);if (saverr) { goto out;
Signature · 1 line
2.21.1
RFC PATCH v2 3/3 tools/virtiofsd/fuse_lowlevel: Fix fuse_out_header::error value
In reply to Philippe Mathieu-DaudéFix warning reported by Clang static code analyzer:
CC tools/virtiofsd/fuse_lowlevel.o
tools/virtiofsd/fuse_lowlevel.c:195:9: warning: Value stored to 'error' is never read
error = -ERANGE;
^ ~~~~~~~---
RFC because untested
--- tools/virtiofsd/fuse_lowlevel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/virtiofsd/fuse_lowlevel.c +1 -1
@@ -192,7 +192,7 @@ int fuse_send_reply_iov_nofree(fuse_req_t req, int error, struct iovec *iov,if (error <=-1000 || error >0 ) {fuse_log (FUSE_LOG_ERR ,"fuse: bad error value: %i\n" , error); - error = -ERANGE ; + out.error = -ERANGE ; } iov[0 ].iov_base = &out;
Signature · 1 line
2.21.1
Re: [PATCH v2 1/3] tools/virtiofsd/passthrough_ll: Remove unneeded variable assignment
In reply to Philippe Mathieu-DaudéQuoted 11 lines · * Philippe Mathieu-Daudé ([email protected]) wrote:
Fix warning reported by Clang static code analyzer:
CC
tools/virtiofsd/passthrough_ll.o
tools/virtiofsd/passthrough_ll.c:1083:5: warning: Value stored to 'saverr' is never readsaverr = ENOMEM; ^ ~~~~~~Fixes 7c6b66027Reported-by Clang Static AnalyzerReviewed-by Ján Tomko <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Thanks, you might want to snd that to the upstream libfuse (different context); it looks like it's the same there.
Dave
Quoted 20 lines
--- tools/virtiofsd/passthrough_ll.c | 2 -- 1 file changed, 2 deletions(-)tools/virtiofsd/passthrough_ll.c +0
-2@@ -1080,8 +1080,6 @@ static void lo_mknod_symlink(fuse_req_t req, fuse_ino_t parent,return ; } - saverr =ENOMEM ; - saverr =lo_change_cred (req, &old);if (saverr) { goto out;Signature · 1 line
2.21.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [PATCH v2 2/3] tools/virtiofsd/passthrough_ll: Remove unneeded variable assignment
In reply to Philippe Mathieu-DaudéQuoted 10 lines · Philippe Mathieu-Daudé
Fix warning reported by Clang static code analyzer:
CC
tools/virtiofsd/passthrough_ll.o
tools/virtiofsd/passthrough_ll.c:925:9: warning: Value stored to 'newfd' is never readnewfd = -1; ^ ~~ tools/virtiofsd/passthrough_ll.c:942:9: warning: Value stored to 'newfd' is never read newfd = -1; ^ ~~
Quoted 9 lines
Fixes 7c6b66027Reported-by Clang Static AnalyzerSigned-off-by Philippe Mathieu-Daudé <[email protected]>---
v2: do not set newfd, use it (jtomko)
---tools/virtiofsd/passthrough_ll.c| 2 --1 file changed, 2 deletions(-)
Jano
Re: [PATCH v2 2/3] tools/virtiofsd/passthrough_ll: Remove unneeded variable assignment
In reply to Philippe Mathieu-DaudéQuoted 10 lines · * Philippe Mathieu-Daudé ([email protected]) wrote:
Fix warning reported by Clang static code analyzer:
CC
tools/virtiofsd/passthrough_ll.o
tools/virtiofsd/passthrough_ll.c:925:9: warning: Value stored to 'newfd' is never readnewfd = -1; ^ ~~ tools/virtiofsd/passthrough_ll.c:942:9: warning: Value stored to 'newfd' is never read newfd = -1; ^ ~~
Quoted 3 lines
Fixes 7c6b66027Reported-by Clang Static AnalyzerSigned-off-by Philippe Mathieu-Daudé <[email protected]>
OK; actually one of those is in upstream, and another was added by Miklos's 'virtiofsd: fail when parent inode isn't known in lo_do_lookup()' - which kind of balances that if out.
I suspect the reason was because out_err: closes newfd if it's not -1, so they were keeping it safe like that just in case another error case gets added.
Dave
Quoted 29 lines
---
v2: do not set newfd, use it (jtomko)--- tools/virtiofsd/passthrough_ll.c | 2 -- 1 file changed, 2 deletions(-)tools/virtiofsd/passthrough_ll.c +0
-2@@ -922,7 +922,6 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name, inode =lo_find (lo, &e->attr);if (inode) {close (newfd); - newfd =-1 ; }else { inode =calloc (1 ,sizeof (struct lo_inode ));if (!inode) {@@ -939,7 +938,6 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name, inode->nlookup =1 ; inode->fd = newfd; - newfd =-1 ; inode->key.ino = e->attr.st_ino; inode->key.dev = e->attr.st_dev;pthread_mutex_init (&inode->plock_mutex,NULL );Signature · 1 line
2.21.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [PATCH v2 1/3] tools/virtiofsd/passthrough_ll: Remove unneeded variable assignment
In reply to Dr. David Alan GilbertQuoted 8 lines · Dr. David Alan Gilbert
Quoted 7 lines · * Philippe Mathieu-Daudé ([email protected]) wrote:
Fix warning reported by Clang static code analyzer:
CC
tools/virtiofsd/passthrough_ll.o
tools/virtiofsd/passthrough_ll.c:1083:5: warning: Value stored to 'saverr' is never readsaverr = ENOMEM; ^ ~~~~~~
Quoted 7 lines
Quoted 4 lines
Fixes 7c6b66027Reported-by Clang Static AnalyzerReviewed-by Ján Tomko <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Thanks, you might want to snd that to the upstream libfuse (different context); it looks like it's the same there.
Done: https://github.com/libfuse/libfuse/pull/501
Quoted 2 lines
Reviewed-by Dr. David Alan Gilbert <[email protected]>
Thanks!
Re: [RFC PATCH v2 3/3] tools/virtiofsd/fuse_lowlevel: Fix fuse_out_header::error value
In reply to Philippe Mathieu-DaudéQuoted 11 lines · * Philippe Mathieu-Daudé ([email protected]) wrote:
Fix warning reported by Clang static code analyzer:
CC
tools/virtiofsd/fuse_lowlevel.o
tools/virtiofsd/fuse_lowlevel.c:195:9: warning: Value stored to 'error' is never readerror = -ERANGE; ^ ~~~~~~~Fixes 2de121f01eReported-by Clang Static AnalyzerReviewed-by Ján Tomko <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Nice, this actually fixes 3db2876
Quoted 22 lines
---
RFC because untested--- tools/virtiofsd/fuse_lowlevel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/virtiofsd/fuse_lowlevel.c +1
-1@@ -192,7 +192,7 @@ int fuse_send_reply_iov_nofree(fuse_req_t req, int error, struct iovec *iov,if (error <=-1000 || error >0 ) {fuse_log (FUSE_LOG_ERR ,"fuse: bad error value: %i\n" , error); - error = -ERANGE ; + out.error = -ERANGE ; } iov[0 ].iov_base = &out;Signature · 1 line
2.21.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [RFC PATCH v2 3/3] tools/virtiofsd/fuse_lowlevel: Fix fuse_out_header::error value
Quoted 8 lines · Dr. David Alan Gilbert
Quoted 7 lines · * Philippe Mathieu-Daudé ([email protected]) wrote:
Fix warning reported by Clang static code analyzer:
CC
tools/virtiofsd/fuse_lowlevel.o
tools/virtiofsd/fuse_lowlevel.c:195:9: warning: Value stored to 'error' is never readerror = -ERANGE; ^ ~~~~~~~
Quoted 6 lines
Quoted 4 lines
Fixes 2de121f01eReported-by Clang Static AnalyzerReviewed-by Ján Tomko <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Nice, this actually fixes 3db2876
Good catch, so this fix can be applied to QEMU (while patch #1 needs backport from upstream libfuse), right?
Quoted 2 lines
Reviewed-by Dr. David Alan Gilbert <[email protected]>
Thanks.
Quoted 26 lines
Quoted 23 lines
---
RFC because untested--- tools/virtiofsd/fuse_lowlevel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/virtiofsd/fuse_lowlevel.c +1
-1@@ -192,7 +192,7 @@ int fuse_send_reply_iov_nofree(fuse_req_t req, int error, struct iovec *iov,if (error <=-1000 || error >0 ) {fuse_log (FUSE_LOG_ERR ,"fuse: bad error value: %i\n" , error); - error = -ERANGE ; + out.error = -ERANGE ; } iov[0 ].iov_base = &out;Signature · 1 line
2.21.1--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [RFC PATCH v2 3/3] tools/virtiofsd/fuse_lowlevel: Fix fuse_out_header::error value
Quoted 14 lines · * Philippe Mathieu-Daudé ([email protected]) wrote:
Quoted 13 lines · Dr. David Alan Gilbert
Quoted 11 lines · * Philippe Mathieu-Daudé ([email protected]) wrote:
Fix warning reported by Clang static code analyzer:
CC
tools/virtiofsd/fuse_lowlevel.o
tools/virtiofsd/fuse_lowlevel.c:195:9: warning: Value stored to 'error' is never readerror = -ERANGE; ^ ~~~~~~~Fixes 2de121f01eReported-by Clang Static AnalyzerReviewed-by Ján Tomko <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 4 lines
Quoted 1 line
Nice, this actually fixes 3db2876
Good catch, so this fix can be applied to QEMU (while patch #1 needs backport from upstream libfuse), right?
I'll take all 3 into QEMU, libfuse can take it asynchronously.
Dave
Quoted 30 lines
Quoted 2 lines
Reviewed-by Dr. David Alan Gilbert <[email protected]>Thanks.
Quoted 24 lines
Quoted 21 lines
---
RFC because untested--- tools/virtiofsd/fuse_lowlevel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/virtiofsd/fuse_lowlevel.c +1
-1@@ -192,7 +192,7 @@ int fuse_send_reply_iov_nofree(fuse_req_t req, int error, struct iovec *iov,if (error <=-1000 || error >0 ) {fuse_log (FUSE_LOG_ERR ,"fuse: bad error value: %i\n" , error); - error = -ERANGE ; + out.error = -ERANGE ; } iov[0 ].iov_base = &out;Signature · 1 line
2.21.1--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK