[PATCH 1/2] oleaut32/tests: Don't take the size of a pointer (Clang).

Michael Stefaniuc mstefani at redhat.com
Tue Sep 18 05:01:09 CDT 2012


Hello Charles,

On 09/18/2012 07:51 AM, Charles Davis wrote:
> From: Charles Davis <cdavis at mymail.mines.edu>
> 
> Contrary to what a novice C programmer might expect, when you declare an
> array parameter to a function, what you actually get is a pointer.
> Therefore, using sizeof() on the parameter will return the size of a
> pointer, and not 8*sizeof(UINT) as was intended here. Since the array was
please fix it in a way to not confuse a novice C programmer;
e.g. passing it a pointer to a MYSTRUCT. That way you can avoid the
magic constant 8 too.

> explicitly declared as being 8 elements long, just use the number 8 in
> the for loop instead.

> ---
>  dlls/oleaut32/tests/tmarshal.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/dlls/oleaut32/tests/tmarshal.c b/dlls/oleaut32/tests/tmarshal.c
> index be8ef94..ad56123 100644
> --- a/dlls/oleaut32/tests/tmarshal.c
> +++ b/dlls/oleaut32/tests/tmarshal.c
> @@ -596,10 +596,10 @@ static HRESULT WINAPI Widget_VarArg(
>  }
>  
>  
> -static BOOL mystruct_uint_ordered(UINT uarr[8])
> +static BOOL mystruct_uint_ordered(UINT uarr[])
>  {
>      int i;
> -    for (i = 0; i < sizeof(uarr) / sizeof(uarr[0]); i++)
> +    for (i = 0; i < 8; i++)
>          if (uarr[i] != i)
>              return 0;
>  

thanks
bye
	michael



More information about the wine-devel mailing list