Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1399070

[PATCH] mm, compaction: avoid uninitialized variable use

From Arnd Bergmann <arnd@arndb.de>
Newsgroups linux.kernel
Subject [PATCH] mm, compaction: avoid uninitialized variable use
Date 2016-05-11 15:30 +0200
Message-ID <rxCn8-F9-5@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


A recent rework of the compaction code introduced a warning about
an uninitialized variable when CONFIG_COMPACTION is disabled and
__alloc_pages_direct_compact() does not set its 'compact_result'
output argument:

mm/page_alloc.c: In function '__alloc_pages_nodemask':
mm/page_alloc.c:3651:6: error: 'compact_result' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This adds another check for CONFIG_COMPACTION to ensure we never
evaluate the uninitialized variable in this configuration, which
is probably the simplest way to avoid the warning.

A more elaborate rework might make this more readable.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 13cff7b81275 ("mm, compaction: simplify __alloc_pages_direct_compact feedback interface")
---
 mm/page_alloc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 477d9382f70d..bedadc686a22 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3640,7 +3640,8 @@ retry:
 		goto got_pg;
 
 	/* Checks for THP-specific high-order allocations */
-	if (is_thp_gfp_mask(gfp_mask)) {
+	if (IS_ENABLED(CONFIG_COMPACTION) &&
+		is_thp_gfp_mask(gfp_mask)) {
 		/*
 		 * If compaction is deferred for high-order allocations, it is
 		 * because sync compaction recently failed. If this is the case
-- 
2.7.0

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] mm, compaction: avoid uninitialized variable use Arnd Bergmann <arnd@arndb.de> - 2016-05-11 15:30 +0200
  Re: [PATCH] mm, compaction: avoid uninitialized variable use Michal Hocko <mhocko@kernel.org> - 2016-05-11 16:50 +0200
    Re: [PATCH] mm, compaction: avoid uninitialized variable use Arnd Bergmann <arnd@arndb.de> - 2016-05-11 17:00 +0200
      Re: [PATCH] mm, compaction: avoid uninitialized variable use Michal Hocko <mhocko@kernel.org> - 2016-05-11 18:20 +0200
    Re: [PATCH] mm, compaction: avoid uninitialized variable use Michal Hocko <mhocko@kernel.org> - 2016-05-11 17:00 +0200
  Re: [PATCH] mm, compaction: avoid uninitialized variable use Michal Hocko <mhocko@kernel.org> - 2016-05-12 08:20 +0200
    Re: [PATCH] mm, compaction: avoid uninitialized variable use Vlastimil Babka <vbabka@suse.cz> - 2016-05-12 14:10 +0200
    Re: [PATCH] mm, compaction: avoid uninitialized variable use Arnd Bergmann <arnd@arndb.de> - 2016-05-12 14:10 +0200

csiph-web