Re: [PATCH] drivers/ata: Add the SW NCQ support to sata_nv for MCP51/MCP55/MCP61

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 17 May 2007 13:12:35 -0700
Andrew Morton <[email protected]> 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.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux