From nobody Tue Jul 04 03:34:07 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 4Qw7gm58Msz4lcYD for ; Tue, 4 Jul 2023 03:34:12 +0000 (UTC) (envelope-from pfg@freebsd.org) Received: from sonic309-22.consmr.mail.ne1.yahoo.com (sonic309-22.consmr.mail.ne1.yahoo.com [66.163.184.148]) (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 did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Qw7gl3l9Mz462F for ; Tue, 4 Jul 2023 03:34:11 +0000 (UTC) (envelope-from pfg@freebsd.org) Authentication-Results: mx1.freebsd.org; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1688441649; bh=Bfch/qpSy6a55HjicdTtlt9hnuoEUricyyDSWSLNvKM=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From:Subject:Reply-To; b=tHqTvDcMIhiKL2P3QgSyf9iChctnZt/4gp0x1tlLEVZOvSU2MlraBu4jTfbF1RuNA+3pyxTOwkBhFnxhxub09jobWJj+bNVWJmZTYP4JCkM9Cy8TmGMNFLzfeCZ7TeeuExQdQMqNXFByid40mhqwi1hngBYQcdhl9EGVqQPUfWbPkro1gprci2iHMY8lP/+uoi+D8UYoRzCbG09jE5hTeoEHP9Xm73B718epxfa4DtK/csB+oq0Z1SigHgNjN8tQc0NPGNSATUoRN25w9ger2NKjLZ4ZGfOAJ/z02BE3cETQ4UhwMMIqlCuzx9fSYMX0GkC1HOjPK88JwFmZbx193Q== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1688441649; bh=uSvWQ3SSCmogsKXUfyJoEmk6YuHMJXrews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WqVvJOyiSUeW5zeVjr7m9NIJaRJZJd8fuk37fCtQ6WFfhePT.im5QP8biwXM L3jLJg7TOm0MpojkZVjd40fc4tYJit8pLYq9sEKHW_urdPeuWOL_wSWACLtPb4IRHxPnEhs_hhIJ JXU_qRi1RMTMsDoMrcK2ExOCo2hZvLAYCKlbgOuFBGiERo.CTcs3lwAXhG36mHb0m1rX7dCGBNxj 3.n0mya.xxfB8nJMpPJ8XHjbh1_..dEiOT.PzEAr.CptULm9B0eUawtYOlcwAfQ3RrjbGknSiG5S DNgMAKf4_VC5XsYXIYoMLy.SWH.cvwJWjKdatxA4kjMMBhpStttfk..Qt4k29560g0KbICqBbgud ch4uEnOlOJ_AnhzzQe7zDwGK1jdJsztVXDxHvAzQsbck_viXqnU.GwdBFWYY0qLV2zj2SdTmB2U4 IfClET6yH0M.poKYoj4AmAAtTSEPyuDL52Uhyy11ztAMgVqJPxRZD6y0N_ujHCco- X-Sonic-MF: X-Sonic-ID: c5c7a821-e95c-4216-8e70-c1654a75482f Received: from sonic.gate.mail.ne1.yahoo.com by sonic309.consmr.mail.ne1.yahoo.com with HTTP; Tue, 4 Jul 2023 03:34:09 +0000 Date: Tue, 4 Jul 2023 03:34:07 +0000 (UTC) From: Pedro Giffuni To: Warner Losh Cc: src-committers , "" , "" Message-ID: <1037448433.54513.1688441647903@mail.yahoo.com> In-Reply-To: References: <202307040308.36438MTA093771@gitrepo.freebsd.org> Subject: Re: git: 4456846a1a0d - main - bin/date: Upgrade calculations 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 Content-Type: multipart/alternative; boundary="----=_Part_54512_580997230.1688441647901" X-Mailer: WebService/1.1.21612 YMailNorrin X-Rspamd-Queue-Id: 4Qw7gl3l9Mz462F X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:36646, ipnet:66.163.184.0/21, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N ------=_Part_54512_580997230.1688441647901 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hmm ... Dragonfly has no armv7 or i386, so they didn't get it too wrong.I guess=C2= =A0the int64_t would be a quick fix or another option, which I was considei= rng, was to look at unsigning it but taking care of the edge cases ... I wa= s too lazy for that. Please go ahead and do the quick fix ;) Pedro. On Monday, July 3, 2023 at 10:12:13 PM GMT-5, Warner Losh wrote: =20 =20 This is a nope on armv7 and i386. So it has no effect there. DF got it wro= ng. 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=3D4456846a1a0d8cb6d0e6bae89f11= 34fa0a1af5cf commit 4456846a1a0d8cb6d0e6bae89f1134fa0a1af5cf Author:=C2=A0 =C2=A0 =C2=A0Pedro F. Giffuni AuthorDate: 2023-07-03 02:32:10 +0000 Commit:=C2=A0 =C2=A0 =C2=A0Pedro F. Giffuni 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; =20 ------=_Part_54512_580997230.1688441647901 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit
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 ;)

Pedro.

On Monday, July 3, 2023 at 10:12:13 PM GMT-5, Warner Losh <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=4456846a1a0d8cb6d0e6bae89f1134fa0a1af5cf

commit 4456846a1a0d8cb6d0e6bae89f1134fa0a1af5cf
Author:     Pedro F. Giffuni <pfg@FreeBSD.org>
AuthorDate: 2023-07-03 02:32:10 +0000
Commit:     Pedro F. Giffuni <pfg@FreeBSD.org>
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;
------=_Part_54512_580997230.1688441647901--