Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5579212img; Wed, 27 Mar 2019 11:04:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqyVw6qWaHoOdI2AZGzPO1pU+MLdVGtUTxV+299E6SU3eN7cKO84kNDJ131Uq49Zn+Ot3SsP X-Received: by 2002:a63:4b0a:: with SMTP id y10mr35468368pga.66.1553709850210; Wed, 27 Mar 2019 11:04:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553709850; cv=none; d=google.com; s=arc-20160816; b=n0qN14+X1jI01pjjhAZXbg2mHVqfGGcBujMTbeIMlfj4ndALCh/Tx8ovZcexagRP8X wfEXK92kiUFSK2JwaWx7m2mqaShuRaIka5EuYy4SDT8NxMgcBFp/Krtb9VSWQSoZS0Us awkevtPhvXRhpAuztPe3WTSMVZ8kosBDyz+3g49LJGrTFFMveO4W5fMZ28XRD5n46ikL h4oahhcapgdu2+X0yeoQhMCZZZr+riEbgP1EGJV4qfhQBy2MeOTb/r44/X505YBHlaKU NK1cnE6b2m4B9gfYsUqzDTXFzosZ7DvIaRm9huh6nSSvSEtaZbSscQfdFicvCh5nzs0S LQuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rSaj9L1xCJ7iztPjfarFG1shcw+7hxXe+zCxGAJuYMQ=; b=t+AcXuLbkEFUkCBYYdIejOH86ldNCDCrMwYvzlDcze0Ht6dks1vR1gmh8jbTjBTEt3 nUK94lOOC/acNzhd1+2BQ13gFhbXA60e1DA1qmt8zcpMYZuD1Q+1swePqkFcczqh8O8r M3j/LLlNYj5BG+OvgehdOi3CkJAITinOkuvP+k0TFOp4Hf36ZZ3QUE7eKVrE1yAWhmgv MONYVAWO+eLZD+GdsGwzLaeAC78PzQ+OvHkJdpmYZV5w1tzcA9d4ahqBkN4DhBOfXf9i 7I9xojMif519R9rynjWGs9+ZtsxCw9XRxxzwBSOCLyUslwCB3JCgtyHPRJVVn/MG3Mx/ HMkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KBaKqEmY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v21si18707103pff.44.2019.03.27.11.03.54; Wed, 27 Mar 2019 11:04:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KBaKqEmY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731614AbfC0SCu (ORCPT + 99 others); Wed, 27 Mar 2019 14:02:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:42764 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731250AbfC0SCs (ORCPT ); Wed, 27 Mar 2019 14:02:48 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5C1D22082F; Wed, 27 Mar 2019 18:02:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709768; bh=b5xJuu4cKmJC0HBUNTG66oXfu8IqPF1/ejzqYlsS8zI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KBaKqEmYIAB49HWucvLauhdZFKkmZxCUMrWtfwDMDOxFJzoBdZfIw8b0dcd+4PeQN MRR7BLRlpWtTGF878QXdZqfxdmAAlCevJD2dIrvXfgJhC24iDJ2J+HVMr5hOrBeIFN AdDzqyK1ed7xLuZY31ZDlguYZEU/7u5i2ALmpRIc= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Qian Cai , Dave Hansen , Andrew Morton , Linus Torvalds , Sasha Levin , linux-mm@kvack.org Subject: [PATCH AUTOSEL 5.0 030/262] mm/sparse: fix a bad comparison Date: Wed, 27 Mar 2019 13:58:05 -0400 Message-Id: <20190327180158.10245-30-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Qian Cai [ Upstream commit d778015ac95bc036af73342c878ab19250e01fe1 ] next_present_section_nr() could only return an unsigned number -1, so just check it specifically where compilers will convert -1 to unsigned if needed. mm/sparse.c: In function 'sparse_init_nid': mm/sparse.c:200:20: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] ((section_nr >= 0) && \ ^~ mm/sparse.c:478:2: note: in expansion of macro 'for_each_present_section_nr' for_each_present_section_nr(pnum_begin, pnum) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~ mm/sparse.c:200:20: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] ((section_nr >= 0) && \ ^~ mm/sparse.c:497:2: note: in expansion of macro 'for_each_present_section_nr' for_each_present_section_nr(pnum_begin, pnum) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~ mm/sparse.c: In function 'sparse_init': mm/sparse.c:200:20: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] ((section_nr >= 0) && \ ^~ mm/sparse.c:520:2: note: in expansion of macro 'for_each_present_section_nr' for_each_present_section_nr(pnum_begin + 1, pnum_end) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~ Link: http://lkml.kernel.org/r/20190228181839.86504-1-cai@lca.pw Fixes: c4e1be9ec113 ("mm, sparsemem: break out of loops early") Signed-off-by: Qian Cai Reviewed-by: Andrew Morton Cc: Dave Hansen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- mm/sparse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/sparse.c b/mm/sparse.c index 7ea5dc6c6b19..77a0554fa5bd 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -197,7 +197,7 @@ static inline int next_present_section_nr(int section_nr) } #define for_each_present_section_nr(start, section_nr) \ for (section_nr = next_present_section_nr(start-1); \ - ((section_nr >= 0) && \ + ((section_nr != -1) && \ (section_nr <= __highest_present_section_nr)); \ section_nr = next_present_section_nr(section_nr)) -- 2.19.1