[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140221082021.GG22574@ulmo.nvidia.com>
Date: Fri, 21 Feb 2014 09:20:22 +0100
From: Thierry Reding <thierry.reding@...il.com>
To: Paul Bolle <pebolle@...cali.nl>
Cc: Ilia Mirkin <imirkin@...m.mit.edu>,
Alex Deucher <alexander.deucher@....com>,
Christian König <christian.koenig@....com>,
"dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] drm/radeon: silence GCC warning on 32 bit
On Thu, Feb 20, 2014 at 10:24:53PM +0100, Paul Bolle wrote:
> On Thu, 2014-02-20 at 16:07 -0500, Ilia Mirkin wrote:
> > On Thu, Feb 20, 2014 at 4:02 PM, Paul Bolle <pebolle@...cali.nl> wrote:
> > > @@ -935,7 +935,7 @@ static ssize_t radeon_ttm_gtt_read(struct file *f, char __user *buf,
> > > while (size) {
> > > loff_t p = *pos / PAGE_SIZE;
> > > unsigned off = *pos & ~PAGE_MASK;
> > > - ssize_t cur_size = min(size, PAGE_SIZE - off);
> > > + ssize_t cur_size = min(size, (size_t)(PAGE_SIZE - off));
> >
> > Isn't the usual way of dealing with these to do something like
> >
> > ssize_t cur_size = min_t(ssize_t, size, PAGE_SIZE - off)
>
> I wouldn't know. I did
> $ git grep -n "(size_t)(PAGE_SIZE"
> arch/powerpc/mm/dma-noncoherent.c:357: size_t seg_size = min((size_t)(PAGE_SIZE - offset), size);
> arch/tile/kernel/pci-dma.c:176: size_t bytes = min(size, (size_t)(PAGE_SIZE - offset));
> arch/tile/kernel/pci-dma.c:192: size_t bytes = min(size, (size_t)(PAGE_SIZE - offset));
> drivers/net/wireless/ti/wlcore/main.c:806: len = min(maxlen, (size_t)(PAGE_SIZE - wl->fwlog_size));
> drivers/scsi/libfc/fc_libfc.c:143: (size_t)(PAGE_SIZE - (off & ~PAGE_MASK)));
> drivers/target/tcm_fc/tfc_io.c:160: tlen = min(tlen, (size_t)(PAGE_SIZE -
> drivers/target/tcm_fc/tfc_io.c:311: tlen = min(tlen, (size_t)(PAGE_SIZE -
>
> and concluded my solution was acceptable. Is your alternative considered
> to be better?
Yes, min_t() is specifically meant for this type of situation. On a side
note, I think cur_size should be size_t rather than ssize_t.
Thierry
Content of type "application/pgp-signature" skipped
Powered by blists - more mailing lists