linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/fb_helper: Use min_t() to handle size_t and unsigned long
@ 2020-11-10  9:01 Geert Uytterhoeven
  2020-11-10  9:17 ` Thomas Zimmermann
  0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2020-11-10  9:01 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Sam Ravnborg
  Cc: dri-devel, linux-kernel, Geert Uytterhoeven

On arm32:

    drivers/gpu/drm/drm_fb_helper.c: In function ‘fb_read_screen_base’:
    include/linux/minmax.h:18:28: warning: comparison of distinct pointer types lacks a cast
    ...
    drivers/gpu/drm/drm_fb_helper.c:2041:22: note: in expansion of macro ‘min’
     2041 |  size_t alloc_size = min(count, PAGE_SIZE);
	  |                      ^~~
    drivers/gpu/drm/drm_fb_helper.c: In function ‘fb_write_screen_base’:
    include/linux/minmax.h:18:28: warning: comparison of distinct pointer types lacks a cast
    ...
    drivers/gpu/drm/drm_fb_helper.c:2115:22: note: in expansion of macro ‘min’
     2115 |  size_t alloc_size = min(count, PAGE_SIZE);
	  |                      ^~~

Indeed, on 32-bit size_t is "unsigned int", not "unsigned long".

Fixes: 222ec45f4c69dfa8 ("drm/fb_helper: Support framebuffers in I/O memory")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Interestingly, the commit log claims v7 changed:

    use min_t(size_t,) (kernel test robot)
---
 drivers/gpu/drm/drm_fb_helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 01ba1da285116373..25edf670867c6f79 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -2038,7 +2038,7 @@ static ssize_t fb_read_screen_base(struct fb_info *info, char __user *buf, size_
 				   loff_t pos)
 {
 	const char __iomem *src = info->screen_base + pos;
-	size_t alloc_size = min(count, PAGE_SIZE);
+	size_t alloc_size = min_t(size_t, count, PAGE_SIZE);
 	ssize_t ret = 0;
 	int err = 0;
 	char *tmp;
@@ -2112,7 +2112,7 @@ static ssize_t fb_write_screen_base(struct fb_info *info, const char __user *buf
 				    loff_t pos)
 {
 	char __iomem *dst = info->screen_base + pos;
-	size_t alloc_size = min(count, PAGE_SIZE);
+	size_t alloc_size = min_t(size_t, count, PAGE_SIZE);
 	ssize_t ret = 0;
 	int err = 0;
 	u8 *tmp;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/fb_helper: Use min_t() to handle size_t and unsigned long
  2020-11-10  9:01 [PATCH] drm/fb_helper: Use min_t() to handle size_t and unsigned long Geert Uytterhoeven
@ 2020-11-10  9:17 ` Thomas Zimmermann
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Zimmermann @ 2020-11-10  9:17 UTC (permalink / raw)
  To: Geert Uytterhoeven, Maarten Lankhorst, Maxime Ripard,
	David Airlie, Daniel Vetter, Sam Ravnborg
  Cc: dri-devel, linux-kernel

Hi

Am 10.11.20 um 10:01 schrieb Geert Uytterhoeven:
> On arm32:
> 
>     drivers/gpu/drm/drm_fb_helper.c: In function ‘fb_read_screen_base’:
>     include/linux/minmax.h:18:28: warning: comparison of distinct pointer types lacks a cast
>     ...
>     drivers/gpu/drm/drm_fb_helper.c:2041:22: note: in expansion of macro ‘min’
>      2041 |  size_t alloc_size = min(count, PAGE_SIZE);
> 	  |                      ^~~
>     drivers/gpu/drm/drm_fb_helper.c: In function ‘fb_write_screen_base’:
>     include/linux/minmax.h:18:28: warning: comparison of distinct pointer types lacks a cast
>     ...
>     drivers/gpu/drm/drm_fb_helper.c:2115:22: note: in expansion of macro ‘min’
>      2115 |  size_t alloc_size = min(count, PAGE_SIZE);
> 	  |                      ^~~
> 
> Indeed, on 32-bit size_t is "unsigned int", not "unsigned long".
> 
> Fixes: 222ec45f4c69dfa8 ("drm/fb_helper: Support framebuffers in I/O memory")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

Thanks a lot. I'll add the patch to drm-misc-next.

> ---
> Interestingly, the commit log claims v7 changed:
> 
>     use min_t(size_t,) (kernel test robot)

It got fixed in the functions' inner loops, but I missed the other
instances.

Best regards
Thomas

> ---
>  drivers/gpu/drm/drm_fb_helper.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 01ba1da285116373..25edf670867c6f79 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -2038,7 +2038,7 @@ static ssize_t fb_read_screen_base(struct fb_info *info, char __user *buf, size_
>  				   loff_t pos)
>  {
>  	const char __iomem *src = info->screen_base + pos;
> -	size_t alloc_size = min(count, PAGE_SIZE);
> +	size_t alloc_size = min_t(size_t, count, PAGE_SIZE);
>  	ssize_t ret = 0;
>  	int err = 0;
>  	char *tmp;
> @@ -2112,7 +2112,7 @@ static ssize_t fb_write_screen_base(struct fb_info *info, const char __user *buf
>  				    loff_t pos)
>  {
>  	char __iomem *dst = info->screen_base + pos;
> -	size_t alloc_size = min(count, PAGE_SIZE);
> +	size_t alloc_size = min_t(size_t, count, PAGE_SIZE);
>  	ssize_t ret = 0;
>  	int err = 0;
>  	u8 *tmp;
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-10  9:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-10  9:01 [PATCH] drm/fb_helper: Use min_t() to handle size_t and unsigned long Geert Uytterhoeven
2020-11-10  9:17 ` Thomas Zimmermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).