Hi Ayman,

On 10/15/19 14:08, [email protected] wrote:

>>      /* Huawei laptops come with one battery only */
>> -    if (strcmp(battery->desc->name, "BAT") != 1)
> 
> Note we don't have a battery number in BATx, strcmp would return 1 if
> battery->desc->name is "BAT0" or any one digit. This is a desired
> behavior where some Huawei laptops identify the first battery as "BAT1"
> and this would match if name is greater than "BAT" by one digit.
> 

Great to know this is not a bug. I don't think there is any
other instance in the whole codebase like this one: strcmp(...) != 1
So, that's an odd thing to see...  Maybe you can consider adding
the whole description above as a code comment? :)

> Maybe strcmp(battery->desc->name, "BAT") < 0 is a better way to go.
> 

Yeah; this is bit more specific.

Thanks!
--
Gustavo

Reply via email to