Re: [RFC PATCH 1/2] Allow casting to a restricted type if !restricted_value

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

 



On Fri, Feb 17, 2017 at 03:11:15PM +0000, Edward Cree wrote:
> If the operand of a cast to a restricted type is an unrestricted value,
>  the cast should not produce a warning, since an equivalent implied cast
>  (e.g. in an initialiser) would not do so.
> 
> Signed-off-by: Edward Cree <ecree@xxxxxxxxxxxxxx>
> ---
>  evaluate.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/evaluate.c b/evaluate.c
> index e350c0c..8e855b1 100644
> --- a/evaluate.c
> +++ b/evaluate.c
> @@ -2771,7 +2771,7 @@ static struct symbol *evaluate_cast(struct expression *expr)
>                 t2 = unfoul(t2);
> 
>         if (t1 != t2) {
> -               if (class1 & TYPE_RESTRICT)
> +               if ((class1 & TYPE_RESTRICT) && restricted_value(target, t1))
>                         warning(expr->pos, "cast to %s",
>                                 show_typename(t1));
>                 if (class2 & TYPE_RESTRICT)

I'm fine with this.

Just the 't1' in restricted_value() that should probably be 't2'
(as can be seen on the warnings, just below t1 is the destination type
and t2 is the origin type) but since this argument is not used anyway
and the semantic of this not defined, it won't matter at all.
Maybe best to use NULL.

Also, I think it would be best to squash the two patches together.

(And I think you will need to resend it from another email address
because of the notice automatically added to your emails).

Luc
--
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