public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] EXT: fix test ext_generic_write_end() copied return value
@ 2008-04-17  3:21 Roel Kluin
  2008-04-17 15:44 ` Badari Pulavarty
  0 siblings, 1 reply; 2+ messages in thread
From: Roel Kluin @ 2008-04-17  3:21 UTC (permalink / raw)
  To: linux-ext4, sct, akpm, adilger

'copied' is unsigned, whereas 'ret2' is not. The test (copied < 0) fails

Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
---
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index eb95670..43daaae 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -1261,10 +1261,11 @@ static int ext3_ordered_write_end(struct file *file,
 		new_i_size = pos + copied;
 		if (new_i_size > EXT3_I(inode)->i_disksize)
 			EXT3_I(inode)->i_disksize = new_i_size;
-		copied = ext3_generic_write_end(file, mapping, pos, len, copied,
+		ret2 = ext3_generic_write_end(file, mapping, pos, len, copied,
 							page, fsdata);
-		if (copied < 0)
-			ret = copied;
+		copied = ret2;
+		if (ret2 < 0)
+			ret = ret2;
 	}
 	ret2 = ext3_journal_stop(handle);
 	if (!ret)
@@ -1289,10 +1290,11 @@ static int ext3_writeback_write_end(struct file *file,
 	if (new_i_size > EXT3_I(inode)->i_disksize)
 		EXT3_I(inode)->i_disksize = new_i_size;
 
-	copied = ext3_generic_write_end(file, mapping, pos, len, copied,
+	ret2 = ext3_generic_write_end(file, mapping, pos, len, copied,
 							page, fsdata);
-	if (copied < 0)
-		ret = copied;
+	copied = ret2;
+	if (ret2 < 0)
+		ret = ret2;
 
 	ret2 = ext3_journal_stop(handle);
 	if (!ret)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 945cbf6..47d5d73 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1301,10 +1301,11 @@ static int ext4_ordered_write_end(struct file *file,
 		new_i_size = pos + copied;
 		if (new_i_size > EXT4_I(inode)->i_disksize)
 			EXT4_I(inode)->i_disksize = new_i_size;
-		copied = ext4_generic_write_end(file, mapping, pos, len, copied,
+		ret2 = ext4_generic_write_end(file, mapping, pos, len, copied,
 							page, fsdata);
-		if (copied < 0)
-			ret = copied;
+		copied = ret2;
+		if (ret2 < 0)
+			ret = ret2;
 	}
 	ret2 = ext4_journal_stop(handle);
 	if (!ret)
@@ -1329,10 +1330,11 @@ static int ext4_writeback_write_end(struct file *file,
 	if (new_i_size > EXT4_I(inode)->i_disksize)
 		EXT4_I(inode)->i_disksize = new_i_size;
 
-	copied = ext4_generic_write_end(file, mapping, pos, len, copied,
+	ret2 = ext4_generic_write_end(file, mapping, pos, len, copied,
 							page, fsdata);
-	if (copied < 0)
-		ret = copied;
+	copied = ret2;
+	if (ret2 < 0)
+		ret = ret2;
 
 	ret2 = ext4_journal_stop(handle);
 	if (!ret)

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

* Re: [PATCH] EXT: fix test ext_generic_write_end() copied return value
  2008-04-17  3:21 [PATCH] EXT: fix test ext_generic_write_end() copied return value Roel Kluin
@ 2008-04-17 15:44 ` Badari Pulavarty
  0 siblings, 0 replies; 2+ messages in thread
From: Badari Pulavarty @ 2008-04-17 15:44 UTC (permalink / raw)
  To: Roel Kluin; +Cc: linux-ext4, sct, akpm, adilger, Nick Piggin


On Thu, 2008-04-17 at 05:21 +0200, Roel Kluin wrote:
> 'copied' is unsigned, whereas 'ret2' is not. The test (copied < 0) fails
> 

While your patch is correct, we don't need it :(

"copied" can never be < 0. Infact, the check itself is NOT needed.
It might have been my fault to add that check, when we converted to
write_begin/end interfaces :(

As you can see block_write_end() never returns < 0.

Thanks,
Badari


> Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
> ---
> diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
> index eb95670..43daaae 100644
> --- a/fs/ext3/inode.c
> +++ b/fs/ext3/inode.c
> @@ -1261,10 +1261,11 @@ static int ext3_ordered_write_end(struct file *file,
>  		new_i_size = pos + copied;
>  		if (new_i_size > EXT3_I(inode)->i_disksize)
>  			EXT3_I(inode)->i_disksize = new_i_size;
> -		copied = ext3_generic_write_end(file, mapping, pos, len, copied,
> +		ret2 = ext3_generic_write_end(file, mapping, pos, len, copied,
>  							page, fsdata);
> -		if (copied < 0)
> -			ret = copied;
> +		copied = ret2;
> +		if (ret2 < 0)
> +			ret = ret2;
>  	}
>  	ret2 = ext3_journal_stop(handle);
>  	if (!ret)
> @@ -1289,10 +1290,11 @@ static int ext3_writeback_write_end(struct file *file,
>  	if (new_i_size > EXT3_I(inode)->i_disksize)
>  		EXT3_I(inode)->i_disksize = new_i_size;
>  
> -	copied = ext3_generic_write_end(file, mapping, pos, len, copied,
> +	ret2 = ext3_generic_write_end(file, mapping, pos, len, copied,
>  							page, fsdata);
> -	if (copied < 0)
> -		ret = copied;
> +	copied = ret2;
> +	if (ret2 < 0)
> +		ret = ret2;
>  
>  	ret2 = ext3_journal_stop(handle);
>  	if (!ret)
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 945cbf6..47d5d73 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -1301,10 +1301,11 @@ static int ext4_ordered_write_end(struct file *file,
>  		new_i_size = pos + copied;
>  		if (new_i_size > EXT4_I(inode)->i_disksize)
>  			EXT4_I(inode)->i_disksize = new_i_size;
> -		copied = ext4_generic_write_end(file, mapping, pos, len, copied,
> +		ret2 = ext4_generic_write_end(file, mapping, pos, len, copied,
>  							page, fsdata);
> -		if (copied < 0)
> -			ret = copied;
> +		copied = ret2;
> +		if (ret2 < 0)
> +			ret = ret2;
>  	}
>  	ret2 = ext4_journal_stop(handle);
>  	if (!ret)
> @@ -1329,10 +1330,11 @@ static int ext4_writeback_write_end(struct file *file,
>  	if (new_i_size > EXT4_I(inode)->i_disksize)
>  		EXT4_I(inode)->i_disksize = new_i_size;
>  
> -	copied = ext4_generic_write_end(file, mapping, pos, len, copied,
> +	ret2 = ext4_generic_write_end(file, mapping, pos, len, copied,
>  							page, fsdata);
> -	if (copied < 0)
> -		ret = copied;
> +	copied = ret2;
> +	if (ret2 < 0)
> +		ret = ret2;
>  
>  	ret2 = ext4_journal_stop(handle);
>  	if (!ret)
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

end of thread, other threads:[~2008-04-17 15:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-17  3:21 [PATCH] EXT: fix test ext_generic_write_end() copied return value Roel Kluin
2008-04-17 15:44 ` Badari Pulavarty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox