Subject: bin/36266: sig_atomic_t pedanticism in comsat(8)
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <dholland@eecs.harvard.edu>
List: netbsd-bugs
Date: 05/03/2007 08:05:00
>Number:         36266
>Category:       bin
>Synopsis:       sig_atomic_t pedanticism in comsat(8)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu May 03 08:05:00 +0000 2007
>Originator:     David A. Holland <dholland@eecs.harvard.edu>
>Release:        NetBSD 4.99.16 (20070502)
>Organization:
>Environment:
System: NetBSD merlin 4.99.16 NetBSD 4.99.16 (MERLIN) #61: Fri Mar 23 18:59:15 EDT 2007  dholland@merlin:/usr/src/sys/arch/i386/compile/MERLIN i386
Architecture: i386
Machine: i386
>Description:

All we're allowed to do with volatile sig_atomic_t in a signal handler
is assign it, not read it and write it back. AFAIK.

Fortunately, any value it might be incremented to is unneeded.

Patch against current comsat.c follows. (The first change is not in a
signal handler and thus isn't strictly necessary - but consistency is
good too.)

>How-To-Repeat:
n/a
>Fix:

Index: comsat.c
===================================================================
RCS file: /cvsroot/src/libexec/comsat/comsat.c,v
retrieving revision 1.35
diff -u -r1.35 comsat.c
--- comsat.c	21 Feb 2007 21:06:26 -0000	1.35
+++ comsat.c	3 May 2007 07:56:08 -0000
@@ -136,7 +136,7 @@
 		syslog(LOG_ERR, "sigprocmask get failed (%m)");
 		exit(1);
 	}
-	needupdate++;
+	needupdate = 1;
 	for (;;) {
 		cc = recv(0, msgbuf, sizeof(msgbuf) - 1, 0);
 		if (cc <= 0) {
@@ -167,7 +167,7 @@
 /*ARGSUSED*/
 onalrm(int signo)
 {
-	needupdate++;
+	needupdate = 1;
 }
 
 static void