From nobody Tue Jul 04 03:11:58 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Qw7BN1nR2z4lTF2 for ; Tue, 4 Jul 2023 03:12:12 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Qw7BM595Gz40YL for ; Tue, 4 Jul 2023 03:12:11 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-51d8fa4dbf9so5740007a12.1 for ; Mon, 03 Jul 2023 20:12:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20221208.gappssmtp.com; s=20221208; t=1688440330; x=1691032330; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=SxIw4UtlSqsll8BXyFK5XyV1Nt4pq9s7hx9Bnob71xo=; b=mG4cdlZGYcgQ5dIYNqeDwQ8Slsndbaw/lUXPn03zqn346Mrq+lbRFyFMrpwBn/O4/n nMxEGPSo9VPcKa5FbMtcOJrTDFsQ0GuHHMCAWDM4Es7xRRqsqUzVvsk1TLGVDeHhXlA6 llx14OgSbwrvJxNB7vh5fzAm7Hap/PJq0WZc6qjmbEesS/B90uJodf8RY20cMOFlG3qV 37w2dWnU2cdHtVsx5cO5CXXc1HrvloFLWB7Qhu2zUqX6wpyZl9skv4aPotHNjBtsW6+h FBXZy/dU2jqjOz7hWihtCp2XhPs6Gn3KHb4CtqOf5UVRhovS5xU3J0ir8xQGMHtHQzBY ojlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688440330; x=1691032330; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SxIw4UtlSqsll8BXyFK5XyV1Nt4pq9s7hx9Bnob71xo=; b=dMgFvNNV6CLkwUCOK0evSgykrmEH8IdxU8RCuPgWhXuPYsKn0/Gl4U4ZxMs11O4TCO jIbADxU60IavZppHc1XzFjYMTbjma+6madgBYLBAcZUBKxqJ+KqK8MZ8O5c48Tp2sYEH wnVLE5q0TmG0S0IYqLsWtnWpAtjYCsFkeM+3n95btEhHecNyst+EwDhNBpg5NKo+eola gLzZ/NM3cRC0zjRMocMBZJ8HdpHewLzWRpain0G7Hl69AetRlzaaMyzDAh/ZaRj3KLqJ bh1lEjiigR1bZI2k3mH7EZsP5tMlTaNGEfUeBB5osARDKhas1LUwAAAwq8pHNBCkO6lR bzIQ== X-Gm-Message-State: ABy/qLZpSsZZce6w6B+Bx2dwb84dWBA8g/OAza2VHM8O0Xf+O5pIWzdq QK9psSG0DMyRbJfL1UrhsvB4aoUzi0/E9Qg3zQbMng== X-Google-Smtp-Source: APBJJlEyQoXf+HTM2N8kWq/YbM9Uaio48xy/c6iXMgOatYD8hhV6eSBpe9LM0mNWGtaS62fUQvIAmUrP9DL/JZcuwUI= X-Received: by 2002:aa7:d30c:0:b0:51d:87c6:bf28 with SMTP id p12-20020aa7d30c000000b0051d87c6bf28mr8463294edq.3.1688440329363; Mon, 03 Jul 2023 20:12:09 -0700 (PDT) List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 References: <202307040308.36438MTA093771@gitrepo.freebsd.org> In-Reply-To: <202307040308.36438MTA093771@gitrepo.freebsd.org> From: Warner Losh Date: Mon, 3 Jul 2023 21:11:58 -0600 Message-ID: Subject: Re: git: 4456846a1a0d - main - bin/date: Upgrade calculations To: "Pedro F. Giffuni" Cc: src-committers , "" , "" Content-Type: multipart/alternative; boundary="0000000000000e782a05ffa0a639" X-Rspamd-Queue-Id: 4Qw7BM595Gz40YL X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N --0000000000000e782a05ffa0a639 Content-Type: text/plain; charset="UTF-8" This is a nope on armv7 and i386. So it has no effect there. DF got it wrong. These should likely be int64_t to avoid the overflow. No? Warner On Mon, Jul 3, 2023, 9:08 PM Pedro F. Giffuni wrote: > The branch main has been updated by pfg: > > URL: > https://cgit.FreeBSD.org/src/commit/?id=4456846a1a0d8cb6d0e6bae89f1134fa0a1af5cf > > commit 4456846a1a0d8cb6d0e6bae89f1134fa0a1af5cf > Author: Pedro F. Giffuni > AuthorDate: 2023-07-03 02:32:10 +0000 > Commit: Pedro F. Giffuni > CommitDate: 2023-07-04 03:08:01 +0000 > > bin/date: Upgrade calculations > > Use long instead of int for numerous calculations, fixing a number of > date calculation overflow issues. > > Obtained from: DragonflyBSD > Git log: 4238ce6f0c6df33ce677ae298b245c62cd60fb43 (only partial) > --- > bin/date/vary.c | 20 ++++++++++---------- > 1 file changed, 10 insertions(+), 10 deletions(-) > > diff --git a/bin/date/vary.c b/bin/date/vary.c > index 5f0123110ee3..6f3c59950ecf 100644 > --- a/bin/date/vary.c > +++ b/bin/date/vary.c > @@ -34,7 +34,7 @@ __FBSDID("$FreeBSD$"); > #include "vary.h" > > struct trans { > - int val; > + long val; > const char *str; > }; > > @@ -52,7 +52,7 @@ static struct trans trans_wday[] = { > }; > > static char digits[] = "0123456789"; > -static int adjhour(struct tm *, char, int, int); > +static int adjhour(struct tm *, char, long, int); > > static int > domktime(struct tm *t, char type) > @@ -125,7 +125,7 @@ daysinmonth(const struct tm *t) > > > static int > -adjyear(struct tm *t, char type, int val, int mk) > +adjyear(struct tm *t, char type, long val, int mk) > { > switch (type) { > case '+': > @@ -146,7 +146,7 @@ adjyear(struct tm *t, char type, int val, int mk) > } > > static int > -adjmon(struct tm *t, char type, int val, int istext, int mk) > +adjmon(struct tm *t, char type, long val, int istext, int mk) > { > int lmdays; > > @@ -206,7 +206,7 @@ adjmon(struct tm *t, char type, int val, int istext, > int mk) > } > > static int > -adjday(struct tm *t, char type, int val, int mk) > +adjday(struct tm *t, char type, long val, int mk) > { > int lmdays; > > @@ -250,7 +250,7 @@ adjday(struct tm *t, char type, int val, int mk) > } > > static int > -adjwday(struct tm *t, char type, int val, int istext, int mk) > +adjwday(struct tm *t, char type, long val, int istext, int mk) > { > if (val < 0) > return 0; > @@ -286,7 +286,7 @@ adjwday(struct tm *t, char type, int val, int istext, > int mk) > } > > static int > -adjhour(struct tm *t, char type, int val, int mk) > +adjhour(struct tm *t, char type, long val, int mk) > { > if (val < 0) > return 0; > @@ -331,7 +331,7 @@ adjhour(struct tm *t, char type, int val, int mk) > } > > static int > -adjmin(struct tm *t, char type, int val, int mk) > +adjmin(struct tm *t, char type, long val, int mk) > { > if (val < 0) > return 0; > @@ -372,7 +372,7 @@ adjmin(struct tm *t, char type, int val, int mk) > } > > static int > -adjsec(struct tm *t, char type, int val, int mk) > +adjsec(struct tm *t, char type, long val, int mk) > { > if (val < 0) > return 0; > @@ -419,7 +419,7 @@ vary_apply(const struct vary *v, struct tm *t) > char which; > char *arg; > size_t len; > - int val; > + long val; > > for (; v; v = v->next) { > type = *v->arg; > --0000000000000e782a05ffa0a639 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
This is a nope on armv7 and i386. So it has no effect the= re. DF got it wrong. These should likely be int64_t to avoid the overflow. = No?

Warner

On Mon, Jul 3,= 2023, 9:08 PM Pedro F. Giffuni <pfg@= freebsd.org> wrote:
The bran= ch main has been updated by pfg:

URL: ht= tps://cgit.FreeBSD.org/src/commit/?id=3D4456846a1a0d8cb6d0e6bae89f1134fa0a1= af5cf

commit 4456846a1a0d8cb6d0e6bae89f1134fa0a1af5cf
Author:=C2=A0 =C2=A0 =C2=A0Pedro F. Giffuni <pfg@FreeBSD.org>
AuthorDate: 2023-07-03 02:32:10 +0000
Commit:=C2=A0 =C2=A0 =C2=A0Pedro F. Giffuni <pfg@FreeBSD.org>
CommitDate: 2023-07-04 03:08:01 +0000

=C2=A0 =C2=A0 bin/date: Upgrade calculations

=C2=A0 =C2=A0 Use long instead of int for numerous calculations, fixing a n= umber of
=C2=A0 =C2=A0 date calculation overflow issues.

=C2=A0 =C2=A0 Obtained from:=C2=A0 DragonflyBSD
=C2=A0 =C2=A0 Git log:=C2=A0 =C2=A0 =C2=A0 =C2=A0 4238ce6f0c6df33ce677ae298= b245c62cd60fb43 (only partial)
---
=C2=A0bin/date/vary.c | 20 ++++++++++----------
=C2=A01 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/bin/date/vary.c b/bin/date/vary.c
index 5f0123110ee3..6f3c59950ecf 100644
--- a/bin/date/vary.c
+++ b/bin/date/vary.c
@@ -34,7 +34,7 @@ __FBSDID("$FreeBSD$");
=C2=A0#include "vary.h"

=C2=A0struct trans {
-=C2=A0 int val;
+=C2=A0 long val;
=C2=A0 =C2=A0const char *str;
=C2=A0};

@@ -52,7 +52,7 @@ static struct trans trans_wday[] =3D {
=C2=A0};

=C2=A0static char digits[] =3D "0123456789";
-static int adjhour(struct tm *, char, int, int);
+static int adjhour(struct tm *, char, long, int);

=C2=A0static int
=C2=A0domktime(struct tm *t, char type)
@@ -125,7 +125,7 @@ daysinmonth(const struct tm *t)


=C2=A0static int
-adjyear(struct tm *t, char type, int val, int mk)
+adjyear(struct tm *t, char type, long val, int mk)
=C2=A0{
=C2=A0 =C2=A0switch (type) {
=C2=A0 =C2=A0 =C2=A0case '+':
@@ -146,7 +146,7 @@ adjyear(struct tm *t, char type, int val, int mk)
=C2=A0}

=C2=A0static int
-adjmon(struct tm *t, char type, int val, int istext, int mk)
+adjmon(struct tm *t, char type, long val, int istext, int mk)
=C2=A0{
=C2=A0 =C2=A0int lmdays;

@@ -206,7 +206,7 @@ adjmon(struct tm *t, char type, int val, int istext, in= t mk)
=C2=A0}

=C2=A0static int
-adjday(struct tm *t, char type, int val, int mk)
+adjday(struct tm *t, char type, long val, int mk)
=C2=A0{
=C2=A0 =C2=A0int lmdays;

@@ -250,7 +250,7 @@ adjday(struct tm *t, char type, int val, int mk)
=C2=A0}

=C2=A0static int
-adjwday(struct tm *t, char type, int val, int istext, int mk)
+adjwday(struct tm *t, char type, long val, int istext, int mk)
=C2=A0{
=C2=A0 =C2=A0if (val < 0)
=C2=A0 =C2=A0 =C2=A0return 0;
@@ -286,7 +286,7 @@ adjwday(struct tm *t, char type, int val, int istext, i= nt mk)
=C2=A0}

=C2=A0static int
-adjhour(struct tm *t, char type, int val, int mk)
+adjhour(struct tm *t, char type, long val, int mk)
=C2=A0{
=C2=A0 =C2=A0if (val < 0)
=C2=A0 =C2=A0 =C2=A0return 0;
@@ -331,7 +331,7 @@ adjhour(struct tm *t, char type, int val, int mk)
=C2=A0}

=C2=A0static int
-adjmin(struct tm *t, char type, int val, int mk)
+adjmin(struct tm *t, char type, long val, int mk)
=C2=A0{
=C2=A0 =C2=A0if (val < 0)
=C2=A0 =C2=A0 =C2=A0return 0;
@@ -372,7 +372,7 @@ adjmin(struct tm *t, char type, int val, int mk)
=C2=A0}

=C2=A0static int
-adjsec(struct tm *t, char type, int val, int mk)
+adjsec(struct tm *t, char type, long val, int mk)
=C2=A0{
=C2=A0 =C2=A0if (val < 0)
=C2=A0 =C2=A0 =C2=A0return 0;
@@ -419,7 +419,7 @@ vary_apply(const struct vary *v, struct tm *t)
=C2=A0 =C2=A0char which;
=C2=A0 =C2=A0char *arg;
=C2=A0 =C2=A0size_t len;
-=C2=A0 int val;
+=C2=A0 long val;

=C2=A0 =C2=A0for (; v; v =3D v->next) {
=C2=A0 =C2=A0 =C2=A0type =3D *v->arg;
--0000000000000e782a05ffa0a639--