mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH] x86: fix -Wsign-compare warnings in uaccess.h
@ 2015-06-27 19:16 Toralf Förster
  2015-06-27 19:20 ` Роман Донченко
  0 siblings, 1 reply; 3+ messages in thread
From: Toralf Förster @ 2015-06-27 19:16 UTC (permalink / raw)
  To: Роман
	Донченко,
	Linux Kernel

>The casts are safe, since those conditions are only evaluated when sz >= 0.


Wouldn't in this case the condition "sz < 0" be superfluously ?


-- 
Toralf
pgp key: 7B1A 07F4 EC82 0F90 D4C2  8936 872A E508 0076 E94E

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

* Re: [PATCH] x86: fix -Wsign-compare warnings in uaccess.h
  2015-06-27 19:16 [PATCH] x86: fix -Wsign-compare warnings in uaccess.h Toralf Förster
@ 2015-06-27 19:20 ` Роман Донченко
  0 siblings, 0 replies; 3+ messages in thread
From: Роман Донченко @ 2015-06-27 19:20 UTC (permalink / raw)
  To: Linux Kernel, Toralf Förster

Toralf Förster <toralf.foerster@gmx.de> писал в своём письме Sat, 27 Jun  
2015 22:16:27 +0300:

>> The casts are safe, since those conditions are only evaluated when sz  
>> >= 0.
>
>
> Wouldn't in this case the condition "sz < 0" be superfluously ?

No, sz can be negative. I meant that if sz < 0, then the second halves  
won't be evaluated (though even if they did, it wouldn't matter).

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

* [PATCH] x86: fix -Wsign-compare warnings in uaccess.h
@ 2015-06-27 16:57 Роман Донченко
  0 siblings, 0 replies; 3+ messages in thread
From: Роман Донченко @ 2015-06-27 16:57 UTC (permalink / raw)
  To: tglx, mingo, hpa; +Cc: x86, linux-kernel, trivial

The casts are safe, since those conditions are only evaluated when sz >= 0.

Signed-off-by: Роман Донченко <dpb@corrigendum.ru>
---
 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 a8df874..4c47002 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -714,7 +714,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)sz >= n))
 		n = _copy_from_user(to, from, n);
 	else if(__builtin_constant_p(n))
 		copy_from_user_overflow();
@@ -732,7 +732,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)sz >= n))
 		n = _copy_to_user(to, from, n);
 	else if(__builtin_constant_p(n))
 		copy_to_user_overflow();
-- 
2.3.2


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

end of thread, other threads:[~2015-06-27 19:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-27 19:16 [PATCH] x86: fix -Wsign-compare warnings in uaccess.h Toralf Förster
2015-06-27 19:20 ` Роман Донченко
  -- strict thread matches above, loose matches on Subject: below --
2015-06-27 16:57 Роман Донченко

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®