Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/chio ANSIfication and KNF fixes by Petri Koistinen via b...
details: https://anonhg.NetBSD.org/src/rev/96e933835522
branches: trunk
changeset: 514887:96e933835522
user: wiz <wiz%NetBSD.org@localhost>
date: Thu Sep 13 10:00:44 2001 +0000
description:
ANSIfication and KNF fixes by Petri Koistinen via bin/13690.
diffstat:
bin/chio/chio.c | 189 ++++++++++++++++++++------------------------------
bin/chio/defs.h | 7 +-
bin/chio/pathnames.h | 7 +-
3 files changed, 87 insertions(+), 116 deletions(-)
diffs (truncated from 551 to 300 lines):
diff -r 90104ecddd70 -r 96e933835522 bin/chio/chio.c
--- a/bin/chio/chio.c Thu Sep 13 09:53:59 2001 +0000
+++ b/bin/chio/chio.c Thu Sep 13 10:00:44 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: chio.c,v 1.15 2001/02/19 22:39:39 cgd Exp $ */
+/* $NetBSD: chio.c,v 1.16 2001/09/13 10:00:44 wiz Exp $ */
/*-
* Copyright (c) 1996, 1998, 1999 The NetBSD Foundation, Inc.
@@ -46,13 +46,14 @@
__COPYRIGHT(
"@(#) Copyright (c) 1996, 1998, 1999\
The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: chio.c,v 1.15 2001/02/19 22:39:39 cgd Exp $");
+__RCSID("$NetBSD: chio.c,v 1.16 2001/09/13 10:00:44 wiz Exp $");
#endif
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/chio.h>
#include <sys/cdio.h> /* for ATAPI CD changer; too bad it uses a lame API */
+
#include <ctype.h>
#include <err.h>
#include <errno.h>
@@ -66,24 +67,24 @@
#include "defs.h"
#include "pathnames.h"
-int main __P((int, char *[]));
-static void usage __P((void));
-static void cleanup __P((void));
-static int parse_element_type __P((const char *));
-static int parse_element_unit __P((const char *));
-static int parse_special __P((const char *));
-static int is_special __P((const char *));
-static const char *bits_to_string __P((int, const char *));
+int main(int, char *[]);
+static void usage(void);
+static void cleanup(void);
+static int parse_element_type(const char *);
+static int parse_element_unit(const char *);
+static int parse_special(const char *);
+static int is_special(const char *);
+static const char *bits_to_string(int, const char *);
-static int do_move __P((const char *, int, char **));
-static int do_exchange __P((const char *, int, char **));
-static int do_position __P((const char *, int, char **));
-static int do_params __P((const char *, int, char **));
-static int do_getpicker __P((const char *, int, char **));
-static int do_setpicker __P((const char *, int, char **));
-static int do_status __P((const char *, int, char **));
-static int do_ielem __P((const char *, int, char **));
-static int do_cdlu __P((const char *, int, char **));
+static int do_move(const char *, int, char **);
+static int do_exchange(const char *, int, char **);
+static int do_position(const char *, int, char **);
+static int do_params(const char *, int, char **);
+static int do_getpicker(const char *, int, char **);
+static int do_setpicker(const char *, int, char **);
+static int do_status(const char *, int, char **);
+static int do_ielem(const char *, int, char **);
+static int do_cdlu(const char *, int, char **);
/* Valid changer element types. */
const struct element_type elements[] = {
@@ -137,13 +138,11 @@
{ NULL, 0 },
};
-static int changer_fd;
-static const char *changer_name;
+static const char *changer_name;
+static int changer_fd;
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
int ch, i;
@@ -152,7 +151,6 @@
case 'f':
changer_name = optarg;
break;
-
default:
usage();
}
@@ -190,10 +188,7 @@
}
static int
-do_move(cname, argc, argv)
- const char *cname;
- int argc;
- char **argv;
+do_move(const char *cname, int argc, char **argv)
{
struct changer_move_request cmd;
int val;
@@ -212,7 +207,7 @@
warnx("%s: too many arguments", cname);
usage();
}
- (void) memset(&cmd, 0, sizeof(cmd));
+ (void)memset(&cmd, 0, sizeof(cmd));
/* <from ET> */
cmd.cm_fromtype = parse_element_type(*argv);
@@ -237,7 +232,6 @@
case SW_INVERT:
cmd.cm_flags |= CM_INVERT;
break;
-
default:
errx(1, "%s: inappropriate modifier `%s'",
cname, *argv);
@@ -253,10 +247,7 @@
}
static int
-do_exchange(cname, argc, argv)
- const char *cname;
- int argc;
- char **argv;
+do_exchange(const char *cname, int argc, char **argv)
{
struct changer_exchange_request cmd;
int val;
@@ -275,7 +266,7 @@
warnx("%s: too many arguments", cname);
usage();
}
- (void) memset(&cmd, 0, sizeof(cmd));
+ (void)memset(&cmd, 0, sizeof(cmd));
/* <src ET> */
cmd.ce_srctype = parse_element_type(*argv);
@@ -321,11 +312,9 @@
case SW_INVERT1:
cmd.ce_flags |= CE_INVERT1;
break;
-
case SW_INVERT2:
cmd.ce_flags |= CE_INVERT2;
break;
-
default:
errx(1, "%s: inappropriate modifier `%s'",
cname, *argv);
@@ -341,10 +330,7 @@
}
static int
-do_position(cname, argc, argv)
- const char *cname;
- int argc;
- char **argv;
+do_position(const char *cname, int argc, char **argv)
{
struct changer_position_request cmd;
int val;
@@ -363,7 +349,7 @@
warnx("%s: too many arguments", cname);
usage();
}
- (void) memset(&cmd, 0, sizeof(cmd));
+ (void)memset(&cmd, 0, sizeof(cmd));
/* <to ET> */
cmd.cp_type = parse_element_type(*argv);
@@ -380,7 +366,6 @@
case SW_INVERT:
cmd.cp_flags |= CP_INVERT;
break;
-
default:
errx(1, "%s: inappropriate modifier `%s'",
cname, *argv);
@@ -397,10 +382,7 @@
/* ARGSUSED */
static int
-do_params(cname, argc, argv)
- const char *cname;
- int argc;
- char **argv;
+do_params(const char *cname, int argc, char **argv)
{
struct changer_params data;
@@ -411,24 +393,24 @@
}
/* Get params from changer and display them. */
- (void) memset(&data, 0, sizeof(data));
+ (void)memset(&data, 0, sizeof(data));
if (ioctl(changer_fd, CHIOGPARAMS, &data))
err(1, "%s: CHIOGPARAMS", changer_name);
#define PLURAL(n) (n) > 1 ? "s" : ""
- (void) printf("%s: %d slot%s, %d drive%s, %d picker%s",
+ (void)printf("%s: %d slot%s, %d drive%s, %d picker%s",
changer_name,
data.cp_nslots, PLURAL(data.cp_nslots),
data.cp_ndrives, PLURAL(data.cp_ndrives),
data.cp_npickers, PLURAL(data.cp_npickers));
if (data.cp_nportals)
- (void) printf(", %d portal%s", data.cp_nportals,
+ (void)printf(", %d portal%s", data.cp_nportals,
PLURAL(data.cp_nportals));
#undef PLURAL
- (void) printf("\n%s: current picker: %d\n", changer_name,
+ (void)printf("\n%s: current picker: %d\n", changer_name,
data.cp_curpicker);
return (0);
@@ -436,10 +418,7 @@
/* ARGSUSED */
static int
-do_getpicker(cname, argc, argv)
- const char *cname;
- int argc;
- char **argv;
+do_getpicker(const char *cname, int argc, char **argv)
{
int picker;
@@ -453,16 +432,13 @@
if (ioctl(changer_fd, CHIOGPICKER, &picker))
err(1, "%s: CHIOGPICKER", changer_name);
- (void) printf("%s: current picker: %d\n", changer_name, picker);
+ (void)printf("%s: current picker: %d\n", changer_name, picker);
return (0);
}
static int
-do_setpicker(cname, argc, argv)
- const char *cname;
- int argc;
- char **argv;
+do_setpicker(const char *cname, int argc, char **argv)
{
int picker;
@@ -484,17 +460,18 @@
}
static int
-do_status(cname, argc, argv)
- const char *cname;
- int argc;
- char **argv;
+do_status(const char *cname, int argc, char **argv)
{
struct changer_element_status_request cmd;
struct changer_params data;
struct changer_element_status *ces;
- int i, chet, schet, echet, count, ucount, unit;
- int have_ucount = 0, have_unit = 0, flags = 0;
+ int i, chet, count, echet, flags, have_ucount, have_unit;
+ int schet, ucount, unit;
size_t size;
+
+ flags = 0;
+ have_ucount = 0;
+ have_unit = 0;
/*
* On a status command, we expect the following:
@@ -515,7 +492,7 @@
* Get params from changer. Specifically, we need the element
* counts.
*/
- (void) memset(&data, 0, sizeof(data));
+ (void)memset(&data, 0, sizeof(data));
if (ioctl(changer_fd, CHIOGPARAMS, &data))
err(1, "%s: CHIOGPARAMS", changer_name);
@@ -581,19 +558,15 @@
case CHET_MT:
count = data.cp_npickers;
break;
-
case CHET_ST:
count = data.cp_nslots;
break;
-
case CHET_IE:
count = data.cp_nportals;
Home |
Main Index |
Thread Index |
Old Index