This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Make fmtmsg() function to multithread-safe


Tolga Dalman said the following on 2012-2-21 18:30:
>> +  const char *pstring;
>>
>> /* Make sure everything is initialized.  */ __libc_once (once, 
>> init); @@ -124,11 +125,18 @@ fmtmsg (long int classification,
>> const
> char *label, int severity,
>> return MM_NOTOK; }
>>
>> +  __libc_lock_lock (lock); + for (severity_rec = severity_list; 
>> severity_rec != NULL; severity_rec = severity_rec->next) if 
>> (severity == severity_rec->severity) +    { +      pstring = 
>> severity_rec->string; /* Bingo.  */ break; +    }
> 
> This makes me a bit nervous. pstring is undefined if the inner
> condition never matches.
> 

If the inner condition never matches, severity_rec will be NULL,
fmtmsg() will return MM_NOTOK.

 134   if (severity_rec == NULL)
 135     return MM_NOTOK;

I will resend v2 with: const char *pstring = NULL;

Thanks for your comment.

-- 
Best Regards,
Peng


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]