From 2804a96a502283a0b41449bcfe2b049dbfc6dbae Mon Sep 17 00:00:00 2001 From: Xin LI Date: Wed, 4 Nov 2009 23:36:23 +0000 Subject: [PATCH] Cleanup code to make it WARNS=6 clean: - ANSIfy prototypes; - Add __unused for parameters that is not being currently used; - Add a header for subrountines being called from other modules. Reviewed by: mjacob --- share/examples/ses/srcs/chpmon.c | 4 +--- share/examples/ses/srcs/eltsub.c | 12 ++++------ share/examples/ses/srcs/eltsub.h | 36 ++++++++++++++++++++++++++++ share/examples/ses/srcs/getencstat.c | 7 ++---- share/examples/ses/srcs/getnobj.c | 4 +--- share/examples/ses/srcs/getobjmap.c | 6 ++--- share/examples/ses/srcs/getobjstat.c | 4 +--- share/examples/ses/srcs/inienc.c | 4 +--- share/examples/ses/srcs/sesd.c | 9 +++---- share/examples/ses/srcs/setencstat.c | 4 +--- share/examples/ses/srcs/setobjstat.c | 4 +--- 11 files changed, 54 insertions(+), 40 deletions(-) create mode 100644 share/examples/ses/srcs/eltsub.h diff --git a/share/examples/ses/srcs/chpmon.c b/share/examples/ses/srcs/chpmon.c index 1b537c7ba11e..cb78f062f354 100644 --- a/share/examples/ses/srcs/chpmon.c +++ b/share/examples/ses/srcs/chpmon.c @@ -47,9 +47,7 @@ #define BADSTAT \ (SES_ENCSTAT_UNRECOV|SES_ENCSTAT_CRITICAL|SES_ENCSTAT_NONCRITICAL) int -main(a, v) - int a; - char **v; +main(int a, char **v) { int fd, delay, dev; ses_encstat stat, *carray; diff --git a/share/examples/ses/srcs/eltsub.c b/share/examples/ses/srcs/eltsub.c index 5fae6653d41f..2acf982d2eb0 100644 --- a/share/examples/ses/srcs/eltsub.c +++ b/share/examples/ses/srcs/eltsub.c @@ -38,9 +38,10 @@ #include #include SESINC +#include "eltsub.h" + char * -geteltnm(type) - int type; +geteltnm(int type) { static char rbuf[132]; @@ -116,8 +117,7 @@ geteltnm(type) } static char * -scode2ascii(code) - u_char code; +scode2ascii(u_char code) { static char rbuf[32]; switch (code & 0xf) { @@ -154,9 +154,7 @@ scode2ascii(code) char * -stat2ascii(eletype, cstat) - int eletype; - u_char *cstat; +stat2ascii(int eletype __unused, u_char *cstat) { static char ebuf[256], *scode; diff --git a/share/examples/ses/srcs/eltsub.h b/share/examples/ses/srcs/eltsub.h new file mode 100644 index 000000000000..3d98572352e9 --- /dev/null +++ b/share/examples/ses/srcs/eltsub.h @@ -0,0 +1,36 @@ +/* $FreeBSD$ */ +/* + * Copyright (c) 2000 by Matthew Jacob + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification, immediately at the beginning of the file. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * the GNU Public License ("GPL"). + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Matthew Jacob + * Feral Software + * mjacob@feral.com + */ + +char * geteltnm(int); +char * stat2ascii(int, u_char *); diff --git a/share/examples/ses/srcs/getencstat.c b/share/examples/ses/srcs/getencstat.c index d9f5c6d68b10..3514fe4e77cb 100644 --- a/share/examples/ses/srcs/getencstat.c +++ b/share/examples/ses/srcs/getencstat.c @@ -40,13 +40,10 @@ #include #include SESINC -extern char *geteltnm __P((int)); -extern char *stat2ascii __P((int, u_char *)); +#include "eltsub.h" int -main(a, v) - int a; - char **v; +main(int a, char **v) { ses_object *objp; ses_objstat ob; diff --git a/share/examples/ses/srcs/getnobj.c b/share/examples/ses/srcs/getnobj.c index 680a6cdbc173..17a26c62bd9d 100644 --- a/share/examples/ses/srcs/getnobj.c +++ b/share/examples/ses/srcs/getnobj.c @@ -41,9 +41,7 @@ #include SESINC int -main(argc, argv) - int argc; - char **argv; +main(int argc, char **argv) { unsigned int nobj; int fd; diff --git a/share/examples/ses/srcs/getobjmap.c b/share/examples/ses/srcs/getobjmap.c index 7f4d1b783745..9798b4c87ba2 100644 --- a/share/examples/ses/srcs/getobjmap.c +++ b/share/examples/ses/srcs/getobjmap.c @@ -39,12 +39,10 @@ #include #include SESINC -extern char *geteltnm __P((int)); +#include "eltsub.h" int -main(a, v) - int a; - char **v; +main(int a, char **v) { ses_object *objp; int nobj, fd, i; diff --git a/share/examples/ses/srcs/getobjstat.c b/share/examples/ses/srcs/getobjstat.c index bf703cf47ff4..99fb1854238b 100644 --- a/share/examples/ses/srcs/getobjstat.c +++ b/share/examples/ses/srcs/getobjstat.c @@ -39,9 +39,7 @@ #include SESINC int -main(a, v) - int a; - char **v; +main(int a, char **v) { int fd; int i; diff --git a/share/examples/ses/srcs/inienc.c b/share/examples/ses/srcs/inienc.c index d6fb262ef7ee..7d6cc220b51f 100644 --- a/share/examples/ses/srcs/inienc.c +++ b/share/examples/ses/srcs/inienc.c @@ -40,9 +40,7 @@ #include SESINC int -main(a, v) - int a; - char **v; +main(int a, char **v) { int fd; diff --git a/share/examples/ses/srcs/sesd.c b/share/examples/ses/srcs/sesd.c index 5262b639bfd4..0793077d2101 100644 --- a/share/examples/ses/srcs/sesd.c +++ b/share/examples/ses/srcs/sesd.c @@ -49,13 +49,11 @@ */ int -main(a, v) - int a; - char **v; +main(int a, char **v) { - static char *usage = + static const char *usage = "usage: %s [ -d ] [ -t pollinterval ] device [ device ]\n"; - int fd, polltime, dev, devbase, nodaemon, bpri; + int fd, polltime, dev, devbase, nodaemon; ses_encstat stat, *carray; if (a < 2) { @@ -115,7 +113,6 @@ main(a, v) for (;;) { for (dev = devbase; dev < a; dev++) { - char buf[128]; fd = open(v[dev], O_RDWR); if (fd < 0) { syslog(LOG_ERR, "%s: %m", v[dev]); diff --git a/share/examples/ses/srcs/setencstat.c b/share/examples/ses/srcs/setencstat.c index 58e0dafc1879..127f68fa4cf5 100644 --- a/share/examples/ses/srcs/setencstat.c +++ b/share/examples/ses/srcs/setencstat.c @@ -40,9 +40,7 @@ #include SESINC int -main(a, v) - int a; - char **v; +main(int a, char **v) { int fd; long val; diff --git a/share/examples/ses/srcs/setobjstat.c b/share/examples/ses/srcs/setobjstat.c index 34e8ea65d97a..08fdb7b48223 100644 --- a/share/examples/ses/srcs/setobjstat.c +++ b/share/examples/ses/srcs/setobjstat.c @@ -40,9 +40,7 @@ #include SESINC int -main(a, v) - int a; - char **v; +main(int a, char **v) { int fd; int i;