On Wed, Dec 17, 2014 at 11:20 AM, Ilia Mirkin <imir...@alum.mit.edu> wrote:
> On Wed, Dec 17, 2014 at 2:17 PM, Matt Turner <matts...@gmail.com> wrote:
>> On Tue, Dec 16, 2014 at 10:47 PM, Vinson Lee <v...@freedesktop.org> wrote:
>>> Fix Coverity "sizeof not portable" defect.
>>>
>>> Signed-off-by: Vinson Lee <v...@freedesktop.org>
>>> ---
>>>  tests/util/piglit-framework-cl-program.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/tests/util/piglit-framework-cl-program.c 
>>> b/tests/util/piglit-framework-cl-program.c
>>> index d335486..f94525b 100644
>>> --- a/tests/util/piglit-framework-cl-program.c
>>> +++ b/tests/util/piglit-framework-cl-program.c
>>> @@ -287,7 +287,7 @@ piglit_cl_program_test_run(const int argc,
>>>         } else if(config->program_binary_file != NULL) {
>>>                 unsigned int length;
>>>                 size_t* lengths = malloc(sizeof(size_t) * 
>>> env.context->num_devices);
>>> -               unsigned char** program_binaries = malloc(sizeof(unsigned 
>>> char**) * env.context->num_devices);
>>> +               unsigned char** program_binaries = malloc(sizeof(unsigned 
>>> char*) * env.context->num_devices);
>>
>> Someone explain this one to me?
>>
>> program_binaries is an unsigned char ** and that's what we're giving
>> to sizeof. What's wrong with sizeof(unsigned char **)?
>
> It's an array of (unsigned char *), not (unsigned char **). For
> example if it were a 1d array, you might have
>
> unsigned char *foo = malloc(sizeof(unsigned char) * num_elements)
>
> right? Of course it doesn't end up _actually_ mattering, since
> sizeof(char*) == sizeof(char**).
>
>   -ilia

Oh yes, of course. Thanks for doing my thinking for me. :)
_______________________________________________
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to