Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4524247imm; Mon, 15 Oct 2018 16:53:24 -0700 (PDT) X-Google-Smtp-Source: ACcGV63vkf+24gBkFXtUMCI+0chian1Nyehjpwsr4ByS4Nch7vJGXvcQ59V58h3MiHVIEnVq4orr X-Received: by 2002:a63:1f64:: with SMTP id q36-v6mr17347090pgm.88.1539647604830; Mon, 15 Oct 2018 16:53:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539647604; cv=none; d=google.com; s=arc-20160816; b=hH79tM6BjX9DZ4J3+OkFmNuokfpN+OaK4wD3+6GkesjP4jGwQ0m7tuL6mB2rljBjfv Dxa1AeEjY9wLIIaFKh0aghUcCGioiLgZZjMx1EF8kVU0SBmjlGTr47CJgsu70yTCqJ51 Sg0c4JV/tz7e5tm+nLh6hsdQO/cQnGwpfVSyWwicAAAAEJXXacYLQHBV0xmjmY2Dcg7w 6ja5Igvr9QBEdJTiqsn7C7ydZe44Rl6ZsZ5auWQ9N4VAthTodcqbG2flWn1iV8bDLexr CkV0agEQpSCXi5qg+oP66G/mJN5HS7qVTmTFyOOvLohNOpPjlbHuLjGp3hKlqG//LZRf kqfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:message-id :in-reply-to:subject:cc:to:from:date; bh=1bVupSFTVMjgvKK7sQIYzwBg/uD8df3HI29jl0ZQ/x4=; b=oelFSZLnyPBVWpWOVcRQu7qug2jr8ifE8QQKBXfjvGljmM614+v9E3IH311WgHmkSA mV6fDGjdVo9oQNiLH/GhLtaHK1ouKCvMvznDhN3GTZwEi/tZI8T6JMV1KkeAIly9nI1w JGXgqCSvhZJHdS3uBJopYKY2kKv8IrHt4kyzs5KyRe7N7Dzgeq6I0UCUBvxDLSg6nUne mo+0fJB34YyAypkGUgNL0uwrIE+AMmlj+wOJx2XTd7Nj00RfUKQGtEBp5SsAMDTAkesl 34O4NpJF0lD11b+0MsCZljEmVktsYS95KhyMcPN/gVj7xp4LIAAc+De9YXs8XAQW4mdQ wLbQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u8-v6si12488736pfj.137.2018.10.15.16.53.05; Mon, 15 Oct 2018 16:53:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727006AbeJPHkC (ORCPT + 99 others); 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 >