From owner-svn-src-all@freebsd.org Mon Jan 1 22:40:40 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 17CC4E87B64 for ; Mon, 1 Jan 2018 22:40:40 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound1b.ore.mailhop.org (outbound1b.ore.mailhop.org [54.200.247.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EB29F1E7A for ; Mon, 1 Jan 2018 22:40:39 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-User: bcd6abae-ef44-11e7-8486-0934409070aa X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 73.78.92.27 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [73.78.92.27]) by outbound1.ore.mailhop.org (Halon) with ESMTPSA id bcd6abae-ef44-11e7-8486-0934409070aa; Mon, 01 Jan 2018 22:40:16 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id w01MeURK011136; Mon, 1 Jan 2018 15:40:30 -0700 (MST) (envelope-from ian@freebsd.org) Message-ID: <1514846430.12000.44.camel@freebsd.org> Subject: Re: svn commit: r327476 - head/sbin/shutdown From: Ian Lepore To: Eitan Adler , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Date: Mon, 01 Jan 2018 15:40:30 -0700 In-Reply-To: <201801012233.w01MXvXw087382@repo.freebsd.org> References: <201801012233.w01MXvXw087382@repo.freebsd.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.1 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jan 2018 22:40:40 -0000 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? -- Ian