*BSD News Article 34854


Return to BSD News archive

Newsgroups: comp.os.386bsd.bugs
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!munnari.oz.au!news.Hawaii.Edu!ames!pacbell.com!ihnp4.ucsd.edu!agate!howland.reston.ans.net!math.ohio-state.edu!jussieu.fr!univ-lyon1.fr!swidir.switch.ch!scsing.switch.ch!news.dfn.de!news.belwue.de!delos.stgt.sub.org!guru.stgt.sub.org!nils
From: nils@guru.stgt.sub.org (Cornelis van der Laan)
Subject: Re: FreeBSD 1.1.5 -- Bug in /usr/bin/leave
Reply-To: nils@ims.uni-stuttgart.de
Sender: news@guru.stgt.sub.org (News pseudo-user)
Nntp-Posting-Host: localhost.ims.uni-stuttgart.de
Organization: Mehr Anarchie !
Message-ID: <NILS.94Aug16025340@guru.stgt.sub.org>
References: <NILS.94Aug14230659@guru.stgt.sub.org> <1994Aug15.034212.20767@cs.brown.edu>
In-Reply-To: mhw@cs.brown.edu's message of Mon, 15 Aug 1994 03:42:12 GMT
Date: Tue, 16 Aug 1994 00:53:39 GMT
Lines: 40

In article <1994Aug15.034212.20767@cs.brown.edu> mhw@cs.brown.edu (Mark Weaver) writes:

> Your fix doesn't change the program at all.  In C, "&&" has a higher
> precedence than "||", and both have a lower precedence than the
> comparison operators.  I don't know why you thought this changed
> anything, but I'm sure it didn't.

You're right, of course. My patch was reversed by some strange
mistake. The error in the code is that && has higher precedence over
all the preceding || expressions, which it shouldn't have. 

(But you're wrong too: my patch would have changed the program.
At 22:30 setting an alarm at 23:15 would have given you an error.)

Sorry for the inconvenience. The right patch must read like this:

*** leave.c     Tue Aug 16 02:45:30 1994
--- leave.c.orig        Tue Aug 16 02:45:11 1994
***************
*** 97,103 ****
                secs = hours * 60 * 60 + minutes * 60;
        else {
                if (hours > 23 || t->tm_hour > hours ||
!                   (t->tm_hour == hours && minutes <= t->tm_min))
                        usage();
                secs = (hours - t->tm_hour) * 60 * 60;
                secs += (minutes - t->tm_min) * 60;
--- 97,103 ----
                secs = hours * 60 * 60 + minutes * 60;
        else {
                if (hours > 23 || t->tm_hour > hours ||
!                   t->tm_hour == hours && minutes <= t->tm_min)
                        usage();
                secs = (hours - t->tm_hour) * 60 * 60;
                secs += (minutes - t->tm_min) * 60;
--
----------------------------------------------------------------
Cornelis van der Laan -- nils@ims.uni-stuttgart.de
                      -- nils@guru.stgt.sub.org
# echo Knusper Knusper Knaeuschen > /etc/nologin