mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: "Peer Chen" <pchen@nvidia.com>, <linux-kernel@vger.kernel.org>,
	"Jeff Garzik" <jeff@garzik.org>,
	"Robert Hancock" <hancockr@shaw.ca>, "Kuan Luo" <kluo@nvidia.com>
Subject: Re: [PATCH] drivers/ata: Add the SW NCQ support to sata_nv for MCP51/MCP55/MCP61
Date: Thu, 17 May 2007 13:17:42 -0700	[thread overview]
Message-ID: <20070517131742.029e9fd0.akpm@linux-foundation.org> (raw)
In-Reply-To: <20070517131235.8f9445cc.akpm@linux-foundation.org>

On Thu, 17 May 2007 13:12:35 -0700
Andrew Morton <akpm@linux-foundation.org> wrote:

> The patch generates warnings:
> 
> drivers/ata/sata_nv.c:2118: warning: cast from pointer to integer of different size
> drivers/ata/sata_nv.c:2118: warning: cast to pointer from integer of different size
> 
> due to some quite suspicious-looknig code:
> 
>         prd = (struct ata_prd*)((u64)pp->prd + ATA_PRD_TBL_SZ*qc->tag);
> 
> we have
> 
> struct ata_prd {
> 	        u32                     addr;
> 	        u32                     flags_len;
> };
> 
> and the code is casting a pointer to this into a pointer to u64, then
> adding stuff to it, then casting it back to the correct type.
> 
> Can't we simply do this?
> 
> --- a/drivers/ata/sata_nv.c~drivers-ata-add-sw-ncq-support-to-sata_nv-for-mcp51-mcp55-mcp61-fix
> +++ a/drivers/ata/sata_nv.c
> @@ -2115,7 +2115,7 @@ static void nv_fill_sg(struct ata_queued
>  	WARN_ON(qc->__sg == NULL);
>  	WARN_ON(qc->n_elem == 0 && qc->pad_len == 0);
>  
> -	prd = (struct ata_prd*)((u64)pp->prd + ATA_PRD_TBL_SZ*qc->tag);
> +	prd = pp->prd + ATA_PRD_TBL_SZ*qc->tag;
>  
>  	idx = 0;
>  	ata_for_each_sg(sg, qc) {

hm, no.

ugh, I dunno what's going on here and I think I'd prefer not to.  Can't
we come up with some typesafe way of doing this without casting?

Meanwhile, I'll switch the cast from u64 to long.

  reply	other threads:[~2007-05-17 20:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-15  6:22 [PATCH] drivers/ata: correct a wrong free function for sata_nv driver Peer Chen
2007-05-16  5:21 ` Jeff Garzik
2007-05-16  5:31   ` Peer Chen
2007-05-17 11:13     ` [PATCH] sata_nv: fix fallout of devres conversion Tejun Heo
2007-05-18  0:58       ` Jeff Garzik
2007-05-17 10:15   ` [PATCH] drivers/ata: Add the SW NCQ support to sata_nv for MCP51/MCP55/MCP61 Peer Chen
2007-05-17 20:12     ` Andrew Morton
2007-05-17 20:17       ` Andrew Morton [this message]
2007-05-17 21:11         ` Jan Engelhardt
2007-05-18  1:47     ` Robert Hancock
2007-05-17 21:02 Zoltan Boszormenyi
     [not found] <fa.iernIz8Xcuvw0SBwi4A99Ju0g2o@ifi.uio.no>
2007-05-18  1:58 ` Robert Hancock
2007-05-18 12:34   ` Alan Cox
2007-05-18 14:34     ` Jeff Garzik
2007-05-18 15:12       ` Alan Cox
2007-05-20  8:34       ` Zoltan Boszormenyi
2007-05-18 11:10 Kuan Luo
     [not found] <fa.NGBsZzMiMJ9x7V/pv+sqAv36hwA@ifi.uio.no>
2007-05-18 23:31 ` Robert Hancock

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=20070517131742.029e9fd0.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=hancockr@shaw.ca \
    --cc=jeff@garzik.org \
    --cc=kluo@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pchen@nvidia.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome