tools/virtiofsd: Fix warning reported by Clang static code analyzer
cover tools/virtiofsd: Fix warning reported by Clang static code analyzer
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 | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-)
Signature · 1 line
2.21.1
PATCH 1/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: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
PATCH 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
PATCH 2/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: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;
^ ~~--- tools/virtiofsd/passthrough_ll.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
tools/virtiofsd/passthrough_ll.c +1 -3
@@ -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) {
@@ -938,8 +937,7 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name,g_atomic_int_set (&inode->refcount,2 ); inode->nlookup =1 ; - inode->fd = newfd; - newfd =-1 ; + inode->fd =-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
Re: [PATCH 1/3] tools/virtiofsd/passthrough_ll: Remove unneeded variable assignment
In reply to Philippe Mathieu-DaudéQuoted 7 lines · 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 readsaverr = ENOMEM; ^ ~~~~~~
Quoted 7 lines
Fixes 7c6b66027Reported-by Clang Static AnalyzerSigned-off-by Philippe Mathieu-Daudé <[email protected]>---
tools/virtiofsd/passthrough_ll.c| 2 --1 file changed, 2 deletions(-)
Jano
Re: [PATCH 2/3] tools/virtiofsd/passthrough_ll: Remove unneeded variable assignment
In reply to Philippe Mathieu-DaudéQuoted 30 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; ^ ~~Fixes 7c6b66027Reported-by Clang Static AnalyzerSigned-off-by Philippe Mathieu-Daudé <[email protected]>---
tools/virtiofsd/passthrough_ll.c| 4 +---1 file changed, 1 insertion(+), 3 deletions(-)tools/virtiofsd/passthrough_ll.c +0
-1@@ -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) {
tools/virtiofsd/passthrough_ll.c static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name, · line 940
Quoted 6 lines
tools/virtiofsd/passthrough_ll.c +1
-2@@ -938,8 +937,7 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name,g_atomic_int_set (&inode->refcount,2 ); inode->nlookup =1 ; - inode->fd = newfd; - newfd =-1 ; + inode->fd =-1 ;
The functional equivalent is:
inode->fd = newfd;
newfd cannot contain -1 here, as checked a few lines above:
newfd = openat(dir->fd, name, O_PATH | O_NOFOLLOW);
if (newfd == -1) {
goto out_err;
}Jano
Quoted 7 lines
tools/virtiofsd/passthrough_ll.c +0
-0inode->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
Re: [PATCH 3/3] tools/virtiofsd/fuse_lowlevel: Fix fuse_out_header.error value
In reply to Philippe Mathieu-DaudéQuoted 7 lines · 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 readerror = -ERANGE; ^ ~~~~~~~
Quoted 9 lines
Fixes 2de121f01eReported-by Clang Static AnalyzerSigned-off-by Philippe Mathieu-Daudé <[email protected]>---
RFC because untested
---tools/virtiofsd/fuse_lowlevel.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)
Jano
Re: [PATCH 2/3] tools/virtiofsd/passthrough_ll: Remove unneeded variable assignment
In reply to Ján TomkoQuoted 43 lines · Ján Tomko
Quoted 31 lines · Philippe Mathieu-Daudé
Fix warning reported by Clang static code analyzer:
CC
tools/virtiofsd/passthrough_ll.otools/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;
^ ~~Fixes 7c6b66027Reported-by Clang Static AnalyzerSigned-off-by Philippe Mathieu-Daudé <[email protected]>---
tools/virtiofsd/passthrough_ll.c| 4 +---1 file changed, 1 insertion(+), 3 deletions(-)tools/virtiofsd/passthrough_ll.c +0
-1@@ -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) {
tools/virtiofsd/passthrough_ll.c static int lo_do_lookup(fuse_req_t req, fuse_ino_t · line 941
Quoted 7 lines
tools/virtiofsd/passthrough_ll.c +1
-2@@ -938,8 +937,7 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name, g_atomic_int_set(&inode->refcount, 2); inode->nlookup = 1; - inode->fd = newfd; - newfd = -1; + inode->fd = -1;The functional equivalent is:
inode->fd= newfd;
Quoted 5 lines
newfd cannot contain -1 here, as checked a few lines above:
newfd =openat(dir->fd, name, O_PATH | O_NOFOLLOW); if (newfd == -1) {
gotoout_err;
}
Correct. I'll respin, thanks for the review!
Quoted 9 lines
Jano
Quoted 7 lines
tools/virtiofsd/passthrough_ll.c +0
-0inode->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