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=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 CA6EBC4338F for ; Thu, 19 Aug 2021 15:06:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B322660EFE for ; Thu, 19 Aug 2021 15:06:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239300AbhHSPHJ (ORCPT ); Thu, 19 Aug 2021 11:07:09 -0400 Received: from netrider.rowland.org ([192.131.102.5]:48383 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S238292AbhHSPHI (ORCPT ); Thu, 19 Aug 2021 11:07:08 -0400 Received: (qmail 229339 invoked by uid 1000); 19 Aug 2021 11:06:30 -0400 Date: Thu, 19 Aug 2021 11:06:30 -0400 From: Alan Stern To: Greg Kroah-Hartman Cc: Rui Miguel Silva , kernel test robot , clang-built-linux@googlegroups.com, kbuild-all@lists.01.org, linux-usb@vger.kernel.org Subject: Re: [usb:usb-testing 54/97] drivers/usb/isp1760/isp1760-hcd.c:735:2: warning: Value stored to 'scratch' is never read [clang-analyzer-deadcode.DeadStores] Message-ID: <20210819150630.GB228422@rowland.harvard.edu> References: <202108190619.wLK5u4fO-lkp@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On Thu, Aug 19, 2021 at 04:59:04PM +0200, Greg Kroah-Hartman wrote: > On Thu, Aug 19, 2021 at 08:47:37AM +0100, Rui Miguel Silva wrote: > > Hi, > > On Wed Aug 18, 2021 at 11:09 PM WEST, kernel test robot wrote: > > > drivers/usb/isp1760/isp1760-core.c:490:2: warning: Value stored to 'udc_enabled' is never read [clang-analyzer-deadcode.DeadStores] > > > udc_enabled = ((devflags & ISP1760_FLAG_ISP1763) || > > > ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > drivers/usb/isp1760/isp1760-core.c:490:2: note: Value stored to 'udc_enabled' is never read > > > udc_enabled = ((devflags & ISP1760_FLAG_ISP1763) || > > > ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > Suppressed 4 warnings (4 in non-user code). > > > Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. > > > 4 warnings generated. > > > Suppressed 4 warnings (4 in non-user code). > > > Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. > > > 9 warnings generated. > > > >> drivers/usb/isp1760/isp1760-hcd.c:735:2: warning: Value stored to 'scratch' is never read [clang-analyzer-deadcode.DeadStores] > > > scratch = isp1760_hcd_read(hcd, HC_CHIP_ID_HIGH); > > > ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > yeah, this is desired behaviour, this read is only to make sure that > > we make something different than the pattern to test go over the bus. > > However I will take a look to this warning and other clang warnings > > that I am seeing in this report. > > This is why I hate this type of warning, doing a read like this is > totally normal for drivers. Compilers that think this is something they > can ignore or warn about are just wrong. No, no. The compiler isn't complaining about the call to isp1760_hcd_read(); it's complaining about the fact that scratch stores the return value. Since the value isn't used anywhere, there's no point in storing it. You can get rid of the warning by changing the line to: (void) isp1760_hcd_read(hcd, HC_CHIP_ID_HIGH); (The (void) cast isn't really necessary; it's just there to point out that the return value is being thrown away. You can omit it if you prefer.) Likewise for the store to udc_enabled. Alan Stern