NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: unable to set time very far in the future



David Brownlee <abs%absd.org@localhost> wrote:

> > RVP <rvp%SDF.ORG@localhost> wrote:

> > > There is a check in the kernel. In sys/kern/kern_time.c:
> > >
> > >     190         /*
> > >     191          * The time being set to an unreasonable value will cause
> > >     192          * unreasonable system behaviour.
> > >     193          */
> > >     194         if (ts->tv_sec < 0 || ts->tv_sec > (1LL << 36))
> > >     195                 return EINVAL;

> Absent any functional change, could we factor this out to a #define
> for future code spelunkers?

Possibly as attached?

("KTIME_SEC_MAX" is the name Linux uses in
https://elixir.bootlin.com/linux/v6.0.2/source/include/linux/time64.h#L33,
although that's a different value.)

-Jan
Index: kern_time.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_time.c,v
retrieving revision 1.217
diff -r1.217 kern_time.c
98a99,101
> /* XXX: how did we pick this value? */
> #define KTIME_SEC_MAX (1LL << 36)
> 
194c197
< 	if (ts->tv_sec < 0 || ts->tv_sec > (1LL << 36))
---
> 	if (ts->tv_sec < 0 || ts->tv_sec > KTIME_SEC_MAX)


Home | Main Index | Thread Index | Old Index