diff mbox

[3/5] e2image: avoid potential divide by zero

Message ID 1388726998-14349-3-git-send-email-tytso@mit.edu
State Accepted, archived
Headers show

Commit Message

Theodore Ts'o Jan. 3, 2014, 5:29 a.m. UTC
It's highly unlikely after five seconds that zero blocks would have
been written, but let's silence the Coverity warning.

Addresses-Coverity-ID: 1147780

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 misc/e2image.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Eric Sandeen Jan. 3, 2014, 4:42 p.m. UTC | #1
On 1/2/14, 11:29 PM, Theodore Ts'o wrote:
> It's highly unlikely after five seconds that zero blocks would have
> been written, but let's silence the Coverity warning.
> 
> Addresses-Coverity-ID: 1147780
> 
> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
>  misc/e2image.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/misc/e2image.c b/misc/e2image.c
> index ac62ffe..6c51137 100644
> --- a/misc/e2image.c
> +++ b/misc/e2image.c
> @@ -634,7 +634,7 @@ more_blocks:
>  			bscount = print_progress(total_written,
>  						 meta_blocks_count);
>  			duration = time(NULL) - start_time;
> -			if (duration > 5) {
> +			if (duration > 5 && total_written) {
>  				time_t est = (duration * meta_blocks_count /
>  					      total_written) - duration;
>  				char buff[30];
> 

--
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
diff mbox

Patch

diff --git a/misc/e2image.c b/misc/e2image.c
index ac62ffe..6c51137 100644
--- a/misc/e2image.c
+++ b/misc/e2image.c
@@ -634,7 +634,7 @@  more_blocks:
 			bscount = print_progress(total_written,
 						 meta_blocks_count);
 			duration = time(NULL) - start_time;
-			if (duration > 5) {
+			if (duration > 5 && total_written) {
 				time_t est = (duration * meta_blocks_count /
 					      total_written) - duration;
 				char buff[30];