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=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=ham 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 6F7CBC04EB9 for ; Mon, 15 Oct 2018 23:52:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 26F672089D for ; Mon, 15 Oct 2018 23:52:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 26F672089D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=telegraphics.com.au Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727059AbeJPHkC (ORCPT ); Tue, 16 Oct 2018 03:40:02 -0400 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:54000 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726430AbeJPHkB (ORCPT ); Tue, 16 Oct 2018 03:40:01 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by kvm5.telegraphics.com.au (Postfix) with ESMTP id 10BED23F5C; Mon, 15 Oct 2018 19:52:25 -0400 (EDT) Date: Tue, 16 Oct 2018 10:52:26 +1100 (AEDT) From: Finn Thain To: Hannes Reinecke cc: "James E.J. Bottomley" , "Martin K. Petersen" , Michael Schmitz , linux-scsi@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 5/6] esp_scsi: De-duplicate PIO routines In-Reply-To: <2b48c925-73f0-0ca0-2f3c-3c35d90010ba@suse.de> Message-ID: References: <35ac9f31-7068-ab93-4629-363ee0bb4c70@suse.de> <2b48c925-73f0-0ca0-2f3c-3c35d90010ba@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 15 Oct 2018, Hannes Reinecke wrote: > > > > In the case of send_cmd_residual, that would mean a second #ifdef > > added to esp_data_bytes_sent() where it gets used. I'm happy to comply > > but I fear that all these #ifdefs may harm readability... > > > > There are already other variables in struct esp that may go unused, > > such as dma_regs, that don't have #ifdefs to elide them. Are these > > also problematic in some way? > > > The unused fields in the struct are not so much an issue; in fact, it > rather complicated things when having individual fields in the struct > surrounded by CONFIG_XXX, as then the order of the fields would change > depending on the configuration. Which makes it really hard to debug .. > True enough. We agree that this #ifdef is undesirable. And yet when I tried it, I found an unexpected readability benefit to your suggestion: #ifdef CONFIG_SCSI_ESP_PIO u8 __iomem *fifo_reg; int send_cmd_error; u32 send_cmd_residual; #endif This grouping does help convey the purpose of these struct members, even though the #ifdef is meant for the compiler not for the human reader. So maybe it makes sense to group these definitions (they are all the same size): /* These are used by esp_scsi_send_pio_cmd() */ u8 __iomem *fifo_reg; int send_cmd_error; u32 send_cmd_residual; > However, the function declaration really is a worry, as the actual > function body only exists when the config option is enabled. So either > add a dummy function or surround the function declaration by > CONFIG_ESP_PIO. > Otherwise I think Dan Carpenter and the likes are guaranteed to send you > a nice mail complaining about this ... > Do static checkers really complain about this? I think the validity of an extern can't be known until the final linkage is done. At that point the checker may complain that no compilation unit references a symbol in a header. But this would lead to false positives where a header file is shared by separate programs which share library code but not macros. -- > Cheers, > > Hannes >