Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1171016

Re: [PATCHv2] mmc:Add pointer cast to uintptr_t for slave_id_rx and tx in the function, sh_mmcif_request_dma_one

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Joe Perches <joe@perches.com>
Newsgroups linux.kernel
Subject Re: [PATCHv2] mmc:Add pointer cast to uintptr_t for slave_id_rx and tx in the function, sh_mmcif_request_dma_one
Date Wed, 24 Jun 2015 02:50:01 +0200
Message-ID <pEH33-2kF-3@gated-at.bofh.it> (permalink)
References <pp65r-8nd-3@gated-at.bofh.it> <pEGgG-1bG-7@gated-at.bofh.it> <pEGqm-1C5-11@gated-at.bofh.it> <pEGJH-1Yh-11@gated-at.bofh.it> <pEGJH-1Yh-9@gated-at.bofh.it>
X-Original-To Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
X-Session-Marker 6A6F6540706572636865732E636F6D
X-Spam-Summary 30,2,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::,RULES_HIT:41:355:379:541:599:960:967:973:988:989:1260:1263:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2194:2198:2199:2200:2393:2525:2560:2563:2682:2685:2731:2828:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4321:5007:6261:7901:7903:8599:9025:9036:10010:10400:10471:10848:11026:11232:11473:11658:11914:12043:12050:12114:12438:12517:12519:12555:12663:12740:13069:13255:13311:13357:14096:14097:21060:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:1:0
X-He-Tag roof15_42709c599754f
X-Filterd-Recvd-Size 2965
Content-Type text/plain; charset="ISO-8859-1"
X-Mailer Evolution 3.12.11-0ubuntu3
MIME-Version 1.0
Content-Transfer-Encoding 7bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 49
Organization linux.* mail to news gateway
X-Original-Cc nick <xerofoify@gmail.com>, ulf.hansson@linaro.org, ben.dooks@codethink.co.uk, ykaneko0929@gmail.com, laurent.pinchart+renesas@ideasonboard.com, kouichi.tomita.yn@renesas.com, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org
X-Original-Date Tue, 23 Jun 2015 17:40:55 -0700
X-Original-Message-ID <1435106455.2504.35.camel@perches.com>
X-Original-References <1431366550-22045-1-git-send-email-xerofoify@gmail.com> <87r3p2rnek.wl%kuninori.morimoto.gx@renesas.com> <1435104444.2504.28.camel@perches.com> <5589F6D8.5090107@gmail.com> <87oak6rm5k.wl%kuninori.morimoto.gx@renesas.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref aioe.org linux.kernel:1171016

Show key headers only | View raw


On Wed, 2015-06-24 at 00:24 +0000, Kuninori Morimoto wrote:
> Hi Joe, Nick
> 
> > >>> This adds a cast to the variables,slave_id_rx and slave_id_rx
> > >>> to uintptr_t before casting to void* in order to avoid build
> > >>> warning on 64bit platforms for the function, sh_mmcif_request_dma_one.
> > > []
> > >>> diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
> > > []
> > >>> @@ -398,8 +398,8 @@ sh_mmcif_request_dma_one(struct sh_mmcif_host *host,
> > >>>  
> > >>>  	if (pdata)
> > >>>  		slave_data = direction == DMA_MEM_TO_DEV ?
> > >>> -			(void *)pdata->slave_id_tx :
> > >>> -			(void *)pdata->slave_id_rx;
> > >>> +			(void *)(uintptr_t)pdata->slave_id_tx :
> > >>> +			(void *)(uintptr_t)pdata->slave_id_rx;
> > > 
> > > It's far more common (~10:1) in the kernel to cast using
> > > 	(<type> *)(unsigned long)<foo>
> > > than
> > > 	(<type> *)(uintptr_t)<foo>
> > > 
> > Joe,
> > I agree it's more common in the kernel but one of the maintainers when I sent
> > this patch a month ago requested I use uintpr_t instead of unsigned long for
> > the casting. Otherwise I would have done the cast to fix the build warning
> > with unsigned long instead.
> 
> This mail
> http://thread.gmane.org/gmane.linux.kernel.mmc/32304

uintptr_t was introduced to avoid ptrdiff_t misuse in
commit 142956af5250 ("fix abuses of ptrdiff_t") by Al Viro.

unsigned long is preponderant, long is used about 1/4 as
often as unsigned long, uintptr_t is relatively uncommon.

If someone wants to go and convert the 800 or so casts to
long or unsigned long to uintptr_t so that's the style most
frequently used, that'd be different.  I'm not going to
submit any patches for that.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCHv2] mmc:Add pointer cast to uintptr_t for slave_id_rx and tx in the function, sh_mmcif_request_dma_one Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> - 2015-06-24 02:00 +0200
  Re: [PATCHv2] mmc:Add pointer cast to uintptr_t for slave_id_rx and  tx in the function, sh_mmcif_request_dma_one Joe Perches <joe@perches.com> - 2015-06-24 02:10 +0200
    Re: [PATCHv2] mmc:Add pointer cast to uintptr_t for slave_id_rx and tx in the function, sh_mmcif_request_dma_one Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> - 2015-06-24 02:30 +0200
      Re: [PATCHv2] mmc:Add pointer cast to uintptr_t for slave_id_rx and  tx in the function, sh_mmcif_request_dma_one Joe Perches <joe@perches.com> - 2015-06-24 02:50 +0200
        Re: [PATCHv2] mmc:Add pointer cast to uintptr_t for slave_id_rx and  tx in the function, sh_mmcif_request_dma_one Joe Perches <joe@perches.com> - 2015-06-24 03:00 +0200

csiph-web