Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2101649imm; Sat, 13 Oct 2018 10:06:07 -0700 (PDT) X-Google-Smtp-Source: ACcGV63xuA4ixYR8iWJnLhjeFx/qLn7iKny+vcEBnOA5S5FlzGsKQ5jd57N5D/aPhi22Y+nPM8lg X-Received: by 2002:a63:de05:: with SMTP id f5-v6mr9793766pgg.292.1539450367326; Sat, 13 Oct 2018 10:06:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539450367; cv=none; d=google.com; s=arc-20160816; b=Li+y8PJudXKbnSCuCcKZ8JR8wSYkrASmfhgPaWsixSy1i45FubWFWtnKCv07o9VZLV 2jNomZSmnpEtgXfoBrOFrfCLsBfAMNRAnQniEq9ayW3lJ5fY9olOz5yK88VYw7CXyfxz B4TSwmpTfNTZCBvA2JN64rCWBqugPA0Ni2vNErltt20eACVwCVMwJhKuqP3fjRHaJa4q lvUKAlwgss8mDFvhAk7GB6UO52CaQshWE/rS1pD6hTwayxpAHV74TalzVQiiEztllENa o8sRg2Jl0qiln2NWv0k2RIrxlnytfrVcTHl/HOi9dAHep02Q5viog7YxICGnlBRVtx02 xJuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=lBV0QO459WTTqFnmD7pZDxx8U0cyPRIGNGBD4H22lDc=; b=xKXRftiXaVY98z6WZV79DJEqO5qwmX/GH8WnEluni50IrbkkyVyolZpwLSQBoge6Xk VFmz2HMT0pqyR4qMec+J0iRUL5TW9O++Btzx390g5fR5JEUkFaUExHtnCWkXdvIO3zr3 OmmuV6uYDCvteVJ/EvFGB1rzmC/HgPO8cHOSBulG1XHlzdCx84fSouqP6zvD1A4xXUOC TrKENEweNpRKFB1I56HaKjKbTHydohIWmhMpkodvsgWMSHaxith86lJ7i/XQUHtOpUWu P0RXg1kIgWCx/+K2UPiq3GVataeFg5DavBg16MnUB5tGpGtZY0ehuCpEucvDOjx7G2OQ FZnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DaAaPTjg; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o12-v6si5317928pfd.102.2018.10.13.10.05.52; Sat, 13 Oct 2018 10:06:07 -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=@gmail.com header.s=20161025 header.b=DaAaPTjg; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726883AbeJNAnR (ORCPT + 99 others); Sat, 13 Oct 2018 20:43:17 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:46471 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726464AbeJNAnR (ORCPT ); Sat, 13 Oct 2018 20:43:17 -0400 Received: by mail-oi1-f195.google.com with SMTP id k64-v6so12150857oia.13 for ; Sat, 13 Oct 2018 10:05:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lBV0QO459WTTqFnmD7pZDxx8U0cyPRIGNGBD4H22lDc=; b=DaAaPTjgo+XOcS0x2asnXJncPDtmSnkH2rCjORfHnH8ZzZ+RdhWnxz5m7sa0l43XoA EwIA0pktSB/fLA63EpRehV24BbfSeoTyq7ezutJcFAOOXxKnzjQVisEEJcfk6ch0DF8A SUTVqU0BpFA8Xh2qB4KcByqPOE0zYNBnIt6CqgeK98gLhklONdOXktY1l+a7KukSK+pX VUWLxTQu/cM2QDh85WGi1/DZ5G+bMSnCCxip2DWvtOQ7TC4r9PRu5nrDBx2azyvq2zxc RWy8v5trMoDqYpDSdGDeeEOdXT+KDP2OefxhhCx7Kwx+azqrHOe7+uzUE92HKxqWqnFq Rclw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lBV0QO459WTTqFnmD7pZDxx8U0cyPRIGNGBD4H22lDc=; b=EfM+S0e9fRDi1behJdMQeyJKHzTP/h1DTL5di0frxjlbu/+Ok2TuVWniJ7Vck59bEN ek8vvRykegfgdG6wG7AC/+yi59oV9p5h33gmXVVhFjM0Uew91PtgepWE9zfKoodoWEXs GO2Jos+EXhHIIKHM5D7XUjMRJif2aAh441/TxdORbYei+wLQ3FpAuB6p+AlMeeYswpzT +Qgv6w5X16Fqf7AUMQLOKF4BilTUSBylsby5k2iaEaN4fWyh5b8Y4ZvNq70WXBRhlmNV iOflBQ+ZWuMcHRyhwxFFh3rufQLar5TeAUz6TtcqmgsYvjEndtqBdNXt7JmpIxbqYQYA I2ZA== X-Gm-Message-State: ABuFfojqU3aJFwpWgCWF//NwZknXeKvfDrFa8SlXSLFiBlRvFh8IvRqP 2dphBAzo3Q3lHNpe1Mxif+cijdB87ydALBnDZ2E= X-Received: by 2002:aca:4792:: with SMTP id u140-v6mr5538699oia.215.1539450321921; Sat, 13 Oct 2018 10:05:21 -0700 (PDT) MIME-Version: 1.0 References: <1539447319-5383-1-git-send-email-penghao122@sina.com.cn> In-Reply-To: <1539447319-5383-1-git-send-email-penghao122@sina.com.cn> From: Pavel Tatashin Date: Sat, 13 Oct 2018 13:04:45 -0400 Message-ID: Subject: Re: [PATCH] mm/sparse: remove a check that compare if unsigned variable is negative To: penghao122@sina.com.cn Cc: Linux Memory Management List , Andrew Morton , pasha.tatashin@oracle.com, osalvador@suse.de, LKML , peng.hao2@zte.com.cn Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is incorrect: next_present_section_nr() returns "int" and -1 no next section, this change would lead to infinite loop. On Sat, Oct 13, 2018 at 12:16 PM Peng Hao wrote: > > > From: Peng Hao > > In all use locations for for_each_present_section_nr, variable > section_nr is unsigned. It is unnecessary to test if it is negative. > > Signed-off-by: Peng Hao > --- > mm/sparse.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/mm/sparse.c b/mm/sparse.c > index 10b07ee..a6f9f22 100644 > --- a/mm/sparse.c > +++ b/mm/sparse.c > @@ -196,8 +196,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 <= __highest_present_section_nr)); \ > + section_nr <= __highest_present_section_nr; \ > section_nr = next_present_section_nr(section_nr)) > > static inline unsigned long first_present_section_nr(void) > -- > 1.8.3.1 > >