On Fri, 17 Aug 2012 15:34:04 +0200
Stefan Weil <s...@weilnetz.de> wrote:

> ccc-analyzer reports these warnings:
> 
> monitor.c:3532:21: warning: Division by zero
>                 val %= val2;
>                     ^
> monitor.c:3530:21: warning: Division by zero
>                 val /= val2;
>                     ^
> 
> Rewriting the code fixes this (and also a style issue).
> 
> Signed-off-by: Stefan Weil <s...@weilnetz.de>

Reviewed-by: Luiz Capitulino <lcapitul...@redhat.com>

Although I wonder how far we're going "fixing" clang warnings/false positives...

> ---
>  monitor.c |    7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/monitor.c b/monitor.c
> index 0c34934..0ea2c14 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -3524,12 +3524,13 @@ static int64_t expr_prod(Monitor *mon)
>              break;
>          case '/':
>          case '%':
> -            if (val2 == 0)
> +            if (val2 == 0) {
>                  expr_error(mon, "division by zero");
> -            if (op == '/')
> +            } else if (op == '/') {
>                  val /= val2;
> -            else
> +            } else {
>                  val %= val2;
> +            }
>              break;
>          }
>      }


Reply via email to