From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3195C433EF for ; Fri, 22 Apr 2022 06:44:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444350AbiDVGrg (ORCPT ); Fri, 22 Apr 2022 02:47:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444491AbiDVGr0 (ORCPT ); Fri, 22 Apr 2022 02:47:26 -0400 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C58D50E00 for ; Thu, 21 Apr 2022 23:44:32 -0700 (PDT) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4Kl4dS58mlz4xXS; Fri, 22 Apr 2022 16:44:27 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1650609870; bh=3eLXiyOB458HngAaYCOTJBZShTmHk/qj59dCQWCz0co=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=SkGfNV8iJBliQixYncwq5FfV8UADKFcsOJ7PQevePJQYT02V+r2jXHxXYL6plpI8G BfPdaZF1IybxT9FNYpuUVE5gP903BbKuzA2EuW9j3f9iNP9x8/tFynZ8ekZGqQ23O/ zq6z994qcGsmjiXzBwmlOh3hASzITXdh+448B7sfuOJkH+07vjCisgsyuGWFtyXVSd G3YAH4xDlj6z+6rPo9DEJLYNyhQH4Yvf8eji5ra0Ugve15ehyQT2PYXcIQrK3ZHjS8 b7ElbR6vrpVHIGt6ZeKXtfIuc+OrUOmAohwSl5ygXCifaPCMzXrsHWjyCXPrpbsm8V PRm9B8SAHt7sA== From: Michael Ellerman To: Yihao Han , Benjamin Herrenschmidt , Ulf Hansson , Mark Brown , Srinivas Pandruvada , William Breathitt Gray , Sven Van Asbroeck , Corentin Labbe , Yihao Han , Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= , 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 In-Reply-To: <20220414140304.82751-1-hanyihao@vivo.com> References: <20220414140304.82751-1-hanyihao@vivo.com> Date: Fri, 22 Apr 2022 16:44:24 +1000 Message-ID: <87zgkd8vnb.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Yihao Han 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 > --- > 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