Author: uqs
Date: Fri May 14 14:26:56 2010
New Revision: 208075
URL: http://svn.freebsd.org/changeset/base/208075

Log:
  Sync apmd(8) with DragonflyBSD, bringing WARNS to 3
  
  Reviewed by:  ed (partial, long time ago)

Modified:
  head/usr.sbin/apmd/Makefile
  head/usr.sbin/apmd/apmd.8
  head/usr.sbin/apmd/apmd.c
  head/usr.sbin/apmd/apmd.h
  head/usr.sbin/apmd/apmdlex.l
  head/usr.sbin/apmd/contrib/pccardq.c

Modified: head/usr.sbin/apmd/Makefile
==============================================================================
--- head/usr.sbin/apmd/Makefile Fri May 14 14:26:49 2010        (r208074)
+++ head/usr.sbin/apmd/Makefile Fri May 14 14:26:56 2010        (r208075)
@@ -5,7 +5,7 @@ MAN=    apmd.8
 MANSUBDIR= /i386
 SRCS=  apmd.c apmdlex.l apmdparse.y y.tab.h
 
-WARNS?=        0
+WARNS?=        3
 
 DPADD= ${LIBL}
 LDADD= -ll

Modified: head/usr.sbin/apmd/apmd.8
==============================================================================
--- head/usr.sbin/apmd/apmd.8   Fri May 14 14:26:49 2010        (r208074)
+++ head/usr.sbin/apmd/apmd.8   Fri May 14 14:26:56 2010        (r208075)
@@ -99,7 +99,9 @@ monitored events.
 .Pp
 If the
 .Nm
-process receives a SIGHUP, it will reread its configuration file and
+process receives a
+.Dv SIGHUP ,
+it will reread its configuration file and
 notify the APM device driver of any changes to its configuration.
 .Pp
 The
@@ -166,7 +168,7 @@ The apm_event keyword
 .Bd -ragged -offset indent
 .Ql apm_event
 is the keyword which indicates the start of configuration for
-each events.
+each event.
 .Ed
 .It
 APM events

Modified: head/usr.sbin/apmd/apmd.c
==============================================================================
--- head/usr.sbin/apmd/apmd.c   Fri May 14 14:26:49 2010        (r208074)
+++ head/usr.sbin/apmd/apmd.c   Fri May 14 14:26:56 2010        (r208075)
@@ -52,8 +52,6 @@ static const char rcsid[] =
 
 #include "apmd.h"
 
-extern int     yyparse(void);
-
 int            debug_level = 0;
 int            verbose = 0;
 int            soft_power_state_change = 0;
@@ -116,14 +114,14 @@ event_cmd_exec_act(void *this)
 
        switch ((pid = fork())) {
        case -1:
-               (void) warn("cannot fork");
+               warn("cannot fork");
                goto out;
        case 0:
                /* child process */
                signal(SIGHUP, SIG_DFL);
                signal(SIGCHLD, SIG_DFL);
                signal(SIGTERM, SIG_DFL);
-               execl(_PATH_BSHELL, "sh", "-c", p->line, (char *)NULL);
+               execl(_PATH_BSHELL, "sh", "-c", p->line, NULL);
                _exit(127);
        default:
                /* parent process */
@@ -170,7 +168,7 @@ struct event_cmd_op event_cmd_exec_ops =
  * reject commad
  */
 int
-event_cmd_reject_act(void *this)
+event_cmd_reject_act(void *this __unused)
 {
        int rc = -1;
 
@@ -200,7 +198,7 @@ clone_event_cmd_list(struct event_cmd *p
        for ( ;p; p = p->next) {
                assert(p->op->clone);
                if ((q->next = p->op->clone(p)) == NULL)
-                       (void) err(1, "out of memory");
+                       err(1, "out of memory");
                q = q->next;
        }
        q->next = NULL;
@@ -238,7 +236,7 @@ register_battery_handlers(
                struct battery_watch_event *we;
                
                if ((we = malloc(sizeof(struct battery_watch_event))) == NULL)
-                       (void) err(1, "out of memory");
+                       err(1, "out of memory");
 
                we->next = battery_watch_list; /* starts at NULL */
                battery_watch_list = we;
@@ -269,7 +267,7 @@ register_apm_event_handlers(
                                break;
                        p = events[n].cmdlist;
                        if ((q = clone_event_cmd_list(cmdlist)) == NULL)
-                               (void) err(1, "out of memory");
+                               err(1, "out of memory");
                        if (p) {
                                while (p->next != NULL)
                                        p = p->next;
@@ -315,7 +313,7 @@ exec_event_cmd(struct event_config *ev)
        status = exec_run_cmd(ev->cmdlist);
        if (status && ev->rejectable) {
                syslog(LOG_ERR, "canceled");
-               (void) event_cmd_reject_act(NULL);
+               event_cmd_reject_act(NULL);
        }
        return status;
 }
@@ -332,7 +330,7 @@ read_config(void)
        int i;
 
        if ((yyin = fopen(apmd_configfile, "r")) == NULL) {
-               (void) err(1, "cannot open config file");
+               err(1, "cannot open config file");
        }
 
 #ifdef DEBUG
@@ -340,7 +338,7 @@ read_config(void)
 #endif
 
        if (yyparse() != 0)
-               (void) err(1, "cannot parse config file");
+               err(1, "cannot parse config file");
 
        fclose(yyin);
 
@@ -349,14 +347,14 @@ read_config(void)
                if (events[i].cmdlist) {
                        u_int event_type = i;
                        if (write(apmctl_fd, &event_type, sizeof(u_int)) == -1) 
{
-                               (void) err(1, "cannot enable event 0x%x", 
event_type);
+                               err(1, "cannot enable event 0x%x", event_type);
                        }
                }
        }
 }
 
 void
-dump_config()
+dump_config(void)
 {
        int i;
        struct battery_watch_event *q;
@@ -392,7 +390,7 @@ dump_config()
 }
 
 void
-destroy_config()
+destroy_config(void)
 {
        int i;
        struct battery_watch_event *q;
@@ -402,7 +400,7 @@ destroy_config()
                if (events[i].cmdlist) {
                        u_int event_type = i;
                        if (write(apmctl_fd, &event_type, sizeof(u_int)) == -1) 
{
-                               (void) err(1, "cannot disable event 0x%x", 
event_type);
+                               err(1, "cannot disable event 0x%x", event_type);
                        }
                }
        }
@@ -423,7 +421,7 @@ destroy_config()
 }
 
 void
-restart()
+restart(void)
 {
        destroy_config();
        read_config();
@@ -435,7 +433,7 @@ restart()
  * write pid file
  */
 static void
-write_pid()
+write_pid(void)
 {
        FILE *fp = fopen(apmd_pidfile, "w");
 
@@ -454,11 +452,11 @@ void
 enque_signal(int sig)
 {
        if (write(signal_fd[1], &sig, sizeof sig) != sizeof sig)
-               (void) err(1, "cannot process signal.");
+               err(1, "cannot process signal.");
 }
 
 void
-wait_child()
+wait_child(void)
 {
        int status;
        while (waitpid(-1, &status, WNOHANG) > 0)
@@ -486,7 +484,7 @@ proc_signal(int fd)
                        wait_child();
                        break;
                default:
-                       (void) warn("unexpected signal(%d) received.", sig);
+                       warn("unexpected signal(%d) received.", sig);
                        break;
                }
        }
@@ -515,7 +513,7 @@ proc_apmevent(int fd)
        BATTERY_DISCHARGING)
 
 void
-check_battery()
+check_battery(void)
 {
 
        static int first_time=1, last_state;
@@ -530,7 +528,7 @@ check_battery()
 
        if (first_time) {
                if ( ioctl(apmnorm_fd, APMIO_GETINFO, &pw_info) < 0)
-                       (void) err(1, "cannot check battery state.");
+                       err(1, "cannot check battery state.");
 /*
  * This next statement isn't entirely true. The spec does not tie AC
  * line state to battery charging or not, but this is a bit lazier to do.
@@ -545,7 +543,7 @@ check_battery()
         * of smoothing or correction?
         */
        if ( ioctl(apmnorm_fd, APMIO_GETINFO, &pw_info) < 0)
-               (void) err(1, "cannot check battery state.");
+               err(1, "cannot check battery state.");
 
        /*
         * If we're not in the state now that we were in last time,
@@ -565,7 +563,7 @@ check_battery()
                if (p -> direction == AC_POWER_STATE &&
                        !(p -> done) &&
                        ((p -> type == BATTERY_PERCENT && 
-                               p -> level == pw_info.ai_batt_life) ||
+                               p -> level == (int)pw_info.ai_batt_life) ||
                        (p -> type == BATTERY_MINUTES &&
                                p -> level == (pw_info.ai_batt_time / 60)))) {
                        p -> done++;
@@ -621,7 +619,7 @@ event_loop(void)
                sigprocmask(SIG_SETMASK, &osigmask, NULL);
                if ((res=select(fdmax + 1, &rfds, 0, 0, &to)) < 0) {
                        if (errno != EINTR)
-                               (void) err(1, "select");
+                               err(1, "select");
                }
                sigprocmask(SIG_SETMASK, &sigmask, NULL);
 
@@ -666,7 +664,7 @@ main(int ac, char* av[])
                        verbose = 1;
                        break;
                default:
-                       (void) err(1, "unknown option `%c'", ch);
+                       err(1, "unknown option `%c'", ch);
                }
        }
 
@@ -674,7 +672,7 @@ main(int ac, char* av[])
                daemon(0, 0);
 
 #ifdef NICE_INCR
-       (void) nice(NICE_INCR);
+       nice(NICE_INCR);
 #endif
 
        if (!daemonize)
@@ -686,29 +684,29 @@ main(int ac, char* av[])
        syslog(LOG_NOTICE, "start");
 
        if (pipe(signal_fd) < 0)
-               (void) err(1, "pipe");
+               err(1, "pipe");
        if (fcntl(signal_fd[0], F_SETFL, O_NONBLOCK) < 0)
-               (void) err(1, "fcntl");
+               err(1, "fcntl");
 
        if ((apmnorm_fd = open(APM_NORM_DEVICEFILE, O_RDWR)) == -1) {
-               (void) err(1, "cannot open device file `%s'", 
APM_NORM_DEVICEFILE);
+               err(1, "cannot open device file `%s'", APM_NORM_DEVICEFILE);
        }
 
        if (fcntl(apmnorm_fd, F_SETFD, 1) == -1) {
-               (void) err(1, "cannot set close-on-exec flag for device file 
'%s'", APM_NORM_DEVICEFILE);
+               err(1, "cannot set close-on-exec flag for device file '%s'", 
APM_NORM_DEVICEFILE);
        }
 
        if ((apmctl_fd = open(APM_CTL_DEVICEFILE, O_RDWR)) == -1) {
-               (void) err(1, "cannot open device file `%s'", 
APM_CTL_DEVICEFILE);
+               err(1, "cannot open device file `%s'", APM_CTL_DEVICEFILE);
        }
 
        if (fcntl(apmctl_fd, F_SETFD, 1) == -1) {
-               (void) err(1, "cannot set close-on-exec flag for device file 
'%s'", APM_CTL_DEVICEFILE);
-       }
+               err(1, "cannot set close-on-exec flag for device file '%s'", 
APM_CTL_DEVICEFILE);
+       }
 
        restart();
        write_pid();
        event_loop();
-       exit(EXIT_SUCCESS);
+       exit(EXIT_SUCCESS);
 }
 

Modified: head/usr.sbin/apmd/apmd.h
==============================================================================
--- head/usr.sbin/apmd/apmd.h   Fri May 14 14:26:49 2010        (r208074)
+++ head/usr.sbin/apmd/apmd.h   Fri May 14 14:26:56 2010        (r208075)
@@ -106,3 +106,28 @@ extern int register_apm_event_handlers(
        bitstr_t bit_decl(evlist, EVENT_MAX),
        struct event_cmd *cmdlist);
 extern void free_event_cmd_list(struct event_cmd *p);
+
+extern int     yyparse(void);
+
+void   yyerror(const char *);
+int    yylex(void);
+
+struct event_cmd *event_cmd_default_clone(void *);
+int event_cmd_exec_act(void *);
+void event_cmd_exec_dump(void *, FILE *);
+struct event_cmd *event_cmd_exec_clone(void *);
+void event_cmd_exec_free(void *);
+int event_cmd_reject_act(void *);
+struct event_cmd *clone_event_cmd_list(struct event_cmd *);
+int exec_run_cmd(struct event_cmd *);
+int exec_event_cmd(struct event_config *);
+void read_config(void);
+void dump_config(void);
+void destroy_config(void);
+void restart(void);
+void enque_signal(int);
+void wait_child(void);
+int proc_signal(int);
+void proc_apmevent(int);
+void check_battery(void);
+void event_loop(void);

Modified: head/usr.sbin/apmd/apmdlex.l
==============================================================================
--- head/usr.sbin/apmd/apmdlex.l        Fri May 14 14:26:49 2010        
(r208074)
+++ head/usr.sbin/apmd/apmdlex.l        Fri May 14 14:26:56 2010        
(r208075)
@@ -36,6 +36,9 @@
 #include "apmd.h"
 #include "y.tab.h"
 
+/* We don't need it, avoid the warning. */
+#define YY_NO_UNPUT
+
 int lineno;
 int first_time;
 %}

Modified: head/usr.sbin/apmd/contrib/pccardq.c
==============================================================================
--- head/usr.sbin/apmd/contrib/pccardq.c        Fri May 14 14:26:49 2010        
(r208074)
+++ head/usr.sbin/apmd/contrib/pccardq.c        Fri May 14 14:26:56 2010        
(r208075)
@@ -20,7 +20,7 @@ const char     *tmp_dir = "/tmp";
 unsigned        slot_map = ~0;
 
 void
-usage()
+usage(void)
 {
     fprintf(stderr, "usage: %s [-a] [-n] [-s slot]\n", prog);
 }
@@ -223,7 +223,7 @@ get_slot_info(int so, int slot, char **m
     return rc;
 }
 
-const char     *
+const char *
 strstate(int state)
 {
     switch (state) {
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to