[PATCH 06/21] powerpc: Avoid comparison of unsigned long >= 0 in __access_ok

Segher Boessenkool segher at kernel.crashing.org
Tue Feb 27 09:17:48 AEDT 2018


On Mon, Feb 26, 2018 at 09:00:09PM +0100, christophe leroy wrote:
> Le 26/02/2018 à 18:50, Mathieu Malaterre a écrit :
> >On Mon, Feb 26, 2018 at 8:44 AM, Mathieu Malaterre <malat at debian.org> 
> >wrote:
> >>On Mon, Feb 26, 2018 at 7:50 AM, Christophe LEROY
> >><christophe.leroy at c-s.fr> wrote:
> >>>Note that I already try to submit a fix for this warning 3 years ago
> >>>(https://patchwork.ozlabs.org/patch/418075/) and it was rejected with the
> >>>following comment:
> >
> >Tested again today with gcc 6.3.0 and gcc is still producing the
> >original warning (treated as error).
> 
> That's right, it seems that recent versions of gcc are not happy anymore 
> with that change.
> 
> Maybe Segher has a suggestion for that one ?

Your patch:

 #define __access_ok(addr, size, segment)	\
 	(((addr) <= (segment).seg) &&		\
-	 (((size) == 0) || (((size) - 1) <= ((segment).seg - (addr)))))
+	 (((size) <= 1) || (((size) - 1) <= ((segment).seg - (addr)))))

Is there any reason to write this as a macro?  Let's make this more
readable:

static inline int __access_ok(unsigned long addr, unsigned long size,
			      mm_segment_t seg)
{
	if (addr > seg.seg)
		return 0;
	return (size == 0 || size - 1 <= seg.seg - addr);
}

and I think we are done already, or will this warn for any input?


Segher


More information about the Linuxppc-dev mailing list