Re: [PATCH 06/24] perf daemon: Add config file support
From: Jiri Olsa
Date: Sat Feb 06 2021 - 15:27:35 EST
On Thu, Feb 04, 2021 at 04:08:50PM +0100, Jiri Olsa wrote:
SNIP
> > > +
> > > +static void session__free(struct session *session)
> > > +{
> > > + free(session->base);
> > > + free(session->name);
> > > + free(session->run);
> >
> > zfree() so that if there is some dangling pointer to session, we'll get
> > NULL derefs
>
> and won't be notified by crash about the error ;-) ok
oops, actualy it makes no sense to do it here, because we're
freeing session just in the next line
>
> >
> > > + free(session);
> > > +}
> > > +
> > > +static void session__remove(struct session *session)
> > > +{
> > > + list_del(&session->list);
> >
> > list_del_init
same here
> >
> > > + session__free(session);
> > > +}
> > > +
> > > +static void daemon__kill(struct daemon *daemon)
> > > +{
> > > + daemon__signal(daemon, SIGTERM);
> > > +}
> > > +
> > > static void daemon__free(struct daemon *daemon)
> > > {
> > > + struct session *session, *h;
> > > +
> > > + list_for_each_entry_safe(session, h, &daemon->sessions, list)
> > > + session__remove(session);
> >
> > Wouldn't be better to have:
> >
> > list_for_each_entry_safe(session, h, &daemon->sessions, list) {
> > list_del_init(&session->list);
> > session__free(session);
> > }
> >
> > Because naming that function "session__remove()" one thinks it is being
> > removed from some data structure, but not that it is being as well
> > deleted.
session__remove is being called also from daemon__reconfig,
so it's there not to repeat the code, I'm ok to rename it
thanks,
jirka