Linux USB
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: [PATCH] usb: typec: silence a static checker warning
Date: Wed, 14 Apr 2021 10:44:40 +0300	[thread overview]
Message-ID: <YHadaACH8Mq/10F7@mwanda> (raw)

Smatch complains about a potential missing error code:

    drivers/usb/typec/port-mapper.c:168 typec_link_port()
    warn: missing error code 'ret'

This is a false positive and returning zero is intentional.  Let's
re-arrange the code to silence the warning and make the intent more
clear.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/usb/typec/port-mapper.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/typec/port-mapper.c b/drivers/usb/typec/port-mapper.c
index fae736eb0601..9b0991bdf391 100644
--- a/drivers/usb/typec/port-mapper.c
+++ b/drivers/usb/typec/port-mapper.c
@@ -157,15 +157,17 @@ int typec_link_port(struct device *port)
 {
 	struct device *connector;
 	struct port_node *node;
-	int ret = 0;
+	int ret;
 
 	node = create_port_node(port);
 	if (IS_ERR(node))
 		return PTR_ERR(node);
 
 	connector = find_connector(node);
-	if (!connector)
+	if (!connector) {
+		ret = 0;
 		goto remove_node;
+	}
 
 	ret = link_port(to_typec_port(connector), node);
 	if (ret)
-- 
2.30.2


             reply	other threads:[~2021-04-14  7:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-14  7:44 Dan Carpenter [this message]
2021-04-14  8:01 ` [PATCH] usb: typec: silence a static checker warning Heikki Krogerus

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=YHadaACH8Mq/10F7@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@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