Re: [PATCH] mm/compaction: Fix warning of 'flags' may be used uninitialized

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wednesday 10 September 2014 11:50:41 David Rientjes wrote:
> On Wed, 10 Sep 2014, Xiubo Li wrote:
> 
> > C      mm/compaction.o
> > mm/compaction.c: In function isolate_freepages_block:
> > mm/compaction.c:364:37: warning: flags may be used uninitialized in
> > this function [-Wmaybe-uninitialized]
> >        && compact_unlock_should_abort(&cc->zone->lock, flags,
> >                                      ^
> > In file included from include/linux/irqflags.h:15:0,
> >                  from ./arch/arm/include/asm/bitops.h:27,
> >                  from include/linux/bitops.h:33,
> >                  from include/linux/kernel.h:10,
> >                  from include/linux/list.h:8,
> >                  from include/linux/preempt.h:10,
> >                  from include/linux/spinlock.h:50,
> >                  from include/linux/swap.h:4,
> >                  from mm/compaction.c:10:
> > mm/compaction.c: In function isolate_migratepages_block:
> > ./arch/arm/include/asm/irqflags.h:152:2: warning: flags may be used
> > uninitialized in this function [-Wmaybe-uninitialized]
> >   asm volatile(
> >   ^
> > mm/compaction.c:576:16: note: flags as declared here
> >   unsigned long flags;
> >                 ^
> > 
> > Signed-off-by: Xiubo Li <Li.Xiubo@xxxxxxxxxxxxx>
> 
> Arnd Bergmann already sent a patch for this to use uninitialized_var() 
> privately but it didn't get cc'd to any mailing list, sorry.

Oops, I hadn't noticed that I missed the mailing lists, sorry about that.
For reference, see my patch below.

	Arnd

8<------
>From a89cbd7a79d3ee0d35209416ea9bf35d4d2a8e69 Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <arnd@xxxxxxxx>
Date: Mon, 8 Sep 2014 12:25:14 +0200
Subject: [PATCH] mm: compaction: fix compile warning

The recently changed code in isolate_freepages_block seems to confuse
gcc-4.9 to the point where it can't know whether the 'flags' variable
is used or not. This happens for me with e.g. ARM realview_defconfig,
but not other configurations:

mm/compaction.c: In function 'isolate_freepages_block':
mm/compaction.c:364:10: warning: 'flags' may be used uninitialized in this function [-Wmaybe-uninitialized]
       && compact_unlock_should_abort(&cc->zone->lock, flags,
          ^
In file included from include/linux/irqflags.h:15:0,
                 from arch/arm/include/asm/bitops.h:27,
                 from include/linux/bitops.h:33,
                 from include/linux/kernel.h:10,
                 from include/linux/list.h:8,
                 from include/linux/preempt.h:10,
                 from include/linux/spinlock.h:50,
                 from include/linux/swap.h:4,
                 from mm/compaction.c:10:
mm/compaction.c: In function 'isolate_migratepages_block':
arch/arm/include/asm/irqflags.h:152:2: warning: 'flags' may be used uninitialized in this function [-Wmaybe-uninitialized]
  asm volatile(
  ^
mm/compaction.c:576:16: note: 'flags' was declared here
  unsigned long flags;

Using the uninitialized_var() macro is probably not the best solution,
but it shuts up the warning.

Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
Fixes: 142d94959e41 ("mm, compaction: periodically drop lock and restore IRQs in scanners")

diff --git a/mm/compaction.c b/mm/compaction.c
index 7d9d92e63297..1e22b46a9690 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -344,7 +344,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
 {
 	int nr_scanned = 0, total_isolated = 0;
 	struct page *cursor, *valid_page = NULL;
-	unsigned long flags;
+	unsigned long uninitialized_var(flags);
 	bool locked = false;
 	unsigned long blockpfn = *start_pfn;
 
@@ -573,7 +573,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
 	unsigned long nr_scanned = 0, nr_isolated = 0;
 	struct list_head *migratelist = &cc->migratepages;
 	struct lruvec *lruvec;
-	unsigned long flags;
+	unsigned long uninitialized_var(flags);
 	bool locked = false;
 	struct page *page = NULL, *valid_page = NULL;
 

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




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]