mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Benson Leung <bleung@chromium.org>
Cc: gregkh@linuxfoundation.org, abhishekpandit@chromium.org,
	dan.carpenter@linaro.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, akuchynski@google.com,
	ukaszb@chromium.org
Subject: Re: [PATCH 1/2] usb: typec: thunderbolt: Fix loops that iterate TYPEC_PLUG_SOP_P and TYPEC_PLUG_SOP_PP
Date: Tue, 28 Jan 2025 10:17:27 +0200	[thread overview]
Message-ID: <Z5iSl7Nj5Nzpj4rV@kuha.fi.intel.com> (raw)
In-Reply-To: <Z5Psp615abaaId6J@google.com>

On Fri, Jan 24, 2025 at 07:40:23PM +0000, Benson Leung wrote:
> Fixes these Smatch static checker warnings:
> drivers/usb/typec/altmodes/thunderbolt.c:116 tbt_altmode_work() warn: why is zero skipped 'i'
> drivers/usb/typec/altmodes/thunderbolt.c:147 tbt_enter_modes_ordered() warn: why is zero skipped 'i'
> drivers/usb/typec/altmodes/thunderbolt.c:328 tbt_altmode_remove() warn: why is zero skipped 'i'
> 
> Fixes: 100e25738659 ("usb: typec: Add driver for Thunderbolt 3 Alternate Mode")
> 
> Signed-off-by: Benson Leung <bleung@chromium.org>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/altmodes/thunderbolt.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/typec/altmodes/thunderbolt.c b/drivers/usb/typec/altmodes/thunderbolt.c
> index 1b475b1d98e7..94e47d30e598 100644
> --- a/drivers/usb/typec/altmodes/thunderbolt.c
> +++ b/drivers/usb/typec/altmodes/thunderbolt.c
> @@ -112,7 +112,7 @@ static void tbt_altmode_work(struct work_struct *work)
>  	return;
>  
>  disable_plugs:
> -	for (int i = TYPEC_PLUG_SOP_PP; i > 0; --i) {
> +	for (int i = TYPEC_PLUG_SOP_PP; i >= 0; --i) {
>  		if (tbt->plug[i])
>  			typec_altmode_put_plug(tbt->plug[i]);
>  
> @@ -143,7 +143,7 @@ static int tbt_enter_modes_ordered(struct typec_altmode *alt)
>  	if (tbt->plug[TYPEC_PLUG_SOP_P]) {
>  		ret = typec_cable_altmode_enter(alt, TYPEC_PLUG_SOP_P, NULL);
>  		if (ret < 0) {
> -			for (int i = TYPEC_PLUG_SOP_PP; i > 0; --i) {
> +			for (int i = TYPEC_PLUG_SOP_PP; i >= 0; --i) {
>  				if (tbt->plug[i])
>  					typec_altmode_put_plug(tbt->plug[i]);
>  
> @@ -324,7 +324,7 @@ static void tbt_altmode_remove(struct typec_altmode *alt)
>  {
>  	struct tbt_altmode *tbt = typec_altmode_get_drvdata(alt);
>  
> -	for (int i = TYPEC_PLUG_SOP_PP; i > 0; --i) {
> +	for (int i = TYPEC_PLUG_SOP_PP; i >= 0; --i) {
>  		if (tbt->plug[i])
>  			typec_altmode_put_plug(tbt->plug[i]);
>  	}
> -- 
> 2.48.1.262.g85cc9f2d1e-goog

-- 
heikki

  reply	other threads:[~2025-01-28  8:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-24 19:40 Benson Leung
2025-01-28  8:17 ` Heikki Krogerus [this message]
2025-02-03 15:18 ` Greg KH
2025-02-03 16:53   ` Benson Leung

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=Z5iSl7Nj5Nzpj4rV@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=abhishekpandit@chromium.org \
    --cc=akuchynski@google.com \
    --cc=bleung@chromium.org \
    --cc=dan.carpenter@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=ukaszb@chromium.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®