Re: [PATCH 3/8] early return if null ctype in evaluate_conditional()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Feb 2, 2018 at 4:17 AM, Luc Van Oostenryck
<luc.vanoostenryck@xxxxxxxxx> wrote:
> NB: no functional changes here.
>
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
> ---
>  evaluate.c | 32 +++++++++++++++-----------------
>  1 file changed, 15 insertions(+), 17 deletions(-)
>
> diff --git a/evaluate.c b/evaluate.c
> index 027993983..1fc6111e4 100644
> --- a/evaluate.c
> +++ b/evaluate.c
> @@ -879,25 +879,23 @@ static struct symbol *evaluate_conditional(struct expression *expr, int iterator
>                 warning(expr->pos, "assignment expression in conditional");
>
>         ctype = evaluate_expression(expr);
> -       if (ctype) {
> -               if (is_safe_type(ctype))
> -                       warning(expr->pos, "testing a 'safe expression'");
> -               if (is_func_type(ctype)) {
> -                       if (Waddress)
> -                               warning(expr->pos, "the address of %s will always evaluate as true", "a function");
> -               } else if (is_array_type(ctype)) {
> -                       if (Waddress)
> -                               warning(expr->pos, "the address of %s will always evaluate as true", "an array");
> -               } else if (!is_scalar_type(ctype)) {
> -                       sparse_error(expr->pos, "incorrect type in conditional");
> -                       info(expr->pos, "   got %s", show_typename(ctype));
> -                       ctype = NULL;
> -               }
> +       if (!ctype)
> +               return NULL;
> +       if (is_safe_type(ctype))
> +               warning(expr->pos, "testing a 'safe expression'");
> +       if (is_func_type(ctype)) {
> +               if (Waddress)
> +                       warning(expr->pos, "the address of %s will always evaluate as true", "a function");
> +       } else if (is_array_type(ctype)) {
> +               if (Waddress)
> +                       warning(expr->pos, "the address of %s will always evaluate as true", "an array");
> +       } else if (!is_scalar_type(ctype)) {
> +               sparse_error(expr->pos, "incorrect type in conditional");
> +               info(expr->pos, "   got %s", show_typename(ctype));
> +               return NULL;

This is not straightly necessary to re-indent a section of the code.
It mess up the git annotation. For example, you can keep the "return NULL"
there and just move the

            ctype = degenerate(expr);

Inside if (ctype) statement block.

Any way, as you said, the function is the same.

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux