[Mesa-dev] [PATCH] i965: Initialize brw_blorp_const_color_program::prog_data.
Kenneth Graunke
kenneth at whitecape.org
Fri Jul 26 22:03:40 PDT 2013
On 07/26/2013 09:53 PM, Vinson Lee wrote:
> On Thu, Jul 25, 2013 at 11:19 PM, Kenneth Graunke <kenneth at whitecape.org> wrote:
>> On 07/25/2013 10:48 PM, Vinson Lee wrote:
>>>
>>> Fixes "Uninitialized scalar field" defect reported by Coverity.
>>>
>>> Signed-off-by: Vinson Lee <vlee at freedesktop.org>
>>> ---
>>> src/mesa/drivers/dri/i965/brw_blorp_clear.cpp | 3 ++-
>>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
>>> b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
>>> index f26f39d..5234208 100644
>>> --- a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
>>> +++ b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
>>> @@ -119,7 +119,8 @@ private:
>>> brw_blorp_const_color_program::brw_blorp_const_color_program(
>>> struct brw_context *brw,
>>> const brw_blorp_const_color_prog_key *key)
>>> - : mem_ctx(ralloc_context(NULL)),
>>> + : prog_data(),
>>> + mem_ctx(ralloc_context(NULL)),
>>> brw(brw),
>>> key(key),
>>> R0(),
>>>
>>
>> NAK. Since brw_blorp_prog_data doesn't define a constructor (see
>> brw_blorp.h:196), adding prog_data() is just a call to the C++ default/empty
>> constructor.
>>
>> So this patch doesn't actually initialize anything at all.
>
> struct brw_blorp_prog_data is a POD class with no constructor defined.
> 'prog_data()' should value-initialize and, in this case,
> zero-initialize all fields of prog_data.
You're right - I forgot that explicitly calling the constructor of a POD
type zero-initializes fields; it's only constructors for non-POD types
that are no-ops.
I still don't like this patch, though...it's really not obvious what's
going on.
--Ken
More information about the mesa-dev
mailing list