This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Make fmtmsg() function to multithread-safe
- From: Peng Haitao <penght at cn dot fujitsu dot com>
- To: Tolga Dalman <tolga dot dalman at googlemail dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Wed, 22 Feb 2012 09:55:26 +0800
- Subject: Re: [PATCH] Make fmtmsg() function to multithread-safe
- References: <4F43618A.8030009@cn.fujitsu.com> <4F437263.3070601@googlemail.com>
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