From owner-svn-src-head@FreeBSD.ORG Wed May 19 08:52:52 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3973C1065672; Wed, 19 May 2010 08:52:52 +0000 (UTC) (envelope-from uqs@FreeBSD.org) Received: from svn.freebsd.org (unknown [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 278358FC08; Wed, 19 May 2010 08:52:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o4J8qpr2023948; Wed, 19 May 2010 08:52:51 GMT (envelope-from uqs@svn.freebsd.org) Received: (from uqs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o4J8qpob023944; Wed, 19 May 2010 08:52:51 GMT (envelope-from uqs@svn.freebsd.org) Message-Id: <201005190852.o4J8qpob023944@svn.freebsd.org> From: Ulrich Spoerlein Date: Wed, 19 May 2010 08:52:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r208289 - head/usr.sbin/apmd X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2010 08:52:52 -0000 Author: uqs Date: Wed May 19 08:52:51 2010 New Revision: 208289 URL: http://svn.freebsd.org/changeset/base/208289 Log: - Fix terminating argument to execl(3), sizeof(NULL) != sizeof(char *) might be true on some systems [1] - Rewrite gotos to use return directly - Some spelling fixes - Reduce unneeded/non-standard Makefile settings Requested by: bde, imp [1] Explanation provided by: bde [1] Reviewed by: imp Modified: head/usr.sbin/apmd/Makefile head/usr.sbin/apmd/README head/usr.sbin/apmd/apmd.c Modified: head/usr.sbin/apmd/Makefile ============================================================================== --- head/usr.sbin/apmd/Makefile Wed May 19 06:49:52 2010 (r208288) +++ head/usr.sbin/apmd/Makefile Wed May 19 08:52:51 2010 (r208289) @@ -10,12 +10,7 @@ WARNS?= 3 DPADD= ${LIBL} LDADD= -ll -YFLAGS+=-v -CFLAGS+=-I. -I${.CURDIR} #-DYY_STACK_USED -# for debug: -#CFLAGS+= -g -DDEBUG - -CLEANFILES= y.output +CFLAGS+= -I${.CURDIR} test: ./apmd -d -f etc/apmd.conf -n Modified: head/usr.sbin/apmd/README ============================================================================== --- head/usr.sbin/apmd/README Wed May 19 06:49:52 2010 (r208288) +++ head/usr.sbin/apmd/README Wed May 19 08:52:51 2010 (r208289) @@ -92,7 +92,7 @@ apm_event SUSPENDREQ { exec "zzz"; } -Will cause apmd to recieve the APM event SUSPENDREQ (which may be +Will cause apmd to receive the APM event SUSPENDREQ (which may be posted by an LCD close), run the sync command 3 times and wait for a while, then execute zzz (apm -z) to put the system in the suspend state. @@ -130,7 +130,7 @@ Other events will not be sent to apmd. 4.3 command line syntax ----------------------- -In the example above, the three lines begining with `exec' are commands +In the example above, the three lines beginning with `exec' are commands for the event. Each line should be terminated with a semicolon. The command list for the event should be enclosed by `{' and `}'. apmd(8) uses /bin/sh for double-quotation enclosed command execution, just as Modified: head/usr.sbin/apmd/apmd.c ============================================================================== --- head/usr.sbin/apmd/apmd.c Wed May 19 06:49:52 2010 (r208288) +++ head/usr.sbin/apmd/apmd.c Wed May 19 08:52:51 2010 (r208289) @@ -115,13 +115,13 @@ event_cmd_exec_act(void *this) switch ((pid = fork())) { case -1: warn("cannot fork"); - goto out; + break; case 0: /* child process */ signal(SIGHUP, SIG_DFL); signal(SIGCHLD, SIG_DFL); signal(SIGTERM, SIG_DFL); - execl(_PATH_BSHELL, "sh", "-c", p->line, NULL); + execl(_PATH_BSHELL, "sh", "-c", p->line, (char *)NULL); _exit(127); default: /* parent process */ @@ -130,7 +130,6 @@ event_cmd_exec_act(void *this) } while (pid == -1 && errno == EINTR); break; } - out: return status; } void @@ -165,19 +164,17 @@ struct event_cmd_op event_cmd_exec_ops = }; /* - * reject commad + * reject command */ int event_cmd_reject_act(void *this __unused) { - int rc = -1; + int rc = 0; if (ioctl(apmctl_fd, APMIO_REJECTLASTREQ, NULL)) { syslog(LOG_NOTICE, "fail to reject\n"); - goto out; + rc = -1; } - rc = 0; - out: return rc; } struct event_cmd_op event_cmd_reject_ops = { @@ -466,7 +463,7 @@ wait_child(void) int proc_signal(int fd) { - int rc = -1; + int rc = 0; int sig; while (read(fd, &sig, sizeof sig) == sizeof sig) { @@ -479,7 +476,7 @@ proc_signal(int fd) case SIGTERM: syslog(LOG_NOTICE, "going down on signal %d", sig); rc = -1; - goto out; + return rc; case SIGCHLD: wait_child(); break; @@ -488,8 +485,6 @@ proc_signal(int fd) break; } } - rc = 0; - out: return rc; } void @@ -630,14 +625,12 @@ event_loop(void) if (FD_ISSET(signal_fd[0], &rfds)) { if (proc_signal(signal_fd[0]) < 0) - goto out; + return; } if (FD_ISSET(apmctl_fd, &rfds)) proc_apmevent(apmctl_fd); } -out: - return; } int