lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LNX.2.21.1810161014080.10@nippy.intranet>
Date:   Tue, 16 Oct 2018 10:52:26 +1100 (AEDT)
From:   Finn Thain <fthain@...egraphics.com.au>
To:     Hannes Reinecke <hare@...e.de>
cc:     "James E.J. Bottomley" <jejb@...ux.vnet.ibm.com>,
        "Martin K. Petersen" <martin.petersen@...cle.com>,
        Michael Schmitz <schmitzmic@...il.com>,
        linux-scsi@...r.kernel.org, linux-m68k@...ts.linux-m68k.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 5/6] esp_scsi: De-duplicate PIO routines

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
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ