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 X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2017DC54FCB for ; Sun, 26 Apr 2020 20:37:39 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E658E206BF for ; Sun, 26 Apr 2020 20:37:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="AKtwZecd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E658E206BF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GyZI9wKOAiFK347H+Gu2/7GENphRlEi9+OwxDM/eAdU=; b=AKtwZecdDtFmuU l83axKmszg2QAOFuSePvfxmMLhTSnv0xQfuwkvyVWMSXSlafp+Z7yn+PMMAztG6LhvHn0QWXI9anF bChEP6h8MSrxrOEgspcT5driIBF+YZfJZHo+QJI8JapMUEk1qrAMdMkLehVi3eJentEbTIJTT1XHP AVLPDmWQFm8IeaCgrU3S6dd6YzhXonl0ZwG8yMcAGsK+/TOrCi2AV4o42vLip4x5qEA5gF0O8vLoU aAZwXsTKO7tYw5WxL/V9uXkN6QSSu/AlmZ33j5hJiDSN/ZYNdSQQnfQJiRLCz5AoifL0itBbHwVIO 2LZkKfWwm6XoQba7cRyA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jSo1x-0006bW-1b; Sun, 26 Apr 2020 20:37:37 +0000 Received: from smtprelay0028.hostedemail.com ([216.40.44.28] helo=smtprelay.hostedemail.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jSo1t-0006RN-0N for linux-arm-kernel@lists.infradead.org; Sun, 26 Apr 2020 20:37:34 +0000 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id 5FA14182CED34; Sun, 26 Apr 2020 20:37:27 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: bite55_40f3731081a4e X-Filterd-Recvd-Size: 2161 Received: from XPS-9350.home (unknown [47.151.136.130]) (Authenticated sender: joe@perches.com) by omf08.hostedemail.com (Postfix) with ESMTPA; Sun, 26 Apr 2020 20:37:26 +0000 (UTC) Message-ID: <0480c38b2e164ab0c25aae2db628c221ea0da111.camel@perches.com> Subject: Re: [PATCH 5/5] coresight: Avoid casting void pointers From: Joe Perches To: Stephen Boyd , Mathieu Poirier Date: Sun, 26 Apr 2020 13:37:25 -0700 In-Reply-To: <20200426185805.14923-6-swboyd@chromium.org> References: <20200426185805.14923-1-swboyd@chromium.org> <20200426185805.14923-6-swboyd@chromium.org> User-Agent: Evolution 3.36.1-2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200426_133733_111884_4DB91288 X-CRM114-Status: GOOD ( 11.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mike Leach , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Suzuki K Poulose Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sun, 2020-04-26 at 11:58 -0700, Stephen Boyd wrote: > We don't need to cast void pointers, such as the amba_id data. Assign to > a local variable to make the code prettier and also return NULL instead > of 0 to make sparse happy. [] > diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h [] > @@ -206,9 +206,12 @@ cti_remove_assoc_from_csdev(struct coresight_device *csdev) {} > /* extract the data value from a UCI structure given amba_id pointer. */ > static inline void *coresight_get_uci_data(const struct amba_id *id) > { > - if (id->data) > - return ((struct amba_cs_uci_id *)(id->data))->data; > - return 0; > + struct amba_cs_uci_id *uci_id = id->data; > + > + if (uci_id) > + return id->data; Missing one more level of indirection here yes? return uci_id->data; > + > + return NULL; > } And this code would generally be written to return the expected value at the bottom of the function and any unusual return early like: static inline void *coresight_get_uci_data(const struct amba_id *id) { struct amba_cs_uci_id *uci_id = id->data; if (!uci_id) return NULL; return uci_id->data; } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel