[File] Boolean within 'if'always evaluates to True

Steve Grubb sgrubb at redhat.com
Mon Jun 8 18:41:16 UTC 2020


Hello,

Continuing with the static analysis. I found a variable that is tested but its
value has not been changed. There is one path above where it gets set, but
that jumps to "done".

Signed-off-by: Steve Grubb <sgrubb at redhat.com>


diff --git a/src/magic.c b/src/magic.c
index da5baf10..54326635 100644
--- a/src/magic.c
+++ b/src/magic.c
@@ -463,8 +463,7 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
 	}
 
 	if (fd != -1) {
-		if (!okstat)
-			okstat = fstat(fd, &sb) == 0;
+		okstat = fstat(fd, &sb) == 0;
 		if (okstat && S_ISFIFO(sb.st_mode))
 			ispipe = 1;
 		if (inname == NULL)





More information about the File mailing list