Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/savecore de-__P(), and generally try to be more conform...



details:   https://anonhg.NetBSD.org/src/rev/f77ff54fd0a1
branches:  trunk
changeset: 500164:f77ff54fd0a1
user:      wiz <wiz%NetBSD.org@localhost>
date:      Thu Dec 07 03:55:44 2000 +0000

description:
de-__P(), and generally try to be more conforming to the new NetBSD style.
Use %m in syslog strings where appropriate.
Reduce warnings with WARNS=2.

diffstat:

 sbin/savecore/savecore.c |  147 +++++++++++++++++++++-------------------------
 1 files changed, 66 insertions(+), 81 deletions(-)

diffs (truncated from 404 to 300 lines):

diff -r 7e633917d64e -r f77ff54fd0a1 sbin/savecore/savecore.c
--- a/sbin/savecore/savecore.c  Thu Dec 07 03:48:09 2000 +0000
+++ b/sbin/savecore/savecore.c  Thu Dec 07 03:55:44 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: savecore.c,v 1.44 2000/12/07 03:17:17 wiz Exp $        */
+/*     $NetBSD: savecore.c,v 1.45 2000/12/07 03:55:44 wiz Exp $        */
 
 /*-
  * Copyright (c) 1986, 1992, 1993
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)savecore.c 8.5 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: savecore.c,v 1.44 2000/12/07 03:17:17 wiz Exp $");
+__RCSID("$NetBSD: savecore.c,v 1.45 2000/12/07 03:55:44 wiz Exp $");
 #endif
 #endif /* not lint */
 
@@ -69,7 +69,7 @@
 #include <limits.h>
 #include <kvm.h>
 
-extern FILE *zopen __P((const char *fname, const char *mode, int bits));
+extern FILE *zopen(const char *fname, const char *mode, int bits);
 
 #define KREAD(kd, addr, p)\
        (kvm_read(kd, addr, (char *)(p), sizeof(*(p))) != sizeof(*(p)))
@@ -123,27 +123,25 @@
 
 int    clear, compress, force, verbose;        /* flags */
 
-void    check_kmem __P((void));
-int     check_space __P((void));
-void    clear_dump __P((void));
-int     Create __P((char *, int));
-int     dump_exists __P((void));
-char   *find_dev __P((dev_t, int));
-int     get_crashtime __P((void));
-void    kmem_setup __P((void));
-void    log __P((int, char *, ...));
-void    Lseek __P((int, off_t, int));
-int     main __P((int, char *[]));
-int     Open __P((char *, int rw));
-char   *rawname __P((char *s));
-void    save_core __P((void));
-void    usage __P((void));
-void    Write __P((int, void *, int));
+void   check_kmem(void);
+int    check_space(void);
+void   clear_dump(void);
+int    Create(char *, int);
+int    dump_exists(void);
+char   *find_dev(dev_t, int);
+int    get_crashtime(void);
+void   kmem_setup(void);
+void   log(int, char *, ...);
+void   Lseek(int, off_t, int);
+int    main(int, char *[]);
+int    Open(char *, int rw);
+char   *rawname(char *s);
+void   save_core(void);
+void   usage(void);
+void   Write(int, void *, int);
 
 int
-main(argc, argv)
-       int argc;
-       char *argv[];
+main(int argc, char *argv[])
 {
        int ch;
 #ifdef CPU_BOOTED_KERNEL
@@ -238,11 +236,11 @@
 }
 
 void
-kmem_setup()
+kmem_setup(void)
 {
-       kvm_t   *kd_kern;
-       char    errbuf[_POSIX2_LINE_MAX];
-       int     i, hdrsz;
+       kvm_t *kd_kern;
+       char errbuf[_POSIX2_LINE_MAX];
+       int i, hdrsz;
        
        /*
         * Some names we need for the currently running system, others for
@@ -259,7 +257,7 @@
        }
        if (kvm_nlist(kd_kern, current_nl) == -1)
                syslog(LOG_ERR, "%s: kvm_nlist: %s", kernel,
-                       kvm_geterr(kd_kern));
+                   kvm_geterr(kd_kern));
        
        for (i = 0; cursyms[i] != -1; i++)
                if (current_nl[cursyms[i]].n_value == 0) {
@@ -292,8 +290,8 @@
                exit(1);
        }
 
-       (void)kvm_read(kd_kern, current_nl[X_VERSION].n_value,
-           vers, sizeof(vers));
+       (void)kvm_read(kd_kern, current_nl[X_VERSION].n_value, vers,
+           sizeof(vers));
        vers[sizeof(vers) - 1] = '\0';
 
        ddname = find_dev(dumpdev, S_IFBLK);
@@ -327,7 +325,7 @@
        }
        if (hdrsz == -1) {
                syslog(LOG_ERR, "%s: kvm_dump_mkheader: %s", kernel,
-                       kvm_geterr(kd_dump));
+                   kvm_geterr(kd_dump));
                exit(1);
        }
        dumplo += hdrsz;
@@ -335,14 +333,14 @@
 }
 
 void
-check_kmem()
+check_kmem(void)
 {
-       char    *cp;
-       long    panicloc;
+       char *cp;
+       long panicloc;
        char core_vers[1024];
 
        (void)kvm_read(kd_dump, dump_nl[X_VERSION].n_value, core_vers,
-               sizeof(core_vers));
+           sizeof(core_vers));
        core_vers[sizeof(core_vers) - 1] = '\0';
 
        if (strcmp(vers, core_vers) && kernel == 0)
@@ -356,13 +354,13 @@
                return;
        }
        if (panicstr) {
-               cp       = panic_mesg;
+               cp = panic_mesg;
                panicloc = panicstr;
                do {
                        if (KREAD(kd_dump, panicloc, cp) != 0) {
                                if (verbose)
                                    syslog(LOG_WARNING, "kvm_read: %s",
-                                          kvm_geterr(kd_dump));
+                                       kvm_geterr(kd_dump));
                                break;
                        }
                        panicloc++;
@@ -372,7 +370,7 @@
 }
 
 int
-dump_exists()
+dump_exists(void)
 {
        int newdumpmag;
 
@@ -407,18 +405,18 @@
 }
 
 void
-clear_dump()
+clear_dump(void)
 {
        if (kvm_dump_inval(kd_dump) == -1)
                syslog(LOG_ERR, "%s: kvm_clear_dump: %s", ddname,
-                       kvm_geterr(kd_dump));
+                   kvm_geterr(kd_dump));
 
 }
 
 char buf[1024 * 1024];
 
 void
-save_core()
+save_core(void)
 {
        FILE *fp;
        int bounds, ifd, nr, nw, ofd;
@@ -435,7 +433,7 @@
                goto err1;
        if (fgets(buf, sizeof(buf), fp) == NULL) {
                if (ferror(fp))
-err1:                  syslog(LOG_WARNING, "%s: %s", path, strerror(errno));
+err1:                  syslog(LOG_WARNING, "%s: %m", path);
                bounds = 0;
        } else
                bounds = atoi(buf);
@@ -453,15 +451,14 @@
            dirname, bounds, compress ? ".Z" : "");
        if (compress) {
                if ((fp = zopen(path, "w", 0)) == NULL) {
-                       syslog(LOG_ERR, "%s: %s", path, strerror(errno));
+                       syslog(LOG_ERR, "%s: %m", path);
                        exit(1);
                }
        } else {
                ofd = Create(path, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
                fp  = fdopen(ofd, "w");
                if (fp == NULL) {
-                       syslog(LOG_ERR, "%s: fdopen: %s", path,
-                           strerror(errno));
+                       syslog(LOG_ERR, "%s: fdopen: %m", path);
                        exit(1);
                }
        }
@@ -478,7 +475,7 @@
 
        if (kvm_dump_wrtheader(kd_dump, fp, dumpsize) == -1) {
                syslog(LOG_ERR, "kvm_dump_wrtheader: %s : %s", path,
-                       kvm_geterr(kd_dump));
+                   kvm_geterr(kd_dump));
                exit(1);
        }
 
@@ -516,7 +513,7 @@
            dirname, bounds, compress ? ".Z" : "");
        if (compress) {
                if ((fp = zopen(path, "w", 0)) == NULL) {
-                       syslog(LOG_ERR, "%s: %s", path, strerror(errno));
+                       syslog(LOG_ERR, "%s: %m", path);
                        exit(1);
                }
        } else
@@ -537,10 +534,8 @@
                }
        }
        if (nr < 0) {
-               syslog(LOG_ERR, "%s: %s",
-                   kernel ? kernel : _PATH_UNIX, strerror(errno));
-               syslog(LOG_WARNING,
-                   "WARNING: kernel may be incomplete");
+               syslog(LOG_ERR, "%s: %m", kernel ? kernel : _PATH_UNIX);
+               syslog(LOG_WARNING, "WARNING: kernel may be incomplete");
                exit(1);
        }
        if (compress)
@@ -550,9 +545,7 @@
 }
 
 char *
-find_dev(dev, type)
-       dev_t dev;
-       int type;
+find_dev(dev_t dev, int type)
 {
        DIR *dfd;
        struct dirent *dir;
@@ -560,14 +553,14 @@
        char *dp, devname[MAXPATHLEN + 1];
 
        if ((dfd = opendir(_PATH_DEV)) == NULL) {
-               syslog(LOG_ERR, "%s: %s", _PATH_DEV, strerror(errno));
+               syslog(LOG_ERR, "%s: %m", _PATH_DEV);
                exit(1);
        }
        (void)strcpy(devname, _PATH_DEV);
        while ((dir = readdir(dfd))) {
                (void)strcpy(devname + sizeof(_PATH_DEV) - 1, dir->d_name);
                if (lstat(devname, &sb)) {
-                       syslog(LOG_ERR, "%s: %s", devname, strerror(errno));
+                       syslog(LOG_ERR, "%s: %m", devname);
                        continue;
                }
                if ((sb.st_mode & S_IFMT) != type)
@@ -575,7 +568,7 @@
                if (dev == sb.st_rdev) {
                        closedir(dfd);
                        if ((dp = strdup(devname)) == NULL) {
-                               syslog(LOG_ERR, "%s", strerror(errno));
+                               syslog(LOG_ERR, "%m");
                                exit(1);
                        }
                        return (dp);
@@ -587,10 +580,10 @@
 }
 
 char *
-rawname(s)
-       char *s;
+rawname(char *s)
 {
-       char *sl, name[MAXPATHLEN];
+       char *sl;
+       char name[MAXPATHLEN];
 
        if ((sl = strrchr(s, '/')) == NULL || sl[1] == '0') {
                syslog(LOG_ERR,
@@ -600,24 +593,24 @@
        (void)snprintf(name, sizeof(name), "%.*s/r%s", (int)(sl - s), s,
            sl + 1);
        if ((sl = strdup(name)) == NULL) {
-               syslog(LOG_ERR, "%s", strerror(errno));
+               syslog(LOG_ERR, "%m");
                exit(1);
        }



Home | Main Index | Thread Index | Old Index