Re: [PATCH v2 1/2] take comma expr in account for constant value

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

 



On Fri, Aug 4, 2017 at 12:06 PM, Luc Van Oostenryck
<luc.vanoostenryck@xxxxxxxxx> wrote:
> It's often the case that we simply need the expr's truth value.
>
> To get the value of an expression or simply if we need to know
> if it's a constant value we can use some functions like
> get_expression_value() or const_expression_value() depending
> on the type of warning needed if the expression is not constant
> (for various definition of constant).
>
> However none of these functions take in account the fact that
> a comma expression can also have a value known at compile time.
>
> In order to not introduce unwanted change elsewheer in the code,
> introduce a new function expr_truth_value() which never warn
> but will return -1 if the expr have no known boolean value.
>
> Note: the whole set of functions should be unified to take comma
>       expressions in account when needed.
>
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
> ---
>  expand.c     | 30 ++++++++++++++++++++++++++++++
>  expression.h |  1 +
>  2 files changed, 31 insertions(+)
>
> diff --git a/expand.c b/expand.c
> index 5f908c971..f436b5b50 100644
> --- a/expand.c
> +++ b/expand.c
> @@ -1281,6 +1281,36 @@ long long get_expression_value_silent(struct expression *expr)
>         return __get_expression_value(expr, 2);
>  }
>
> +int expr_truth_value(struct expression *expr)

Looks fine to me.

One of the very minor note is that. I think this patch can actually merge with
the next one. It is easier to read patch have both the define and usage.
I found myself need to switch between patches to read how it was used.

The test case on the other hand can justify to become a standalone patch.
Some time we want see the how the code change (with or without patches)
impact the test case.

Another minor commend is that, if it is not for RC5.
You actually don't need to worry about code impact range
any more. You might just as well do the full change into the constant
expression value evaluation.

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