From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: re: Extcon: support multiple states at a device.
Date: Fri, 22 May 2015 07:28:36 +0000 [thread overview]
Message-ID: <20150522072836.GA30507@mwanda> (raw)
Hello MyungJoo Ham,
The patch 7eaf7186842c: ('extcon: Use the unique id for external
connector instead of string') from Apr 24, 2015, leads to the following
static checker warning:
drivers/extcon/extcon.c:356 extcon_get_cable_state_()
warn: we tested 'index < 0' before and it was 'false'
drivers/extcon/extcon.c
343 /**
344 * extcon_get_cable_state_() - Get the status of a specific cable.
345 * @edev: the extcon device that has the cable.
346 * @id: the unique id of each external connector in extcon enumeration.
347 */
348 int extcon_get_cable_state_(struct extcon_dev *edev, const enum extcon id)
349 {
350 int index;
351
352 index = find_cable_index_by_id(edev, id);
353 if (index < 0)
^^^^^^^^^
Return error code here.
354 return index;
355
356 if (index < 0 || (edev->max_supported && edev->max_supported <= index))
^^^^^^^^^
No need to check here.
357 return -EINVAL;
358
359 return !!(edev->state & (1 << index));
360 }
But the other issue with this code is that the callers sometimes treat
errors as found, for example in extcon_get_cable_state().
regards,
dan carpenter
next reply other threads:[~2015-05-22 7:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-22 7:28 Dan Carpenter [this message]
2015-05-22 9:55 ` Extcon: support multiple states at a device Chanwoo Choi
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=20150522072836.GA30507@mwanda \
--to=dan.carpenter@oracle.com \
--cc=kernel-janitors@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.