[PATCH] Make fmtmsg() function to multithread-safe
Peng Haitao
penght@cn.fujitsu.com
Wed Feb 22 01:55:00 GMT 2012
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
More information about the Libc-alpha
mailing list