From adamw@holonet.net Fri Jul 16 02:33:31 1999
Return-Path: <adamw@holonet.net>
Received: from holonet.net (giskard.holonet.net [198.207.169.7])
	by hub.freebsd.org (Postfix) with ESMTP id 9EAC814C9F
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 16 Jul 1999 02:33:29 -0700 (PDT)
	(envelope-from adamw@holonet.net)
Received: from  (adamw@localhost) by holonet.net (Adam Wight)
	id CAA01048; Fri, 16 Jul 1999 02:31:50 -0700
Message-Id: <199907160931.CAA01048@holonet.net>
Date: Fri, 16 Jul 99 2:31:49 PDT
From: Adam Wight <adamw@holonet.net>
Reply-To: adamw@holonet.net
To: FreeBSD-gnats-submit@freebsd.org
Subject: Ambiguous if statement.
X-Send-Pr-Version: 3.2

>Number:         12663
>Category:       kern
>Synopsis:       Ambiguous if statement
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jul 16 02:40:01 PDT 1999
>Closed-Date:    Thu Jul 22 07:46:44 PDT 1999
>Last-Modified:  Thu Jul 22 07:49:17 PDT 1999
>Originator:     Adam Wight
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
>Environment:
    all

>Description:
    The file sys/i386/apm/apm.c contains an ambiguous if...else statement
    that appears to be parsed correctly by the compiler, but could break
    silently depending on the compiler release.

>How-To-Repeat:

>Fix:

Sorry, you might have to use patch -l...

===================================================================
RCS file: /usr/cvs/src/sys/i386/apm/apm.c,v
retrieving revision 1.90
diff -c -r1.90 apm.c
*** apm.c   1999/07/10 18:08:48 1.90
--- apm.c   1999/07/13 17:45:38
***************  
*** 1283,1293 ****
    struct apm_softc *sc = &apm_softc;
    int revents = 0;

!   if (events & (POLLIN | POLLRDNORM))
!       if (sc->event_count)
            revents |= events & (POLLIN | POLLRDNORM);
!       else 
            selrecord(p, &sc->sc_rsel);

    return (revents);
  }  
--- 1283,1295 ----
    struct apm_softc *sc = &apm_softc;
    int revents = 0;

!   if (events & (POLLIN | POLLRDNORM)) {
!       if (sc->event_count) {
            revents |= events & (POLLIN | POLLRDNORM);
!       } else {
            selrecord(p, &sc->sc_rsel);
+       }
+   }

    return (revents);
  }


>Release-Note:
>Audit-Trail:

From: Nate Williams <nate@mt.sri.com>
To: adamw@holonet.net
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: kern/12663: Ambiguous if statement.
Date: Fri, 16 Jul 1999 09:22:19 -0600

 Adam Wight writes:
 > 
 > >Number:         12663
 > >Category:       kern
 > >Synopsis:       Ambiguous if statement
 > >Confidential:   no
 > >Severity:       non-critical
 > >Priority:       low
 > >Responsible:    freebsd-bugs
 > >State:          open
 > >Quarter:        
 > >Keywords:       
 > >Date-Required:
 > >Class:          change-request
 > >Submitter-Id:   current-users
 > >Arrival-Date:   Fri Jul 16 02:40:01 PDT 1999
 > >Closed-Date:
 > >Last-Modified:
 > >Originator:     Adam Wight
 > >Release:        FreeBSD 4.0-CURRENT i386
 > >Organization:
 > >Environment:
 >     all
 > 
 > >Description:
 >     The file sys/i386/apm/apm.c contains an ambiguous if...else statement
 >     that appears to be parsed correctly by the compiler, but could break
 >     silently depending on the compiler release.
 
 No, they could not break silently, as the syntax is guaranteed to be
 correct by the ANSI-C standard.  If it broke, the compiler would be
 broke and a number of other such code in many systems would also break.
 
 
 Nate
 

From: Mitsuru IWASAKI <iwasaki@hitachi-to.co.jp>
To: Nate Williams <nate@mt.sri.com>
Cc: freebsd-gnats-submit@freebsd.org, adamw@holonet.net
Subject: Re: kern/12663: Ambiguous if statement
Date: Wed, 21 Jul 1999 13:40:00 +0900

 Nate Williams writes:
 > No, they could not break silently, as the syntax is guaranteed to be
 > correct by the ANSI-C standard.  If it broke, the compiler would be
 > broke and a number of other such code in many systems would also break.
 
 You might be right, Nate.  But I forgot to fix it up when I ported 
 the code from NetBSD's one. Also I like a lot the style as Mr. Adam Wight 
 pointed out because It is preventible from missing { and } when few more 
 lines are needed in the block afterward.
 
 Thank you Adam and Nate, I'll fix it soon if there is no objections.
 
State-Changed-From-To: open->closed 
State-Changed-By: iwasaki 
State-Changed-When: Thu Jul 22 07:46:44 PDT 1999 
State-Changed-Why:  
Fixed.  Thanks! 
>Unformatted:
