public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman.id.au>
To: "Yihao Han" <hanyihao@vivo.com>,
	"Benjamin Herrenschmidt" <benh@kernel.crashing.org>,
	"Ulf Hansson" <ulf.hansson@linaro.org>,
	"Mark Brown" <broonie@kernel.org>,
	"Srinivas Pandruvada" <srinivas.pandruvada@linux.intel.com>,
	"William Breathitt Gray" <vilhelm.gray@gmail.com>,
	"Sven Van Asbroeck" <TheSven73@gmail.com>,
	"Corentin Labbe" <clabbe@baylibre.com>,
	"Yihao Han" <hanyihao@vivo.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Cc: kernel@vivo.com
Subject: Re: [PATCH] macintosh: macio_asic: fix resource_size.cocci warnings
Date: Fri, 22 Apr 2022 16:44:24 +1000	[thread overview]
Message-ID: <87zgkd8vnb.fsf@mpe.ellerman.id.au> (raw)
In-Reply-To: <20220414140304.82751-1-hanyihao@vivo.com>

Yihao Han <hanyihao@vivo.com> writes:
> drivers/macintosh/macio_asic.c:219:26-29: WARNING:
> Suspicious code. resource_size is maybe missing with res
> drivers/macintosh/macio_asic.c:221:26-29: WARNING:
> Suspicious code. resource_size is maybe missing with res
>
> Use resource_size function on resource object instead of
> explicit computation.
>
> Generated by: scripts/coccinelle/api/resource_size.cocci
>
> Signed-off-by: Yihao Han <hanyihao@vivo.com>
> ---
>  drivers/macintosh/macio_asic.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
> index 1943a007e2d5..260fccb3863e 100644
> --- a/drivers/macintosh/macio_asic.c
> +++ b/drivers/macintosh/macio_asic.c
> @@ -216,9 +216,9 @@ static int macio_resource_quirks(struct device_node *np, struct resource *res,
>  	/* Some older IDE resources have bogus sizes */
>  	if (of_node_name_eq(np, "IDE") || of_node_name_eq(np, "ATA") ||
>  	    of_node_is_type(np, "ide") || of_node_is_type(np, "ata")) {
> -		if (index == 0 && (res->end - res->start) > 0xfff)
> +		if (index == 0 && (resource_size(res)) > 0xfff)
>  			res->end = res->start + 0xfff;
> -		if (index == 1 && (res->end - res->start) > 0xff)
> +		if (index == 1 && (resource_size(res)) > 0xff)

Are you sure the conversion is correct? It's not exactly equivalent:

static inline resource_size_t resource_size(const struct resource *res)
{
	return res->end - res->start + 1;
}

cheers

  parent reply	other threads:[~2022-04-22  6:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-14 14:02 [PATCH] macintosh: macio_asic: fix resource_size.cocci warnings Yihao Han
2022-04-19  7:54 ` Uwe Kleine-König
2022-04-22  6:44 ` Michael Ellerman [this message]
2022-04-25 17:23   ` Uwe Kleine-König

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=87zgkd8vnb.fsf@mpe.ellerman.id.au \
    --to=mpe@ellerman.id.au \
    --cc=TheSven73@gmail.com \
    --cc=benh@kernel.crashing.org \
    --cc=broonie@kernel.org \
    --cc=clabbe@baylibre.com \
    --cc=hanyihao@vivo.com \
    --cc=kernel@vivo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=ulf.hansson@linaro.org \
    --cc=vilhelm.gray@gmail.com \
    /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