All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Damien Le Moal <damien.lemoal@opensource.wdc.com>,
	linux-ide@vger.kernel.org
Subject: Re: [PATCH v2 22/22] ata: ahci_xgene: Fix id array access in xgene_ahci_read_id()
Date: Tue, 4 Jan 2022 12:51:09 +0100	[thread overview]
Message-ID: <88f71464-135d-7cae-287d-8961eff37333@suse.de> (raw)
In-Reply-To: <20220104105843.1730172-23-damien.lemoal@opensource.wdc.com>

On 1/4/22 11:58 AM, Damien Le Moal wrote:
> ATA IDENTIFY command returns an array of le16 words. Accessing it as a
> u16 array triggers the following sparse warning:
> 
> drivers/ata/ahci_xgene.c:262:33: warning: invalid assignment: &=
> drivers/ata/ahci_xgene.c:262:33:    left side has type unsigned short
> drivers/ata/ahci_xgene.c:262:33:    right side has type restricted __le16
> 
> Use a local variable to explicitly cast the id array to __le16 to avoid
> this warning.
> 
> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
> ---
>  drivers/ata/ahci_xgene.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/ata/ahci_xgene.c b/drivers/ata/ahci_xgene.c
> index 68ec7e9430b2..d5075d0f8cb1 100644
> --- a/drivers/ata/ahci_xgene.c
> +++ b/drivers/ata/ahci_xgene.c
> @@ -239,6 +239,7 @@ static bool xgene_ahci_is_memram_inited(struct xgene_ahci_context *ctx)
>  static unsigned int xgene_ahci_read_id(struct ata_device *dev,
>  				       struct ata_taskfile *tf, u16 *id)
>  {
> +	__le16 *__id = (__le16 *)id;
>  	u32 err_mask;
>  
>  	err_mask = ata_do_dev_read_id(dev, tf, id);
> @@ -259,7 +260,7 @@ static unsigned int xgene_ahci_read_id(struct ata_device *dev,
>  	 *
>  	 * Clear reserved bit 8 (DEVSLP bit) as we don't support DEVSLP
>  	 */
> -	id[ATA_ID_FEATURE_SUPP] &= cpu_to_le16(~(1 << 8));
> +	__id[ATA_ID_FEATURE_SUPP] &= cpu_to_le16(~(1 << 8));
>  
>  	return 0;
>  }
> 
Hmm. I would think that the 'id' argument is wrong; it really should be
'__le16 *', as it only gets converted later on with the call to
swap_buf_le16(id, ATA_ID_WORDS) in
drivers/ata/libata-core.c:ata_dev_read_id(). So when this function is
called the argument really _is_ __le16, only the declaration doesn't
tell us.

Maybe one should rather fix this?

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

  reply	other threads:[~2022-01-04 11:51 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-04 10:58 [PATCH v2 00/22] Improve compile test coverage Damien Le Moal
2022-01-04 10:58 ` [PATCH v2 01/22] ata: sata_fsl: add compile test support Damien Le Moal
2022-01-04 11:28   ` Hannes Reinecke
2022-01-04 10:58 ` [PATCH v2 02/22] ata: ahci_brcm: " Damien Le Moal
2022-01-04 11:28   ` Hannes Reinecke
2022-01-04 10:58 ` [PATCH v2 03/22] ata: ahci_da850: " Damien Le Moal
2022-01-04 11:29   ` Hannes Reinecke
2022-01-04 10:58 ` [PATCH v2 04/22] ata: ahci_dm816: " Damien Le Moal
2022-01-04 11:29   ` Hannes Reinecke
2022-01-04 10:58 ` [PATCH v2 05/22] ata: ahci_st: " Damien Le Moal
2022-01-04 11:29   ` Hannes Reinecke
2022-01-04 10:58 ` [PATCH v2 06/22] ata: ahci_mtk: " Damien Le Moal
2022-01-04 11:30   ` Hannes Reinecke
2022-01-04 10:58 ` [PATCH v2 07/22] ata: ahci_mvebu: " Damien Le Moal
2022-01-04 11:30   ` Hannes Reinecke
2022-01-04 10:58 ` [PATCH v2 08/22] ata: ahci_sunxi: " Damien Le Moal
2022-01-04 11:30   ` Hannes Reinecke
2022-01-04 10:58 ` [PATCH v2 09/22] ata: ahci_tegra: " Damien Le Moal
2022-01-04 11:31   ` Hannes Reinecke
2022-01-04 10:58 ` [PATCH v2 10/22] ata: ahci_xgene: " Damien Le Moal
2022-01-04 11:31   ` Hannes Reinecke
2022-01-04 10:58 ` [PATCH v2 11/22] ata: ahci_seattle: " Damien Le Moal
2022-01-04 11:31   ` Hannes Reinecke
2022-01-04 10:58 ` [PATCH v2 12/22] ata: pata_bk3710: " Damien Le Moal
2022-01-04 11:31   ` Hannes Reinecke
2022-01-04 10:58 ` [PATCH v2 13/22] ata: pata_cs5535: " Damien Le Moal
2022-01-04 11:35   ` Hannes Reinecke
2022-01-06  4:50     ` Damien Le Moal
2022-01-05 22:57   ` kernel test robot
2022-01-04 10:58 ` [PATCH v2 14/22] ata: pata_ftide010: " Damien Le Moal
2022-01-04 11:35   ` Hannes Reinecke
2022-01-04 10:58 ` [PATCH v2 15/22] ata: pata_imx: " Damien Le Moal
2022-01-04 11:35   ` Hannes Reinecke
2022-01-04 10:58 ` [PATCH v2 16/22] ata: pata_pxa: " Damien Le Moal
2022-01-04 11:36   ` Hannes Reinecke
2022-01-04 10:58 ` [PATCH v2 17/22] ata: pata_legacy: " Damien Le Moal
2022-01-04 11:39   ` Hannes Reinecke
2022-01-04 10:58 ` [PATCH v2 18/22] ata: pata_samsung_cf: " Damien Le Moal
2022-01-04 11:40   ` Hannes Reinecke
2022-01-04 10:58 ` [PATCH v2 19/22] ata: sata_fsl: fix scsi host initialization Damien Le Moal
2022-01-04 11:41   ` Hannes Reinecke
2022-01-04 10:58 ` [PATCH v2 20/22] ata: sata_fsl: fix cmdhdr_tbl_entry and prde struct definitions Damien Le Moal
2022-01-04 11:45   ` Hannes Reinecke
2022-01-05  3:39     ` Damien Le Moal
2022-01-04 10:58 ` [PATCH v2 21/22] ata: ahci_xgene: use correct type for port mmio address Damien Le Moal
2022-01-04 11:46   ` Hannes Reinecke
2022-01-04 10:58 ` [PATCH v2 22/22] ata: ahci_xgene: Fix id array access in xgene_ahci_read_id() Damien Le Moal
2022-01-04 11:51   ` Hannes Reinecke [this message]
2022-01-05  3:40     ` Damien Le Moal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=88f71464-135d-7cae-287d-8961eff37333@suse.de \
    --to=hare@suse.de \
    --cc=damien.lemoal@opensource.wdc.com \
    --cc=linux-ide@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.