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

Daniel Lezcano
2023-12-27T15:40:37Z

On 27/12/2023 16:31, Stanislaw Gruszka wrote:
> 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.

The caller will have to handle the specific case if there is no
listeners. There is an error if the message can not be sent but here
there is no error related to that, just we don't send it. So having an
error when there is nothing to do is not really an error.

--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |