[PATCH] Remove more superfluous if(p) checks around free(p)

Matt Turner mattst88 at gmail.com
Wed Jun 9 09:51:39 PDT 2010


On Wed, Jun 9, 2010 at 12:46 PM, Alan Coopersmith
<alan.coopersmith at oracle.com> wrote:
> Matt Turner wrote:
>> --- a/xkb/ddxList.c
>> +++ b/xkb/ddxList.c
>> @@ -208,10 +208,8 @@ char     tmpname[PATH_MAX];
>>       return BadImplementation;
>>      }
>>      list->nFound[what]= 0;
>> -    if (buf) {
>> -        free(buf);
>> -        buf = NULL;
>> -    }
>> +    free(buf);
>> +    buf = NULL;
>>      buf = malloc(PATH_MAX * sizeof(char));
>>      if (!buf)
>>          return BadAlloc;
>
> While you didn't introduce it, you could get rid of the buf = NULL setting,
> though presumably the compiler optimizes it away when it sees buf overwritten
> on the next line without ever referencing the NULL pointer.
>
> Even with that tiny nit,
> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>
>
> --
>        -Alan Coopersmith-        alan.coopersmith at oracle.com
>         Oracle Solaris Platform Engineering: X Window System

Good catch. I'll resent to Keith with the Reviewed-by tags and this change.

Thanks for the reviews,
Matt


More information about the xorg-devel mailing list