Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Jan 2018 15:05:16 -0800
From:      Eitan Adler <eadler@freebsd.org>
To:        Ian Lepore <ian@freebsd.org>
Cc:        "src-committers@freebsd.org" <src-committers@freebsd.org>,  "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>,  "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>
Subject:   Re: svn commit: r327476 - head/sbin/shutdown
Message-ID:  <CAF6rxg=qtm5vKX=JwJja=L_sVV4gE8jy641WA4dFjx=w_c47aQ@mail.gmail.com>
In-Reply-To: <1514846430.12000.44.camel@freebsd.org>
References:  <201801012233.w01MXvXw087382@repo.freebsd.org> <1514846430.12000.44.camel@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Monday, 1 January 2018, Ian Lepore <ian@freebsd.org> wrote:

> On Mon, 2018-01-01 at 22:33 +0000, Eitan Adler wrote:
> > Author: eadler
> > Date: Mon Jan  1 22:33:57 2018
> > New Revision: 327476
> > URL: https://svnweb.freebsd.org/changeset/base/327476
> >
> > Log:
> >   shutdown: Assume absolute time is in the future
> >
> [...]
> > Modified: head/sbin/shutdown/shutdown.c
> > ============================================================
> ==================
> > --- head/sbin/shutdown/shutdown.c     Mon Jan  1 22:31:52 2018
> (r327475)
> > +++ head/sbin/shutdown/shutdown.c     Mon Jan  1 22:33:57 2018
> (r327476)
> > @@ -431,7 +431,7 @@ getoffset(char *timearg)
> >       struct tm *lt;
> >       char *p;
> >       time_t now;
> > -     int this_year;
> > +     int this_year, maybe_today;
> >       char *timeunit;
> >
> >       (void)time(&now);
> > @@ -503,6 +503,7 @@ getoffset(char *timearg)
> >                       badtime();
> >               /* FALLTHROUGH */
> >       case 6:
> > +             maybe_today = 0;
> >               lt->tm_mday = ATOI2(timearg);
> >               if (lt->tm_mday < 1 || lt->tm_mday > 31)
> >                       badtime();
> > @@ -517,8 +518,23 @@ getoffset(char *timearg)
> >               lt->tm_sec = 0;
> >               if ((shuttime = mktime(lt)) == -1)
> >                       badtime();
> > -             if ((offset = shuttime - now) < 0)
> > -                     errx(1, "that time is already past.");
> > +
> > +             if ((offset = shuttime - now) < 0) {
> > +                     if (!maybe_today)
> > +                             errx(1, "that time is already past.");
> > +
> > +                     /*
> > +                      * If the user only gave a time, assume that
> > +                      * any time earlier than the current time
> > +                      * was intended to be that time tomorrow.
> > +                      */
> > +                     lt->tm_mday++;
> > +                     if ((shuttime = mktime(lt)) == -1)
> > +                             badtime();
> > +                     if ((offset = shuttime - now) < 0) {
> > +                             errx(1, "tomorrow is before today?");
> > +                     }
> > +             }
> >               break;
> >       default:
> >               badtime();
> >
>
> Where does maybe_today ever get set to non-zero?


Baah. This is what happens when my build/test and commit box are not the
same. Will fix later when I get back home.

>
> -- Ian
>


-- 
Sent from my Turing Machine



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAF6rxg=qtm5vKX=JwJja=L_sVV4gE8jy641WA4dFjx=w_c47aQ>