[Mesa-dev] [PATCH v2 1/2] mesa/fbo: do not assign a value that is never read later on

Martin Peres martin.peres at linux.intel.com
Tue Mar 31 07:39:21 PDT 2015


On 31/03/15 17:31, Brian Paul wrote:
> On 03/31/2015 03:32 AM, Martin Peres wrote:
>> The issue has been detected by coverty.
>>
>> v2:
>> - move the declaration of obj to the else clause (Brian Paul)
>>
>> Signed-off-by: Martin Peres <martin.peres at linux.intel.com>
>> ---
>>   src/mesa/main/fbobject.c | 5 ++---
>>   1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
>> index 072e1a8..f2ae9b7 100644
>> --- a/src/mesa/main/fbobject.c
>> +++ b/src/mesa/main/fbobject.c
>> @@ -1400,7 +1400,6 @@ create_render_buffers(struct gl_context *ctx, 
>> GLsizei n, GLuint *renderbuffers,
>>                         bool dsa)
>>   {
>>      const char *func = dsa ? "glCreateRenderbuffers" : 
>> "glGenRenderbuffers";
>> -   struct gl_renderbuffer *obj;
>>      GLuint first;
>>      GLint i;
>>
>> @@ -1419,9 +1418,9 @@ create_render_buffers(struct gl_context *ctx, 
>> GLsizei n, GLuint *renderbuffers,
>>         renderbuffers[i] = name;
>>
>>         if (dsa) {
>> -         obj = allocate_renderbuffer(ctx, name, func);
>> +         allocate_renderbuffer(ctx, name, func);
>>         } else {
>> -         obj = &DummyRenderbuffer;
>> +         struct gl_renderbuffer *obj = &DummyRenderbuffer;
>>
>>            /* insert the object into the hash table */
>>            mtx_lock(&ctx->Shared->Mutex);
>>
>
> Actually, you don't need to declare an obj var at all, just do:
>
>   _mesa_HashInsert(ctx->Shared->RenderBuffers, name, &DummyRenderbuffer);

This would make waaaayyyy too much sense! More seriously, I thought it 
would exceed the 80-char limit but it just reaches it without crossing.

Thanks for being better at eye-balling this. I will send a v3 right away.


More information about the mesa-dev mailing list