NetBSD Problem Report #41919
From mouse@Sparkle.Rodents-Montreal.ORG Sat Aug 22 22:00:27 2009
Return-Path: <mouse@Sparkle.Rodents-Montreal.ORG>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by www.NetBSD.org (Postfix) with ESMTP id 66EC863C2A8
for <gnats-bugs@gnats.NetBSD.org>; Sat, 22 Aug 2009 22:00:27 +0000 (UTC)
Message-Id: <200908222200.SAA11237@Sparkle.Rodents-Montreal.ORG>
Date: Sat, 22 Aug 2009 17:58:16 -0400 (EDT)
From: der Mouse <mouse@Rodents-Montreal.ORG>
Reply-To: mouse@Rodents-Montreal.ORG
To: gnats-bugs@gnats.NetBSD.org
Subject: [dM] S_IS*() insufficiently parenthesized
X-Send-Pr-Version: 3.95
>Number: 41919
>Category: lib
>Synopsis: [dM] S_IS*() insufficiently parenthesized
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: lib-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Aug 22 22:05:00 +0000 2009
>Closed-Date: Fri Dec 18 06:14:39 +0000 2009
>Last-Modified: Fri Dec 18 06:15:02 +0000 2009
>Originator: der Mouse
>Release: NetBSD 4.0.1
>Organization:
Dis-
>Environment:
System: NetBSD Laptop-401.Rodents-Montreal.ORG 4.0.1 NetBSD 4.0.1 (GEN401_WD0F) #0: Mon Jul 20 23:52:41 EDT 2009 mouse@Laptop-401.Rodents-Montreal.ORG:/home/mouse/kbuild/GEN401_WD0F i386
Architecture: i386
Machine: i386
>Description:
The S_ISDIR(), S_ISCHR(), etc, macros in <sys/stat.h> are
insufficiently parenthesized, leading to breakage when the
argument is of the form xxx|yyy. (This is not a hypothetical
usage case; I tripped over it trying to build some third-party
code.)
>How-To-Repeat:
Compile code using such an argument, as in
#include <sys/stat.h>
int foo(int x)
{
return(S_ISREG(x|0644)?2:3);
}
and observe it doesn't behave the way it should. Or, compile
with -Wall and get a "suggest parentheses around arithmetic in
operand of |" warning.
>Fix:
Add parens.
Diff relative to stat.h,v 1.54 (4.0.1's stat.h, it being 4.0.1
I tripped over this on); other versions' <sys/stat.h>s need
similar changes, but this diff may not apply painlessly.
--- OLD/stat.h 2006-02-24 17:01:30.000000000 -0500
+++ NEW/stat.h 2009-08-22 17:53:01.000000000 -0400
@@ -168,21 +168,21 @@
#define S_ARCH2 _S_ARCH2
#endif
-#define S_ISDIR(m) ((m & _S_IFMT) == _S_IFDIR) /* directory */
-#define S_ISCHR(m) ((m & _S_IFMT) == _S_IFCHR) /* char special */
-#define S_ISBLK(m) ((m & _S_IFMT) == _S_IFBLK) /* block special */
-#define S_ISREG(m) ((m & _S_IFMT) == _S_IFREG) /* regular file */
-#define S_ISFIFO(m) ((m & _S_IFMT) == _S_IFIFO) /* fifo */
+#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) /* directory */
+#define S_ISCHR(m) (((m) & _S_IFMT) == _S_IFCHR) /* char special */
+#define S_ISBLK(m) (((m) & _S_IFMT) == _S_IFBLK) /* block special */
+#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) /* regular file */
+#define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO) /* fifo */
#if ((_POSIX_C_SOURCE - 0) >= 200112L) || defined(_XOPEN_SOURCE) || \
defined(_NETBSD_SOURCE)
-#define S_ISLNK(m) ((m & _S_IFMT) == _S_IFLNK) /* symbolic link */
+#define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK) /* symbolic link */
#endif
#if ((_POSIX_C_SOURCE - 0) >= 200112L) || ((_XOPEN_SOURCE - 0) >= 600) || \
defined(_NETBSD_SOURCE)
-#define S_ISSOCK(m) ((m & _S_IFMT) == _S_IFSOCK) /* socket */
+#define S_ISSOCK(m) (((m) & _S_IFMT) == _S_IFSOCK) /* socket */
#endif
#if defined(_NETBSD_SOURCE)
-#define S_ISWHT(m) ((m & _S_IFMT) == _S_IFWHT) /* whiteout */
+#define S_ISWHT(m) (((m) & _S_IFMT) == _S_IFWHT) /* whiteout */
#endif
#if defined(_NETBSD_SOURCE)
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse@rodents-montreal.org
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
>Release-Note:
>Audit-Trail:
From: der Mouse <mouse@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/41919 CVS commit: src/sys/sys
Date: Thu, 27 Aug 2009 07:28:42 +0000
Module Name: src
Committed By: mouse
Date: Thu Aug 27 07:28:42 UTC 2009
Modified Files:
src/sys/sys: stat.h
Log Message:
Parenthesize S_IS*() macro arguments to prevent breakage with certain
arguments - see PR 41919. Approved by dholland.
To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/sys/stat.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: mouse@NetBSD.org
State-Changed-When: Thu, 27 Aug 2009 07:49:27 +0000
State-Changed-Why:
Patch applied.
From: jnemeth@victoria.tc.ca (John Nemeth)
To: gnats-bugs@NetBSD.org, lib-bug-people@NetBSD.org, netbsd-bugs@NetBSD.org,
gnats-admin@NetBSD.org, mouse@NetBSD.org, mouse@Rodents-Montreal.ORG
Cc:
Subject: Re: lib/41919 ([dM] S_IS*() insufficiently parenthesized)
Date: Thu, 27 Aug 2009 03:15:16 -0700
On Dec 12, 7:56pm, mouse@NetBSD.org wrote:
}
} Synopsis: [dM] S_IS*() insufficiently parenthesized
}
} State-Changed-From-To: open->closed
} State-Changed-By: mouse@NetBSD.org
} State-Changed-When: Thu, 27 Aug 2009 07:49:27 +0000
} State-Changed-Why:
} Patch applied.
This should probably be pulled up. See
http://www.netbsd.org/developers/releng/pullups.html for instructions.
The PR should be placed in the pending-pullups state when the pullups
have been submitted and place the pullup numbers in the comment. See
http://www.netbsd.org/developers/PR.html for more information.
}-- End of excerpt from mouse@NetBSD.org
State-Changed-From-To: closed->suspended
State-Changed-By: mouse@NetBSD.org
State-Changed-When: Thu, 27 Aug 2009 14:43:29 +0000
State-Changed-Why:
Shouldn't've closed; suspending pending resolution of the pullups question.
.
State-Changed-From-To: suspended->pending-pullups
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Mon, 14 Dec 2009 06:53:36 +0000
State-Changed-Why:
pullup-5 #1196, pullup-4 #1371
From: Stephen Borrill <sborrill@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/41919 CVS commit: [netbsd-4] src/sys/sys
Date: Wed, 16 Dec 2009 11:17:40 +0000
Module Name: src
Committed By: sborrill
Date: Wed Dec 16 11:17:40 UTC 2009
Modified Files:
src/sys/sys [netbsd-4]: stat.h
Log Message:
Pull up the following revisions(s) (requested by dholland in ticket #1371):
sys/sys/stat.h: revision 1.59
Parenthesize S_IS*() macro arguments to prevent breakage with certain
arguments. Addresses PR/41919.
To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.54.18.1 src/sys/sys/stat.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: pending-pullups->closed
State-Changed-By: snj@NetBSD.org
State-Changed-When: Fri, 18 Dec 2009 06:14:39 +0000
State-Changed-Why:
Pullups complete.
From: Soren Jacobsen <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/41919 CVS commit: [netbsd-5] src/sys/sys
Date: Fri, 18 Dec 2009 06:12:51 +0000
Module Name: src
Committed By: snj
Date: Fri Dec 18 06:12:51 UTC 2009
Modified Files:
src/sys/sys [netbsd-5]: stat.h
Log Message:
Pull up following revision(s) (requested by dholland in ticket #1196):
sys/sys/stat.h: revision 1.59
Parenthesize S_IS*() macro arguments to prevent breakage with certain
arguments - see PR 41919. Approved by dholland.
To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.57.4.1 src/sys/sys/stat.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
UTSLing makes me think this applies to everything from 1.4T
through -current as well.
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.