linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: Variable to signed to check return code
@ 2019-05-17  9:01 Philippe Mazenauer
  2019-05-17 10:25 ` Lee Jones
  0 siblings, 1 reply; 10+ messages in thread
From: Philippe Mazenauer @ 2019-05-17  9:01 UTC (permalink / raw)
  Cc: lee.jones, Philippe Mazenauer, Theodore Ts'o, Andreas Dilger,
	linux-ext4, linux-kernel

Variables 'n' and 'err' are both used for less-than-zero error checking,
however both are declared as unsigned. Ensure ext4_map_blocks() and
add_system_zone() are able to have their return values propagated
correctly by redefining them both as signed integers.

../fs/ext4/block_validity.c:158:9: warning: comparison of unsigned
expression < 0 is always false [-Wtype-limits]
    if (n < 0) {
        ^

../fs/ext4/block_validity.c:173:12: warning: comparison of unsigned
expression < 0 is always false [-Wtype-limits]
    if (err < 0)
        ^

Signed-off-by: Philippe Mazenauer <philippe.mazenauer@outlook.de>
---
 fs/ext4/block_validity.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/block_validity.c b/fs/ext4/block_validity.c
index 968f163b5feb..678e99aeef1f 100644
--- a/fs/ext4/block_validity.c
+++ b/fs/ext4/block_validity.c
@@ -142,7 +142,8 @@ static int ext4_protect_reserved_inode(struct super_block *sb, u32 ino)
 	struct inode *inode;
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
 	struct ext4_map_blocks map;
-	u32 i = 0, err = 0, num, n;
+	int err = 0, n;
+	u32 i = 0, num;
 
 	if ((ino < EXT4_ROOT_INO) ||
 	    (ino > le32_to_cpu(sbi->s_es->s_inodes_count)))
-- 
2.17.1


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

end of thread, other threads:[~2019-05-22  6:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-17  9:01 [PATCH] ext4: Variable to signed to check return code Philippe Mazenauer
2019-05-17 10:25 ` Lee Jones
2019-05-17 20:28   ` Theodore Ts'o
2019-05-18  6:38     ` Lee Jones
2019-05-18 19:54       ` Theodore Ts'o
2019-05-20  8:24         ` Lee Jones
2019-05-20 15:36           ` Theodore Ts'o
2019-05-21  7:25             ` Lee Jones
2019-05-21 17:16               ` Theodore Ts'o
2019-05-22  6:59                 ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).