From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Darren Hart <dvhart@infradead.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Ayman Bagabas <ayman.bagabas@gmail.com>
Cc: platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org,
"Gustavo A. R. Silva" <gustavo@embeddedor.com>
Subject: [PATCH] platform/x86: huawei-wmi: Fix misuse of strcmp() function
Date: Tue, 15 Oct 2019 13:25:49 -0500 [thread overview]
Message-ID: <20191015182549.GA13772@embeddedor> (raw)
Comparing the result of strcmp directly with 1 may cause it to be
misinterpreted. Note that strcmp may return an integer besides -1,
0, or 1.
Fix this by returning -ENODEV only when strcmp() returns a value
other than 0.
Addresses-Coverity-ID: 1487035 ("Misuse of memcmp-style function")
Fixes: b7527d0f4502 ("platform/x86: huawei-wmi: Add battery charging thresholds")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
drivers/platform/x86/huawei-wmi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/platform/x86/huawei-wmi.c b/drivers/platform/x86/huawei-wmi.c
index 6720f78c60c2..b43f76acbfea 100644
--- a/drivers/platform/x86/huawei-wmi.c
+++ b/drivers/platform/x86/huawei-wmi.c
@@ -470,7 +470,7 @@ static DEVICE_ATTR_RW(charge_control_thresholds);
static int huawei_wmi_battery_add(struct power_supply *battery)
{
/* Huawei laptops come with one battery only */
- if (strcmp(battery->desc->name, "BAT") != 1)
+ if (strcmp(battery->desc->name, "BAT"))
return -ENODEV;
device_create_file(&battery->dev, &dev_attr_charge_control_start_threshold);
--
2.23.0
next reply other threads:[~2019-10-15 18:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-15 18:25 Gustavo A. R. Silva [this message]
2019-10-15 19:08 ` [PATCH] platform/x86: huawei-wmi: Fix misuse of strcmp() function ayman.bagabas
2019-10-15 19:26 ` Gustavo A. R. Silva
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=20191015182549.GA13772@embeddedor \
--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