[PATCH v2] drm/radeon: silence GCC warning on 32 bit

2014-03-04 Thread Christian König
Am 04.03.2014 10:34, schrieb Paul Bolle:
> Building radeon_ttm.o on 32 bit x86 triggers a warning:
>  In file included from include/asm-generic/bug.h:13:0,
>   from [...]/arch/x86/include/asm/bug.h:38,
>   from include/linux/bug.h:4,
>   from include/drm/drm_mm.h:39,
>   from include/drm/drm_vma_manager.h:26,
>   from include/drm/ttm/ttm_bo_api.h:35,
>   from drivers/gpu/drm/radeon/radeon_ttm.c:32:
>  drivers/gpu/drm/radeon/radeon_ttm.c: In function 'radeon_ttm_gtt_read':
>  include/linux/kernel.h:712:17: warning: comparison of distinct pointer 
> types lacks a cast [enabled by default]
>(void) (&_min1 == &_min2);  \
>   ^
>  drivers/gpu/drm/radeon/radeon_ttm.c:938:22: note: in expansion of macro 
> 'min'
> ssize_t cur_size = min(size, PAGE_SIZE - off);
>^
>
> Silence this warning by using min_t(). Since cur_size will never be
> negative and its upper bound is PAGE_SIZE, we can change its type to
> size_t and use min_t(size_t, [...]) here.
>
> Signed-off-by: Paul Bolle 

Reviewed-by: Christian K?nig 

> ---
> v2: use min_t() as Ilia suggested, and convert cur_size to size_t, as
> Thierry suggested.
>
> Still compile tested only (on 32 and 64 bit x86).
>
>   drivers/gpu/drm/radeon/radeon_ttm.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c 
> b/drivers/gpu/drm/radeon/radeon_ttm.c
> index 77f5b0c..1ce6ba6 100644
> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> @@ -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);
> + size_t cur_size = min_t(size_t, size, PAGE_SIZE - off);
>   struct page *page;
>   void *ptr;
>   




[PATCH v2] drm/radeon: silence GCC warning on 32 bit

2014-03-04 Thread Paul Bolle
Building radeon_ttm.o on 32 bit x86 triggers a warning:
In file included from include/asm-generic/bug.h:13:0,
 from [...]/arch/x86/include/asm/bug.h:38,
 from include/linux/bug.h:4,
 from include/drm/drm_mm.h:39,
 from include/drm/drm_vma_manager.h:26,
 from include/drm/ttm/ttm_bo_api.h:35,
 from drivers/gpu/drm/radeon/radeon_ttm.c:32:
drivers/gpu/drm/radeon/radeon_ttm.c: In function 'radeon_ttm_gtt_read':
include/linux/kernel.h:712:17: warning: comparison of distinct pointer 
types lacks a cast [enabled by default]
  (void) (&_min1 == &_min2);  \
 ^
drivers/gpu/drm/radeon/radeon_ttm.c:938:22: note: in expansion of macro 
'min'
   ssize_t cur_size = min(size, PAGE_SIZE - off);
  ^

Silence this warning by using min_t(). Since cur_size will never be
negative and its upper bound is PAGE_SIZE, we can change its type to
size_t and use min_t(size_t, [...]) here.

Signed-off-by: Paul Bolle 
---
v2: use min_t() as Ilia suggested, and convert cur_size to size_t, as
Thierry suggested.

Still compile tested only (on 32 and 64 bit x86).

 drivers/gpu/drm/radeon/radeon_ttm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c 
b/drivers/gpu/drm/radeon/radeon_ttm.c
index 77f5b0c..1ce6ba6 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -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);
+   size_t cur_size = min_t(size_t, size, PAGE_SIZE - off);
struct page *page;
void *ptr;

-- 
1.8.5.3



[PATCH v2] drm/radeon: silence GCC warning on 32 bit

2014-03-04 Thread Alex Deucher
On Tue, Mar 4, 2014 at 4:34 AM, Paul Bolle  wrote:
> Building radeon_ttm.o on 32 bit x86 triggers a warning:
> In file included from include/asm-generic/bug.h:13:0,
>  from [...]/arch/x86/include/asm/bug.h:38,
>  from include/linux/bug.h:4,
>  from include/drm/drm_mm.h:39,
>  from include/drm/drm_vma_manager.h:26,
>  from include/drm/ttm/ttm_bo_api.h:35,
>  from drivers/gpu/drm/radeon/radeon_ttm.c:32:
> drivers/gpu/drm/radeon/radeon_ttm.c: In function 'radeon_ttm_gtt_read':
> include/linux/kernel.h:712:17: warning: comparison of distinct pointer 
> types lacks a cast [enabled by default]
>   (void) (&_min1 == &_min2);  \
>  ^
> drivers/gpu/drm/radeon/radeon_ttm.c:938:22: note: in expansion of macro 
> 'min'
>ssize_t cur_size = min(size, PAGE_SIZE - off);
>   ^
>
> Silence this warning by using min_t(). Since cur_size will never be
> negative and its upper bound is PAGE_SIZE, we can change its type to
> size_t and use min_t(size_t, [...]) here.
>
> Signed-off-by: Paul Bolle 

Applied to my -fixes tree.

Thanks!

Alex

> ---
> v2: use min_t() as Ilia suggested, and convert cur_size to size_t, as
> Thierry suggested.
>
> Still compile tested only (on 32 and 64 bit x86).
>
>  drivers/gpu/drm/radeon/radeon_ttm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c 
> b/drivers/gpu/drm/radeon/radeon_ttm.c
> index 77f5b0c..1ce6ba6 100644
> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> @@ -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);
> +   size_t cur_size = min_t(size_t, size, PAGE_SIZE - off);
> struct page *page;
> void *ptr;
>
> --
> 1.8.5.3
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel