linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH, 2.6.28-rc5] unitialized return value in mm/mlock.c: __mlock_vma_pages_range()
@ 2008-11-16 23:30 Helge Deller
  2008-11-16 23:55 ` Linus Torvalds
  0 siblings, 1 reply; 2+ messages in thread
From: Helge Deller @ 2008-11-16 23:30 UTC (permalink / raw)
  To: linux-kernel, akpm, torvalds, Kyle Mc Martin, linux-parisc, linux-mm

Fix an unitialized return value when compiling on parisc (with CONFIG_UNEVICTABLE_LRU=y):
	mm/mlock.c: In function `__mlock_vma_pages_range':
	mm/mlock.c:165: warning: `ret' might be used uninitialized in this function

Signed-off-by: Helge Deller <deller@gmx.de>

--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -162,7 +162,7 @@ static long __mlock_vma_pages_range(struct vm_area_struct *vma,
 	unsigned long addr = start;
 	struct page *pages[16]; /* 16 gives a reasonable batch */
 	int nr_pages = (end - start) / PAGE_SIZE;
-	int ret;
+	int ret = 0;
 	int gup_flags = 0;
 
 	VM_BUG_ON(start & ~PAGE_MASK);



--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH, 2.6.28-rc5] unitialized return value in mm/mlock.c: __mlock_vma_pages_range()
  2008-11-16 23:30 [PATCH, 2.6.28-rc5] unitialized return value in mm/mlock.c: __mlock_vma_pages_range() Helge Deller
@ 2008-11-16 23:55 ` Linus Torvalds
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Torvalds @ 2008-11-16 23:55 UTC (permalink / raw)
  To: Helge Deller; +Cc: linux-kernel, akpm, Kyle Mc Martin, linux-parisc, linux-mm


On Mon, 17 Nov 2008, Helge Deller wrote:
>
> Fix an unitialized return value when compiling on parisc (with CONFIG_UNEVICTABLE_LRU=y):
> 	mm/mlock.c: In function `__mlock_vma_pages_range':
> 	mm/mlock.c:165: warning: `ret' might be used uninitialized in this function

Looks valid.

Of course, nobody should ever call this with a range that could possibly 
be empty, so an equally valid approach would be to change the "while" loop 
to a "do while()", and that would generate better code. But I guess the 
simple unnecessary initialization is more defensive programming, in that 
if some other buggy caller does set things up with an empty range, it gets 
the right result.

Btw, exactly _because_ gcc warnings about uninitialized functions are 
sometimes bogus (ie due to gcc simply not being able to follow things like 
conditional initializations where the values are only used if they were 
initialized), I would ask that people comment on these kinds of issues 
when they send in patches. 

		Linus

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2008-11-16 23:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-16 23:30 [PATCH, 2.6.28-rc5] unitialized return value in mm/mlock.c: __mlock_vma_pages_range() Helge Deller
2008-11-16 23:55 ` Linus Torvalds

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