[PATCH] mm: fix uninitialized variable warnings

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

 



In a rare randconfig build, I got a warning about possibly uninitialized
variables:

mm/page-writeback.c: In function 'balance_dirty_pages':
mm/page-writeback.c:1623:16: error: 'writeback' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    mdtc->dirty += writeback;
                ^~
mm/page-writeback.c:1624:4: error: 'filepages' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    mdtc_calc_avail(mdtc, filepages, headroom);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mm/page-writeback.c:1624:4: error: 'headroom' may be used uninitialized in this function [-Werror=maybe-uninitialized]

The compiler evidently fails to notice that the usage is in dead code
after 'mdtc' is set to NULL when CONFIG_CGROUP_WRITEBACK is disabled.
Adding an IS_ENABLED() check makes this clear to the compiler.

Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
---
 mm/page-writeback.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 3f690bae6b78..f02535b7731a 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -1611,7 +1611,7 @@ static void balance_dirty_pages(struct bdi_writeback *wb,
 			bg_thresh = gdtc->bg_thresh;
 		}
 
-		if (mdtc) {
+		if (IS_ENABLED(CONFIG_CGROUP_WRITEBACK) && mdtc) {
 			unsigned long filepages, headroom, writeback;
 
 			/*
@@ -1944,7 +1944,7 @@ bool wb_over_bg_thresh(struct bdi_writeback *wb)
 	    wb_calc_thresh(gdtc->wb, gdtc->bg_thresh))
 		return true;
 
-	if (mdtc) {
+	if (IS_ENABLED(CONFIG_CGROUP_WRITEBACK) && mdtc) {
 		unsigned long filepages, headroom, writeback;
 
 		mem_cgroup_wb_stats(wb, &filepages, &headroom, &mdtc->dirty,
-- 
2.18.0




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

  Powered by Linux