lkml.org 
[lkml]   [1999]   [Jul]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: dangling else
Hi Chris.

On Tue, 13 Jul 1999, Chris Atenasio wrote:

> umm... looks like it was already fixed in sparc64

> linux-2.2.10/arch/sparc/mm/fault.c:386

> if(write)
> if(!(vma->vm_flags & VM_WRITE))
> goto bad_area;
> else
> if(!(vma->vm_flags & (VM_READ | VM_EXEC)))
> goto bad_area;

That doesn't do what the indentation suggests, so you may want to
check what is intended. Here's how the compiler would interpret
that:

> if(write)
> if(!(vma->vm_flags & VM_WRITE))
> goto bad_area;
> else
> if(!(vma->vm_flags & (VM_READ | VM_EXEC)))
> goto bad_area;

As you can see, the implications are different. Here's the corrected
version of the original, assuming the indentation shows what is
intended...

> if(write)
> {
> if(!(vma->vm_flags & VM_WRITE))
> goto bad_area;
> }
> else
> if(!(vma->vm_flags & (VM_READ | VM_EXEC)))
> goto bad_area;

Note the extra pair of braces...

Best wishes from Riley.

+----------------------------------------------------------------------+
| There is something frustrating about the quality and speed of Linux |
| development, ie., the quality is too high and the speed is too high, |
| in other words, I can implement this XXXX feature, but I bet someone |
| else has already done so and is just about to release their patch. |
+----------------------------------------------------------------------+
* ftp://ftp.MemAlpha.cx/pub/rhw/Linux
* http://www.MemAlpha.cx/kernel.versions.html


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:52    [W:0.059 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site