On Fri, 2015-05-08 at 14:30 +0800, Wanlong Gao wrote: > On 05/07/2015 09:21 PM, Cyril Hrubis wrote: > > Hi! > >> int getuserid(char *user) > >> { > >> - struct passwd *ent; > >> - > >> - /* allocate some space for the passwd struct */ > >> - if ((ent = malloc(sizeof(struct passwd))) == NULL) { > >> - tst_brkm(TBROK, cleanup, "couldn't allocate space for passwd" > >> - " structure"); > >> - } > >> + struct passwd *ent = NULL; > > > > Why do you initialize the pointer with NULL? If it's only used to store > > the return from getpwnam()... > > > > Otherwise, this is a good catch :) > > > > > Yeah, good catch, thank you. > > BTW, since it's a lib, we can't avoid using it in the pthread situation, > so, how about using thread-safe version getpwnam_r() instead? Thanks for your suggestion. Yes, I agree that getpwnam_r() is more better. I will update it.
Thanks, wei > > > Thanks, > Wanlong Gao > ------------------------------------------------------------------------------ One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list