[ovs-dev] [coverity 12/12] timeval: Avoid unnecessary integer overflow in time_alarm().

Ethan Jackson ethan at nicira.com
Fri Feb 1 21:59:26 UTC 2013


I've always found this part of C annoying.

Acked-by: Ethan Jackson <ethan at nicira.com>

On Thu, Jan 24, 2013 at 2:44 PM, Ben Pfaff <blp at nicira.com> wrote:
> Durations longer than 4294967 seconds would unnecessarily overflow in the
> multiplication here.
>
> Found by Coverity.
>
> Signed-off-by: Ben Pfaff <blp at nicira.com>
> ---
>  lib/timeval.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/timeval.c b/lib/timeval.c
> index d91305c..ef9c8fe 100644
> --- a/lib/timeval.c
> +++ b/lib/timeval.c
> @@ -1,5 +1,5 @@
>  /*
> - * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
> + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
>   *
>   * Licensed under the Apache License, Version 2.0 (the "License");
>   * you may not use this file except in compliance with the License.
> @@ -328,7 +328,7 @@ time_alarm(unsigned int secs)
>      time_refresh();
>
>      now = time_msec();
> -    msecs = secs * 1000;
> +    msecs = secs * 1000LL;
>
>      block_sigalrm(&oldsigs);
>      deadline = now < LLONG_MAX - msecs ? now + msecs : LLONG_MAX;
> --
> 1.7.2.5
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev



More information about the dev mailing list