Date: Tue, 4 Jul 2023 04:17:23 +0100 From: Jessica Clarke <jrtc27@freebsd.org> To: Warner Losh <imp@bsdimp.com> Cc: "Pedro F. Giffuni" <pfg@freebsd.org>, src-committers <src-committers@freebsd.org>, "<dev-commits-src-all@freebsd.org>" <dev-commits-src-all@freebsd.org>, "<dev-commits-src-main@freebsd.org>" <dev-commits-src-main@freebsd.org> Subject: Re: git: 4456846a1a0d - main - bin/date: Upgrade calculations Message-ID: <203AA4D5-CA21-4716-BF11-09DD20101538@freebsd.org> In-Reply-To: <CANCZdfqMvf1QuS=fNQjRPe3YUbp1zPQW4aorh=VTRHk%2Bf_e8qg@mail.gmail.com> References: <202307040308.36438MTA093771@gitrepo.freebsd.org> <CANCZdfqMvf1QuS=fNQjRPe3YUbp1zPQW4aorh=VTRHk%2Bf_e8qg@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 4 Jul 2023, at 04:11, Warner Losh <imp@bsdimp.com> wrote: >=20 > 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? Quite. Obviously DragonFly can ignore the issue because it=E2=80=99s amd64-only... but still a bit unnecessarily non-portable. Jess > On Mon, Jul 3, 2023, 9:08 PM Pedro F. Giffuni <pfg@freebsd.org> wrote: > The branch main has been updated by pfg: >=20 > URL: = https://cgit.FreeBSD.org/src/commit/?id=3D4456846a1a0d8cb6d0e6bae89f1134fa= 0a1af5cf >=20 > 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 >=20 > bin/date: Upgrade calculations >=20 > Use long instead of int for numerous calculations, fixing a number = of > date calculation overflow issues. >=20 > Obtained from: DragonflyBSD > Git log: 4238ce6f0c6df33ce677ae298b245c62cd60fb43 (only = partial) > --- > bin/date/vary.c | 20 ++++++++++---------- > 1 file changed, 10 insertions(+), 10 deletions(-) >=20 > 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" >=20 > struct trans { > - int val; > + long val; > const char *str; > }; >=20 > @@ -52,7 +52,7 @@ static struct trans trans_wday[] =3D { > }; >=20 > static char digits[] =3D "0123456789"; > -static int adjhour(struct tm *, char, int, int); > +static int adjhour(struct tm *, char, long, int); >=20 > static int > domktime(struct tm *t, char type) > @@ -125,7 +125,7 @@ daysinmonth(const struct tm *t) >=20 >=20 > 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) > } >=20 > 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; >=20 > @@ -206,7 +206,7 @@ adjmon(struct tm *t, char type, int val, int = istext, int mk) > } >=20 > static int > -adjday(struct tm *t, char type, int val, int mk) > +adjday(struct tm *t, char type, long val, int mk) > { > int lmdays; >=20 > @@ -250,7 +250,7 @@ adjday(struct tm *t, char type, int val, int mk) > } >=20 > 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) > } >=20 > 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) > } >=20 > 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) > } >=20 > 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; >=20 > for (; v; v =3D v->next) { > type =3D *v->arg;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?203AA4D5-CA21-4716-BF11-09DD20101538>