[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-sparse
Subject:    Re: [PATCH] evaluate: reject post-ops on void*
From:       Christopher Li <sparse () chrisli ! org>
Date:       2012-01-27 11:42:56
Message-ID: CANeU7Qnrjf9xAerY3azSUfSg1QBwrLSSVgXQLm_WVad5qnatnQ () mail ! gmail ! com
[Download RAW message or body]

Sorry for the late reply.

On Sun, Jan 22, 2012 at 3:31 PM, Jan Pokorný <pokorny_jan@seznam.cz> wrote:
> Following example haven't been linearized correctly:
>
>        static void *inc_ptr(void *a) {
>                return ++a;
>        }
>
> test-linearize:
>
>        <entry-point>
>        add.32      %r2 <- %arg1, $-1
>        ret.32      %r2

Yes, you discover a bug in the area we did not treat
type size consistently.

> --- a/evaluate.c
> +++ b/evaluate.c
> @@ -1711,7 +1711,8 @@ static struct symbol *evaluate_postop(struct expression *expr)
>                multiply = 1;
>        } else if (class == TYPE_PTR) {
>                struct symbol *target = examine_pointer_target(ctype);
> -               if (!is_function(target))
> +               /* beside function, reject also void* (due to sizeof(void)) */
> +               if (target != &void_ctype && !is_function(target))
>                        multiply = bits_to_bytes(target->bit_size);
>        }

Good catch, but it does not cover all the special case yet.
If you look at evaluate_sizeof(), there are 3 different types need special
handling: void, bool, function.

Same thing should be apply to implicit sizeof operations. They should
share some code rather than enumerate the special case in two different
places. Let me think about it more.

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

Configure | About | News | Add a list | Sponsored by KoreLogic