Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2206541ybi; Mon, 17 Jun 2019 00:21:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqwgcGOgXIBIGFVt9vUpQ9DQxOVtQbrxUeEgc0OkZmVITXIo6XTmZ3ZBH+Ajn5HCxZqiXl90 X-Received: by 2002:a65:408d:: with SMTP id t13mr47422376pgp.373.1560756097985; Mon, 17 Jun 2019 00:21:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560756097; cv=none; d=google.com; s=arc-20160816; b=vz5OZo9VcgszljgsUmHQFPA3M6ApQy7sL/mrB3RhAVAXJ8e9jkn4kuvPZQMYWiOF+h rSPIkThothQzC5Ve7AEA7OTZ8lIjTSxDeRC7XkzsXrFy5Yu7VCAQzZKtcC2Zz/tayMbi fcd8p6Y3c5Gko/zKoEDxg6kO8C3C15SEyYwj0MfzkEbouU8Y+uasnCgYZutAnqGWCoBk eqsKF46yCvVgvj1XVLxoSvVwAxuN54fMaXpiXAgGwZt2UL4G3jdtNqxgnAIJ90XQ7YbS uXnYhPjsx+KKxG5ymHtH1ae4ZdHJwaU7hhpzN8EPJfvY0XX3J/O8YXWzyV+uA60ouhr/ kWxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=taie2JYezWzJogalmxVehPImlMqA5dujJGn6oHcXSJ4=; b=OzN4m3l4d+zD3JcA+SeuLk3aWhhyru9v//wWkT6jZIrHo1NTYDBgE0GI3dfwCFZ3l2 p2zJd80Fzdni2H5SqEWJYwGO9hmgdbSLTaBNcXVcB03w+vvnEjg20jU6yPD+ZOA6OEqt bpru6FAXd+3yPzfZW4LllFyHuHrceNoK4Khe0ZqOEGEVXTXGpfQH8LktFq+j1p5mdD2Y wIAXQa1s+/oH1KIWVpRUvJbWxCg7rEaMMsuYFrVbFm3m1JCkWiEVAiqP3MrO5j72d/ja u8baDQ8e8J47SgYDvzF/NIi6Dub98m9CxtPpwrGKevriE3tw5hLTAfu4YgGWxVawxWdo zkUQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m63si9840990pjb.8.2019.06.17.00.21.20; Mon, 17 Jun 2019 00:21:37 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726121AbfFQHVK (ORCPT + 99 others); Mon, 17 Jun 2019 03:21:10 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:42624 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725826AbfFQHVK (ORCPT ); Mon, 17 Jun 2019 03:21:10 -0400 Received: from p5b06daab.dip0.t-ipconnect.de ([91.6.218.171] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1hclwv-0007m4-9B; Mon, 17 Jun 2019 09:21:05 +0200 Date: Mon, 17 Jun 2019 09:21:04 +0200 (CEST) From: Thomas Gleixner To: Weikang shi cc: John Stultz , sboyd@kernel.org, LKML , swkhack@qq.com, Miroslav Lichvar Subject: Re: [PATCH] time: fix a assignment error in ntp module In-Reply-To: <20190422093421.47896-1-swkhack@gmail.com> Message-ID: References: <20190422093421.47896-1-swkhack@gmail.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 22 Apr 2019, Weikang shi wrote: > From: swkhack > > It is meanless to check a 64bit(txc->constant) value is postive > when the value has to be assigned to a 32 bit variable(*time_tai). > So I make a temp type conversion before the compare. What? Casting it to int makes it more negative, right? That's just wrong: long long x = 0xFFFFFFFF00000000; int y = (int) x; x is obviously negative, but y not. C type casting 101. > Signed-off-by: swkhack > --- > kernel/time/ntp.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c > index 92a90014a..6b454eafc 100644 > --- a/kernel/time/ntp.c > +++ b/kernel/time/ntp.c > @@ -690,7 +690,7 @@ static inline void process_adjtimex_modes(const struct __kernel_timex *txc, > time_constant = max(time_constant, 0l); > } > > - if (txc->modes & ADJ_TAI && txc->constant > 0) > + if (txc->modes & ADJ_TAI && (int)txc->constant > 0) > *time_tai = txc->constant; The way more interesting question is whether txc->constant can be > UINT_MAX. In that case the txc->constant would be truncated. Miroslav? Thanks, tglx