Skip to content
Snippets Groups Projects
Commit 509b498a authored by Lokesh Vutla's avatar Lokesh Vutla Committed by Tom Rini
Browse files

ext4: Fix comparision of unsigned expression with < 0


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: default avatarLokesh Vutla <lokeshvutla@ti.com>
Reviewed-by: default avatarTom Rini <trini@konsulko.com>
parent 8a707baf
No related branches found
No related tags found
No related merge requests found
...@@ -60,9 +60,8 @@ int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len, char *buf) ...@@ -60,9 +60,8 @@ int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len, char *buf)
} }
/* Check partition boundaries */ /* Check partition boundaries */
if ((sector < 0) || if ((sector + ((byte_offset + byte_len - 1) >> log2blksz))
((sector + ((byte_offset + byte_len - 1) >> log2blksz)) >= part_info->size) {
>= part_info->size)) {
printf("%s read outside partition " LBAFU "\n", __func__, printf("%s read outside partition " LBAFU "\n", __func__,
sector); sector);
return 0; return 0;
......
...@@ -71,7 +71,7 @@ int ext4fs_read_file(struct ext2fs_node *node, loff_t pos, ...@@ -71,7 +71,7 @@ int ext4fs_read_file(struct ext2fs_node *node, loff_t pos,
blockcnt = lldiv(((len + pos) + blocksize - 1), blocksize); blockcnt = lldiv(((len + pos) + blocksize - 1), blocksize);
for (i = lldiv(pos, blocksize); i < blockcnt; i++) { for (i = lldiv(pos, blocksize); i < blockcnt; i++) {
lbaint_t blknr; long int blknr;
int blockoff = pos - (blocksize * i); int blockoff = pos - (blocksize * i);
int blockend = blocksize; int blockend = blocksize;
int skipfirst = 0; int skipfirst = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment