* [PATCH 2.6] clean-up: fixes "comparison between signed and unsigned"
@ 2004-12-06 20:57 Riina Kikas
2004-12-06 22:11 ` Jesper Juhl
0 siblings, 1 reply; 2+ messages in thread
From: Riina Kikas @ 2004-12-06 20:57 UTC (permalink / raw)
To: linux-kernel; +Cc: mroos
This patch fixes warning "comparison between signed and unsigned"
occuring on line 308
Signed-off-by: Riina Kikas <Riina.Kikas@mail.ee>
--- a/arch/i386/mm/fault.c 2004-12-02 21:30:30.000000000 +0000
+++ b/arch/i386/mm/fault.c 2004-12-02 21:30:59.000000000 +0000
@@ -302,7 +302,13 @@
* pusha) doing post-decrement on the stack and that
* doesn't show up until later..
*/
- if (address + 32 < regs->esp)
+ unsigned long regs_esp;
+ if (regs->esp < 0) {
+ regs_esp = 0;
+ } else {
+ regs_esp = regs->esp;
+ }
+ if (address + 32 < regs_esp)
goto bad_area;
}
if (expand_stack(vma, address))
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 2.6] clean-up: fixes "comparison between signed and unsigned"
2004-12-06 20:57 [PATCH 2.6] clean-up: fixes "comparison between signed and unsigned" Riina Kikas
@ 2004-12-06 22:11 ` Jesper Juhl
0 siblings, 0 replies; 2+ messages in thread
From: Jesper Juhl @ 2004-12-06 22:11 UTC (permalink / raw)
To: Riina Kikas; +Cc: linux-kernel, mroos
On Mon, 6 Dec 2004, Riina Kikas wrote:
> This patch fixes warning "comparison between signed and unsigned"
> occuring on line 308
>
> Signed-off-by: Riina Kikas <Riina.Kikas@mail.ee>
>
> --- a/arch/i386/mm/fault.c 2004-12-02 21:30:30.000000000 +0000
> +++ b/arch/i386/mm/fault.c 2004-12-02 21:30:59.000000000 +0000
> @@ -302,7 +302,13 @@
> * pusha) doing post-decrement on the stack and that
> * doesn't show up until later..
> */
> - if (address + 32 < regs->esp)
> + unsigned long regs_esp;
> + if (regs->esp < 0) {
> + regs_esp = 0;
> + } else {
> + regs_esp = regs->esp;
> + }
> + if (address + 32 < regs_esp)
> goto bad_area;
> }
> if (expand_stack(vma, address))
This seems a bit silly. If the stack pointer (esp) is ever negative that's
clearly a bug somewhere. So instead of testing it for <0 and then setting
your regs_esp variable to 0 it would make more sense to me to just
BUG_ON(regs->esp < 0) or something, if you want to do anything at all. And
if you want to silence the warning a exlicit cast to unsigned long should
do I'd say, but I have a feeling the best thing is to just leave that
warning alone, the code seems to be fine.
Also, your declaration of regs_esp interspaced with code (which is allowed
by C99 but not C89) will break on C89 compilers, some of which are still
supported - such as gcc 2.95.3 for instance.
--
Jesper Juhl
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-12-06 22:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-06 20:57 [PATCH 2.6] clean-up: fixes "comparison between signed and unsigned" Riina Kikas
2004-12-06 22:11 ` Jesper Juhl
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®