2015-05-10 23:48:37

by Louis Langholtz

[permalink] [raw]
Subject: [PATCH] x86: eliminate comparison between signed and unsigned integer expressions

Eliminates multiple compiler warnings when the -Wno-sign-compare option is
removed from the x86 Makefile (an option that is documented as a "Workaround
for a gcc prelease that unfortunately was shipped in a suse release").

Signed-off-by: Louis Langholtz <[email protected]>
---
arch/x86/include/asm/uaccess.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index ace9dec..3289bd1 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -709,7 +709,7 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
* case, and do only runtime checking for non-constant sizes.
*/

- if (likely(sz < 0 || sz >= n))
+ if (likely(sz < 0 || ((unsigned int)sz) >= n))
n = _copy_from_user(to, from, n);
else if(__builtin_constant_p(n))
copy_from_user_overflow();
@@ -727,7 +727,7 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
might_fault();

/* See the comment in copy_from_user() above. */
- if (likely(sz < 0 || sz >= n))
+ if (likely(sz < 0 || ((unsigned int)sz) >= n))
n = _copy_to_user(to, from, n);
else if(__builtin_constant_p(n))
copy_to_user_overflow();