From nobody Tue Jul 04 04:00:34 2023 X-Original-To: dev-commits-src-all@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 4Qw8GV2rCfz4lpGR for ; Tue, 4 Jul 2023 04:00:50 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) (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 4Qw8GV1R9cz4FPS for ; Tue, 4 Jul 2023 04:00:50 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2b6a0d91e80so82645021fa.3 for ; Mon, 03 Jul 2023 21:00:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20221208.gappssmtp.com; s=20221208; t=1688443247; x=1691035247; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=abTrg2YC73mkzIf50yIvs/bldISrMmzLuOmj3GQMgXc=; b=dhRge76lx8zKYrq4JE2+Fn1muKcgBJAggrp3YaciR8qi4ZJMJIKfcRo89aqTQtWWq+ ymXcmia1veAuFCn5WTdOioBLMLR5MI/4TiRZ4fLZrKCsazunCtoz1He/noSgFCYB1Pd0 LxMOj+7TH6XGCP1bZxM4V6SMygootR2X9ggnu0Yl7p2a6fQuDFVdSI8bLoMSpUo5L9bt 2lNmZn536ww4YBODF+0DsSZT9qgCkTzsdveWFoWDUH4SyOFUFsUMAl2oXK2xrszBD7kv liSExJcxSlUbf0+/0XwLM9KtTURiJ+9xBbmmF+BD07Cij4A72C517DcuCxvkt0BIS6Gz z7Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688443247; x=1691035247; 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=abTrg2YC73mkzIf50yIvs/bldISrMmzLuOmj3GQMgXc=; b=lzTqjF/O2D5QVyiRJefZq022DZbdmV8eXz61BWwu4insF3InvhePxf84MlwTViGx6Y nY7U/6J1OAl2IiQyMNAsWWSqtktHS2Ah2fGJ0e1gkDujPQYAEU7ODtbuP0yl9edf1bga LlBGLnmlGW+p12Xy6enNHDpnQrpTn3D2s9PNOlU4mjQrGf0DksvunQAIiukEbO3Qz5ym mPzYOK3vlCrRl9gYaxZ2zRchqB96w7wMf6i48Q59FSj0JTABuRcKl3EWzPsqDqZzxDrR AfWNNJYekH7SsE6cL7I1JD32y+5D14ZVIEcBw/MFm1FM2qAvGPMS/Yjc43/Xh5J7OujI X2og== X-Gm-Message-State: ABy/qLaZbbR1nT7KhFBrUKJynftyERaoZbJxP/sWl6tfG0IT3mwGZvV/ kISSG4XwNrBZFgvco3O1TDTC67a5RnCR34Nxr4jb2Q== X-Google-Smtp-Source: APBJJlHT4AxgM/FTL7y4jtXmMpjSqARatQF/Esos03FbkmetaoWm1QG8c8XfU1fPhPCPxNMsoqKXFuTlg7xcn24C9dc= X-Received: by 2002:a2e:8e8a:0:b0:2b4:5cad:f246 with SMTP id z10-20020a2e8e8a000000b002b45cadf246mr8479740ljk.7.1688443246105; Mon, 03 Jul 2023 21:00:46 -0700 (PDT) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 References: <202307040308.36438MTA093771@gitrepo.freebsd.org> <1037448433.54513.1688441647903@mail.yahoo.com> In-Reply-To: <1037448433.54513.1688441647903@mail.yahoo.com> From: Warner Losh Date: Mon, 3 Jul 2023 22:00:34 -0600 Message-ID: Subject: Re: git: 4456846a1a0d - main - bin/date: Upgrade calculations To: Pedro Giffuni Cc: src-committers , "" , "" Content-Type: multipart/alternative; boundary="000000000000e86aeb05ffa1535c" X-Rspamd-Queue-Id: 4Qw8GV1R9cz4FPS 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 --000000000000e86aeb05ffa1535c Content-Type: text/plain; charset="UTF-8" On Mon, Jul 3, 2023, 9:34 PM Pedro Giffuni wrote: > Hmm ... > > Dragonfly has no armv7 or i386, so they didn't get it too wrong. > I guess the int64_t would be a quick fix or another option, which I was > consideirng, was to look at unsigning it but taking care of the edge cases > ... I was too lazy for that. > > Please go ahead and do the quick fix ;) > What makes you say it's a quick fix? If the calculations need 64 bits, int64_t is the proper data type. How is that analysis wrong? Also, it's tradition that you should fix it... Warner > Pedro. > > On Monday, July 3, 2023 at 10:12:13 PM GMT-5, Warner Losh > wrote: > > > 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; > > --000000000000e86aeb05ffa1535c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Mon, Jul 3, 2023, 9:34 PM Pedro Giffuni <pfg@freebsd.org> wrote:
Hmm ...

Dragonfly has no armv7 or i386, so they didn't get it too wron= g.
I guess=C2=A0the = int64_t would be a quick fix or another option, which I was c= onsideirng, was to look at unsigning it but taking care of the edge cases .= .. I was too lazy for that.

Please go = ahead and do the quick fix ;)

What makes you say it's a qu= ick fix? If the calculations need 64 bits, int64_t is the proper data type.= How is that analysis wrong?

Also, it's tradition that you should fix it...

Warner


Pedro.

=20
=20
On Monday, July 3, 2023 at 10:12:13 PM GMT-5, Warner Lo= sh <imp@bsdimp.com> wrote:


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 <pfg@freebsd.org> wrote:
The = branch main has been updated by pfg:

URL: https://cgit.FreeBSD.org/src/commit/?id=3D4456846a1a0d8cb6d0e6b= ae89f1134fa0a1af5cf

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;
--000000000000e86aeb05ffa1535c--