All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2] ext4: Fix comparision of unsigned expression with < 0
@ 2017-04-26 11:28 Lokesh Vutla
  2017-04-26 11:55 ` Tom Rini
  2017-04-28 13:09 ` [U-Boot] [U-Boot, " Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Lokesh Vutla @ 2017-04-26 11:28 UTC (permalink / raw)
  To: u-boot

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.

Similarly ext4/dev.c does a similar comparison. Drop the redundant
comparison.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
Changes since v1:
- Fixed similar comparision in ext4/dev.c

 fs/ext4/dev.c    | 5 ++---
 fs/ext4/ext4fs.c | 2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/ext4/dev.c b/fs/ext4/dev.c
index ee84d3fbe1..ae2ba6a901 100644
--- a/fs/ext4/dev.c
+++ b/fs/ext4/dev.c
@@ -60,9 +60,8 @@ int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len, char *buf)
 	}
 
 	/* Check partition boundaries */
-	if ((sector < 0) ||
-	    ((sector + ((byte_offset + byte_len - 1) >> log2blksz))
-	     >= part_info->size)) {
+	if ((sector + ((byte_offset + byte_len - 1) >> log2blksz))
+	    >= part_info->size) {
 		printf("%s read outside partition " LBAFU "\n", __func__,
 		       sector);
 		return 0;
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;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH v2] ext4: Fix comparision of unsigned expression with < 0
  2017-04-26 11:28 [U-Boot] [PATCH v2] ext4: Fix comparision of unsigned expression with < 0 Lokesh Vutla
@ 2017-04-26 11:55 ` Tom Rini
  2017-04-28 13:09 ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2017-04-26 11:55 UTC (permalink / raw)
  To: u-boot

On Wed, Apr 26, 2017 at 04:58:22PM +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.
> 
> Similarly ext4/dev.c does a similar comparison. Drop the redundant
> comparison.
> 
> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170426/e4be713c/attachment.sig>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [U-Boot, v2] ext4: Fix comparision of unsigned expression with < 0
  2017-04-26 11:28 [U-Boot] [PATCH v2] ext4: Fix comparision of unsigned expression with < 0 Lokesh Vutla
  2017-04-26 11:55 ` Tom Rini
@ 2017-04-28 13:09 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2017-04-28 13:09 UTC (permalink / raw)
  To: u-boot

On Wed, Apr 26, 2017 at 04:58:22PM +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.
> 
> Similarly ext4/dev.c does a similar comparison. Drop the redundant
> comparison.
> 
> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170428/7c9c440f/attachment.sig>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-28 13:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-26 11:28 [U-Boot] [PATCH v2] ext4: Fix comparision of unsigned expression with < 0 Lokesh Vutla
2017-04-26 11:55 ` Tom Rini
2017-04-28 13:09 ` [U-Boot] [U-Boot, " Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.