Re: [PATCH v5 2/4] tools/lib/thermal: Make more generic the command encoding function

Daniel Lezcano
2024-10-22T07:12:09Z

On 21/10/2024 21:49, Lukasz Luba wrote:
>
>
> On 10/14/24 10:43, Daniel Lezcano wrote:
>> The thermal netlink has been extended with more commands which require
>> an encoding with more information. The generic encoding function puts
>> the thermal zone id with the command name. It is the unique
>> parameters.
>>
>> The next changes will provide more parameters to the command. Set the
>> scene for those new parameters by making the encoding function more
>> generic.
>>
>> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
>> ---

[ ... ]

>> +static thermal_error_t thermal_genl_auto(struct thermal_handler *th,
>> cmd_cb_t cmd_cb,
>> +                     struct cmd_param *param,
>> +                     int cmd, int flags, void *arg)
>>   {
>>       struct nl_msg *msg;
>>       void *hdr;
>> @@ -276,7 +291,7 @@ static thermal_error_t thermal_genl_auto(struct
>> thermal_handler *th, int id, int
>>       if (!hdr)
>>           return THERMAL_ERROR;
>> -    if (id >= 0 && nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_ID, id))
>> +    if (cmd_cb && cmd_cb(msg, param))
>>           return THERMAL_ERROR;
>
> It's not in this code but also in older:
> shouldn't we free the nlmsg_free(msg); before returns in this
> function?

Right, thanks for pointing this out

If it is ok, I will send a patch on top of this series to fix the entire
function

--
<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 |