mirror of
https://github.com/linux-sunxi/u-boot-sunxi.git
synced 2024-02-12 11:16:03 +08:00
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: Lokesh Vutla <lokeshvutla@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user