Re: [PATCH 2/2] thermal: netlink: Add thermal_group_has_listeners() helper

Stanislaw Gruszka
2023-12-27T15:31:39Z

Hi Daniel,

On Wed, Dec 27, 2023 at 03:11:03PM +0100, Daniel Lezcano wrote:
> > +static int thermal_group_has_listeners(enum thermal_genl_multicast_groups group)
> > +{
> > + return genl_has_listeners(&thermal_gnl_family, &init_net, group);
> > +}
> > +
> > /************************** Sampling encoding *******************************/
> >
> > int thermal_genl_sampling_temp(int id, int temp)
> > @@ -83,6 +88,9 @@ int thermal_genl_sampling_temp(int id, int temp)
> > struct sk_buff *skb;
> > void *hdr;
> >
> > + if (!thermal_group_has_listeners(THERMAL_GENL_SAMPLING_GROUP))
> > + return -ESRCH;
> > +
>
> Do really want to return an error ? Shall we just bail out instead ?

I decided for error because thermal_notify_* are int functions and we
return error code for some other cases when the messages can not be
sent (i.e. alloc error).
Event if currently return value is ignored by all callers (FWICT),
error information could be used theoretically.

If returning 0 is preferable/better, I can change that.

Regards
Stanislaw