From: Tom Rini Date: Tue, 25 Apr 2017 14:04:47 -0400 Subject: [U-Boot] [RFC PATCH] ext4: Fix comparision of unsigned expression with < 0 In-Reply-To: <20170425045227.19713-1-lokeshvutla@ti.com> References: <20170425045227.19713-1-lokeshvutla@ti.com> Message-ID: <20170425180447.GC12511@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Tue, Apr 25, 2017 at 10:22:27AM +0530, Lokesh Vutla wrote: > In file ext4fs.c funtion ext4fs_read_file() compares an > unsigned expression with < 0 like below > > lbaint_t blknr; > blknr = read_allocated_block(&(node->inode), i); > if (blknr < 0) > return -1; > > blknr is of type ulong/uint64_t. read_allocated_block() returns > long int. So comparing blknr with < 0 will always be false. Instead > declare blknr as long int. > > Reported-by: Sunita Nadampalli > Signed-off-by: Lokesh Vutla > --- > fs/ext4/ext4fs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c > index 7187dcfb05..081509dbb4 100644 > --- a/fs/ext4/ext4fs.c > +++ b/fs/ext4/ext4fs.c > @@ -71,7 +71,7 @@ int ext4fs_read_file(struct ext2fs_node *node, loff_t pos, > blockcnt = lldiv(((len + pos) + blocksize - 1), blocksize); > > for (i = lldiv(pos, blocksize); i < blockcnt; i++) { > - lbaint_t blknr; > + long int blknr; > int blockoff = pos - (blocksize * i); > int blockend = blocksize; > int skipfirst = 0; My only question is, did you catch that by inspection, clang, or a newer than gcc-6.3 warning? Also, fs/ext4/dev.c:63 is a similar problem, if you'd like to non-RFC a v2. Thanks! -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: