From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: ayman.bagabas@gmail.com, Darren Hart <dvhart@infradead.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform/x86: huawei-wmi: Fix misuse of strcmp() function
Date: Tue, 15 Oct 2019 14:26:47 -0500 [thread overview]
Message-ID: <d5f4164f-7cee-3fdb-49ce-4e1d1d70572a@embeddedor.com> (raw)
In-Reply-To: <336c7fa6eebdbada759c9ad30a0a6b85af6f6c58.camel@gmail.com>
Hi Ayman,
On 10/15/19 14:08, ayman.bagabas@gmail.com 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
prev parent reply other threads:[~2019-10-15 19:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-15 18:25 Gustavo A. R. Silva
2019-10-15 19:08 ` ayman.bagabas
2019-10-15 19:26 ` Gustavo A. R. Silva [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d5f4164f-7cee-3fdb-49ce-4e1d1d70572a@embeddedor.com \
--to=gustavo@embeddedor.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=ayman.bagabas@gmail.com \
--cc=dvhart@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®