DragonFly submit List (threaded) for 2005-01
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
Re: camcontrol WARNS6: take 5
The patch was getting too long to be reasonable. This one
is just WARNS6 and the function declarations cleanup. I Can
trim it down to just WARNS6 in one patch, if needed.
--
Larry Lansing
Index: Makefile
===================================================================
RCS file: /home/dcvs/src/sbin/camcontrol/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- Makefile 31 Jan 2004 06:56:40 -0000 1.3
+++ Makefile 10 Jan 2005 04:40:20 -0000
@@ -2,6 +2,7 @@
# $DragonFly: src/sbin/camcontrol/Makefile,v 1.3 2004/01/31 06:56:40 dillon Exp $
PROG= camcontrol
+WARNS?= 6
SRCS= camcontrol.c util.c
.if !defined(RELEASE_CRUNCH)
SRCS+= modeedit.c
Index: camcontrol.c
===================================================================
RCS file: /home/dcvs/src/sbin/camcontrol/camcontrol.c,v
retrieving revision 1.2
diff -u -r1.2 camcontrol.c
--- camcontrol.c 17 Jun 2003 04:27:32 -0000 1.2
+++ camcontrol.c 11 Jan 2005 02:43:23 -0000
@@ -105,7 +105,7 @@
} cam_argmask;
struct camcontrol_opts {
- char *optname;
+ const char *optname;
cam_cmdmask cmdnum;
cam_argmask argnum;
const char *subopt;
@@ -161,49 +161,44 @@
int bus, target, lun;
-camcontrol_optret getoption(char *arg, cam_cmdmask *cmdnum, cam_argmask *argnum,
- char **subopt);
+camcontrol_optret getoption(char *, cam_cmdmask *, cam_argmask *,
+ const char **);
#ifndef MINIMALISTIC
-static int getdevlist(struct cam_device *device);
-static int getdevtree(void);
-static int testunitready(struct cam_device *device, int retry_count,
- int timeout, int quiet);
-static int scsistart(struct cam_device *device, int startstop, int loadeject,
- int retry_count, int timeout);
-static int scsidoinquiry(struct cam_device *device, int argc, char **argv,
- char *combinedopt, int retry_count, int timeout);
-static int scsiinquiry(struct cam_device *device, int retry_count, int timeout);
-static int scsiserial(struct cam_device *device, int retry_count, int timeout);
-static int scsixferrate(struct cam_device *device);
+static int getdevlist(struct cam_device *);
+static int getdevtree(void);
+static int testunitready(struct cam_device *, int, int, int);
+static int scsistart(struct cam_device *, int, int, int, int);
+static int scsidoinquiry(struct cam_device *, int, char **, char *, int,
+ int);
+static int scsiinquiry(struct cam_device *, int, int);
+static int scsiserial(struct cam_device *, int, int);
+static int scsixferrate(struct cam_device *);
#endif /* MINIMALISTIC */
-static int parse_btl(char *tstr, int *bus, int *target, int *lun,
- cam_argmask *arglist);
-static int dorescan_or_reset(int argc, char **argv, int rescan);
-static int rescan_or_reset_bus(int bus, int rescan);
-static int scanlun_or_reset_dev(int bus, int target, int lun, int scan);
+static int parse_btl(char *, int *, int *, int *, cam_argmask *);
+static int dorescan_or_reset(int, char **, int);
+static int rescan_or_reset_bus(int, int);
+static int scanlun_or_reset_dev(int, int, int, int);
#ifndef MINIMALISTIC
-static int readdefects(struct cam_device *device, int argc, char **argv,
- char *combinedopt, int retry_count, int timeout);
-static void modepage(struct cam_device *device, int argc, char **argv,
- char *combinedopt, int retry_count, int timeout);
-static int scsicmd(struct cam_device *device, int argc, char **argv,
- char *combinedopt, int retry_count, int timeout);
-static int tagcontrol(struct cam_device *device, int argc, char **argv,
- char *combinedopt);
-static void cts_print(struct cam_device *device,
- struct ccb_trans_settings *cts);
-static void cpi_print(struct ccb_pathinq *cpi);
-static int get_cpi(struct cam_device *device, struct ccb_pathinq *cpi);
-static int get_print_cts(struct cam_device *device, int user_settings,
- int quiet, struct ccb_trans_settings *cts);
-static int ratecontrol(struct cam_device *device, int retry_count,
- int timeout, int argc, char **argv, char *combinedopt);
-static int scsiformat(struct cam_device *device, int argc, char **argv,
- char *combinedopt, int retry_count, int timeout);
+static int readdefects(struct cam_device *, int, char **, char *, int,
+ int);
+static void modepage(struct cam_device *, int, char **, char *, int, int);
+static int scsicmd(struct cam_device *, int, char **, char *, int, int);
+static int tagcontrol(struct cam_device *, int, char **, char *);
+static void cts_print(struct cam_device *device,
+ struct ccb_trans_settings *);
+static void cpi_print(struct ccb_pathinq *);
+static int get_cpi(struct cam_device *, struct ccb_pathinq *);
+static int get_print_cts(struct cam_device *, int, int,
+ struct ccb_trans_settings *);
+static int ratecontrol(struct cam_device *, int, int, int, char **,
+ char *);
+static int scsiformat(struct cam_device *, int, char **, char *, int, int);
#endif /* MINIMALISTIC */
+
camcontrol_optret
-getoption(char *arg, cam_cmdmask *cmdnum, cam_argmask *argnum, char **subopt)
+getoption(char *arg, cam_cmdmask *cmdnum, cam_argmask *argnum,
+ const char **subopt)
{
struct camcontrol_opts *opts;
int num_matches = 0;
@@ -213,7 +208,7 @@
if (strncmp(opts->optname, arg, strlen(arg)) == 0) {
*cmdnum = opts->cmdnum;
*argnum = opts->argnum;
- *subopt = (char *)opts->subopt;
+ *subopt = opts->subopt;
if (++num_matches > 1)
return(CC_OR_AMBIGUOUS);
}
@@ -986,7 +981,8 @@
* Returns the number of parsed components, or 0.
*/
static int
-parse_btl(char *tstr, int *bus, int *target, int *lun, cam_argmask *arglist)
+parse_btl(char *tstr, int *mybus, int *mytarget, int *mylun,
+ cam_argmask *myarglist)
{
char *tmpstr;
int convs = 0;
@@ -996,18 +992,18 @@
tmpstr = (char *)strtok(tstr, ":");
if ((tmpstr != NULL) && (*tmpstr != '\0')) {
- *bus = strtol(tmpstr, NULL, 0);
- *arglist |= CAM_ARG_BUS;
+ *mybus = strtol(tmpstr, NULL, 0);
+ *myarglist |= CAM_ARG_BUS;
convs++;
tmpstr = (char *)strtok(NULL, ":");
if ((tmpstr != NULL) && (*tmpstr != '\0')) {
- *target = strtol(tmpstr, NULL, 0);
- *arglist |= CAM_ARG_TARGET;
+ *mytarget = strtol(tmpstr, NULL, 0);
+ *myarglist |= CAM_ARG_TARGET;
convs++;
tmpstr = (char *)strtok(NULL, ":");
if ((tmpstr != NULL) && (*tmpstr != '\0')) {
- *lun = strtol(tmpstr, NULL, 0);
- *arglist |= CAM_ARG_LUN;
+ *mylun = strtol(tmpstr, NULL, 0);
+ *myarglist |= CAM_ARG_LUN;
convs++;
}
}
@@ -1022,7 +1018,7 @@
static const char must[] =
"you must specify \"all\", a bus, or a bus:target:lun to %s";
int rv, error = 0;
- int bus = -1, target = -1, lun = -1;
+ int mybus = -1, mytarget = -1, mylun = -1;
char *tstr;
if (argc < 3) {
@@ -1036,7 +1032,8 @@
if (strncasecmp(tstr, "all", strlen("all")) == 0)
arglist |= CAM_ARG_BUS;
else {
- rv = parse_btl(argv[optind], &bus, &target, &lun, &arglist);
+ rv = parse_btl(argv[optind], &mybus, &mytarget, &mylun,
+ &arglist);
if (rv != 1 && rv != 3) {
warnx(must, rescan? "rescan" : "reset");
return(1);
@@ -1046,15 +1043,15 @@
if ((arglist & CAM_ARG_BUS)
&& (arglist & CAM_ARG_TARGET)
&& (arglist & CAM_ARG_LUN))
- error = scanlun_or_reset_dev(bus, target, lun, rescan);
+ error = scanlun_or_reset_dev(mybus, mytarget, mylun, rescan);
else
- error = rescan_or_reset_bus(bus, rescan);
+ error = rescan_or_reset_bus(mybus, rescan);
return(error);
}
static int
-rescan_or_reset_bus(int bus, int rescan)
+rescan_or_reset_bus(int mybus, int rescan)
{
union ccb ccb, matchccb;
int fd, retval;
@@ -1068,9 +1065,9 @@
return(1);
}
- if (bus != -1) {
+ if (mybus != -1) {
ccb.ccb_h.func_code = rescan ? XPT_SCAN_BUS : XPT_RESET_BUS;
- ccb.ccb_h.path_id = bus;
+ ccb.ccb_h.path_id = mybus;
ccb.ccb_h.target_id = CAM_TARGET_WILDCARD;
ccb.ccb_h.target_lun = CAM_LUN_WILDCARD;
ccb.crcn.flags = CAM_FLAG_NONE;
@@ -1086,10 +1083,10 @@
if ((ccb.ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) {
fprintf(stdout, "%s of bus %d was successful\n",
- rescan ? "Re-scan" : "Reset", bus);
+ rescan ? "Re-scan" : "Reset", mybus);
} else {
fprintf(stdout, "%s of bus %d returned error %#x\n",
- rescan ? "Re-scan" : "Reset", bus,
+ rescan ? "Re-scan" : "Reset", mybus,
ccb.ccb_h.status & CAM_STATUS_MASK);
retval = 1;
}
@@ -1220,7 +1217,7 @@
}
static int
-scanlun_or_reset_dev(int bus, int target, int lun, int scan)
+scanlun_or_reset_dev(int mybus, int mytarget, int mylun, int scan)
{
union ccb ccb;
struct cam_device *device;
@@ -1228,18 +1225,18 @@
device = NULL;
- if (bus < 0) {
- warnx("invalid bus number %d", bus);
+ if (mybus < 0) {
+ warnx("invalid bus number %d", mybus);
return(1);
}
- if (target < 0) {
- warnx("invalid target number %d", target);
+ if (mytarget < 0) {
+ warnx("invalid target number %d", mytarget);
return(1);
}
- if (lun < 0) {
- warnx("invalid lun number %d", lun);
+ if (mylun < 0) {
+ warnx("invalid lun number %d", mylun);
return(1);
}
@@ -1255,7 +1252,7 @@
return(1);
}
} else {
- device = cam_open_btl(bus, target, lun, O_RDWR, NULL);
+ device = cam_open_btl(mybus, mytarget, mylun, O_RDWR, NULL);
if (device == NULL) {
warnx("%s", cam_errbuf);
return(1);
@@ -1263,9 +1260,9 @@
}
ccb.ccb_h.func_code = (scan)? XPT_SCAN_LUN : XPT_RESET_DEV;
- ccb.ccb_h.path_id = bus;
- ccb.ccb_h.target_id = target;
- ccb.ccb_h.target_lun = lun;
+ ccb.ccb_h.path_id = mybus;
+ ccb.ccb_h.target_id = mytarget;
+ ccb.ccb_h.target_lun = mylun;
ccb.ccb_h.timeout = 5000;
ccb.crcn.flags = CAM_FLAG_NONE;
@@ -1298,11 +1295,11 @@
|| ((!scan)
&& ((ccb.ccb_h.status & CAM_STATUS_MASK) == CAM_BDR_SENT))) {
fprintf(stdout, "%s of %d:%d:%d was successful\n",
- scan? "Re-scan" : "Reset", bus, target, lun);
+ scan? "Re-scan" : "Reset", mybus, mytarget, mylun);
return(0);
} else {
fprintf(stdout, "%s of %d:%d:%d returned error %#x\n",
- scan? "Re-scan" : "Reset", bus, target, lun,
+ scan? "Re-scan" : "Reset", mybus, mytarget, mylun,
ccb.ccb_h.status & CAM_STATUS_MASK);
return(1);
}
@@ -2042,7 +2039,7 @@
camdebug(int argc, char **argv, char *combinedopt)
{
int c, fd;
- int bus = -1, target = -1, lun = -1;
+ int mybus = -1, mytarget = -1, mylun = -1;
char *tstr, *tmpstr = NULL;
union ccb ccb;
int error = 0;
@@ -2108,15 +2105,15 @@
} else if (strncmp(tstr, "all", 3) != 0) {
tmpstr = (char *)strtok(tstr, ":");
if ((tmpstr != NULL) && (*tmpstr != '\0')){
- bus = strtol(tmpstr, NULL, 0);
+ mybus = strtol(tmpstr, NULL, 0);
arglist |= CAM_ARG_BUS;
tmpstr = (char *)strtok(NULL, ":");
if ((tmpstr != NULL) && (*tmpstr != '\0')){
- target = strtol(tmpstr, NULL, 0);
+ mytarget = strtol(tmpstr, NULL, 0);
arglist |= CAM_ARG_TARGET;
tmpstr = (char *)strtok(NULL, ":");
if ((tmpstr != NULL) && (*tmpstr != '\0')){
- lun = strtol(tmpstr, NULL, 0);
+ mylun = strtol(tmpstr, NULL, 0);
arglist |= CAM_ARG_LUN;
}
}
@@ -2130,9 +2127,9 @@
if (error == 0) {
ccb.ccb_h.func_code = XPT_DEBUG;
- ccb.ccb_h.path_id = bus;
- ccb.ccb_h.target_id = target;
- ccb.ccb_h.target_lun = lun;
+ ccb.ccb_h.path_id = mybus;
+ ccb.ccb_h.target_id = mytarget;
+ ccb.ccb_h.target_lun = mylun;
if (ioctl(fd, CAMIOCOMMAND, &ccb) == -1) {
warn("CAMIOCOMMAND ioctl failed");
@@ -2159,7 +2156,7 @@
fprintf(stderr,
"Debugging enabled for "
"%d:%d:%d\n",
- bus, target, lun);
+ mybus, mytarget, mylun);
}
}
}
@@ -2388,7 +2385,7 @@
cpi->version_num);
for (i = 1; i < 0xff; i = i << 1) {
- char *str;
+ const char *str;
if ((i & cpi->hba_inquiry) == 0)
continue;
@@ -2425,7 +2422,7 @@
}
for (i = 1; i < 0xff; i = i << 1) {
- char *str;
+ const char *str;
if ((i & cpi->hba_misc) == 0)
continue;
@@ -2454,7 +2451,7 @@
}
for (i = 1; i < 0xff; i = i << 1) {
- char *str;
+ const char *str;
if ((i & cpi->target_sprt) == 0)
continue;
@@ -3286,8 +3283,8 @@
int timeout = 0, retry_count = 1;
camcontrol_optret optreturn;
char *tstr;
- char *mainopt = "C:En:t:u:v";
- char *subopt = NULL;
+ const char *mainopt = "C:En:t:u:v";
+ const char *subopt = NULL;
char combinedopt[256];
int error = 0, optstart = 2;
int devopen = 1;
Index: camcontrol.h
===================================================================
RCS file: /home/dcvs/src/sbin/camcontrol/camcontrol.h,v
retrieving revision 1.2
diff -u -r1.2 camcontrol.h
--- camcontrol.h 17 Jun 2003 04:27:32 -0000 1.2
+++ camcontrol.h 11 Jan 2005 02:35:07 -0000
@@ -41,17 +41,13 @@
int got;
};
-void mode_sense(struct cam_device *device, int mode_page, int page_control,
- int dbd, int retry_count, int timeout, u_int8_t *data,
- int datalen);
-void mode_select(struct cam_device *device, int save_pages, int retry_count,
- int timeout, u_int8_t *data, int datalen);
-void mode_edit(struct cam_device *device, int page, int page_control, int dbd,
- int edit, int binary, int retry_count, int timeout);
-void mode_list(struct cam_device *device, int page_control, int dbd,
- int retry_count, int timeout);
-char *cget(void *hook, char *name);
-int iget(void *hook, char *name);
-void arg_put(void *hook, int letter, void *arg, int count, char *name);
-void usage(int verbose);
+void mode_sense(struct cam_device *, int, int, int, int, int, u_int8_t *,
+ int);
+void mode_select(struct cam_device *, int, int, int, u_int8_t *, int);
+void mode_edit(struct cam_device *, int, int, int, int, int, int, int);
+void mode_list(struct cam_device *, int, int, int, int);
+char *cget(void *, char *);
+int iget(void *, char *);
+void arg_put(void *, int, void *, int, char *);
+void usage(int);
#endif /* _CAMCONTROL_H */
Index: modeedit.c
===================================================================
RCS file: /home/dcvs/src/sbin/camcontrol/modeedit.c,v
retrieving revision 1.2
diff -u -r1.2 modeedit.c
--- modeedit.c 17 Jun 2003 04:27:32 -0000 1.2
+++ modeedit.c 11 Jan 2005 02:35:18 -0000
@@ -100,35 +100,24 @@
/* Function prototypes. */
-static void editentry_create(void *hook, int letter, void *arg,
- int count, char *name);
-static void editentry_update(void *hook, int letter, void *arg,
- int count, char *name);
-static int editentry_save(void *hook, char *name);
-static struct editentry *editentry_lookup(char *name);
-static int editentry_set(char *name, char *newvalue,
- int editonly);
-static void editlist_populate(struct cam_device *device,
- int modepage, int page_control,
- int dbd, int retries, int timeout);
-static void editlist_save(struct cam_device *device, int modepage,
- int page_control, int dbd, int retries,
- int timeout);
-static void nameentry_create(int pagenum, char *name);
-static struct pagename *nameentry_lookup(int pagenum);
-static int load_format(char *pagedb_path, int page);
-static int modepage_write(FILE *file, int editonly);
-static int modepage_read(FILE *file);
+static void editentry_create(void *, int, void *, int, char *);
+static void editentry_update(void *, int, void *, int, char *);
+static int editentry_save(void *, char *);
+static struct editentry *editentry_lookup(char *);
+static int editentry_set(char *, char *, int);
+static void editlist_populate(struct cam_device *, int, int, int,
+ int, int);
+static void editlist_save(struct cam_device *, int, int, int, int,
+ int);
+static void nameentry_create(int, char *);
+static struct pagename *nameentry_lookup(int);
+static int load_format(const char *, int);
+static int modepage_write(FILE *, int);
+static int modepage_read(FILE *);
static void modepage_edit(void);
-static void modepage_dump(struct cam_device *device, int page,
- int page_control, int dbd, int retries,
- int timeout);
+static void modepage_dump(struct cam_device *, int, int, int, int,
+ int);
static void cleanup_editfile(void);
-void mode_edit(struct cam_device *device, int page,
- int page_control, int dbd, int edit,
- int binary, int retry_count, int timeout);
-void mode_list(struct cam_device *device, int page_control,
- int dbd, int retry_count, int timeout);
#define returnerr(code) do { \
@@ -145,7 +134,8 @@
static void
-editentry_create(void *hook, int letter, void *arg, int count, char *name)
+editentry_create(void *hook __unused, int letter, void *arg, int count,
+ char *name)
{
struct editentry *newentry; /* Buffer to hold new entry. */
@@ -166,7 +156,8 @@
}
static void
-editentry_update(void *hook, int letter, void *arg, int count, char *name)
+editentry_update(void *hook __unused, int letter, void *arg, int count,
+ char *name)
{
struct editentry *dest; /* Buffer to hold entry to update. */
@@ -193,7 +184,7 @@
}
static int
-editentry_save(void *hook, char *name)
+editentry_save(void *hook __unused, char *name)
{
struct editentry *src; /* Entry value to save. */
@@ -290,13 +281,13 @@
strncpy(cval, newvalue, dest->size);
if (dest->type == 'z') {
/* Convert trailing spaces to nulls. */
- char *convertend;
+ char *conv_end;
- for (convertend = cval + dest->size;
- convertend >= cval; convertend--) {
- if (*convertend == ' ')
- *convertend = '\0';
- else if (*convertend != '\0')
+ for (conv_end = cval + dest->size;
+ conv_end >= cval; conv_end--) {
+ if (*conv_end == ' ')
+ *conv_end = '\0';
+ else if (*conv_end != '\0')
break;
}
}
@@ -355,7 +346,7 @@
}
static int
-load_format(char *pagedb_path, int page)
+load_format(const char *pagedb_path, int page)
{
FILE *pagedb;
char str_pagenum[MAX_PAGENUM_LEN];
@@ -717,7 +708,7 @@
static void
modepage_edit(void)
{
- char *editor;
+ const char *editor;
char *commandline;
int fd;
int written;
@@ -784,7 +775,7 @@
u_int8_t *mode_pars; /* Pointer to modepage params. */
struct scsi_mode_header_6 *mh; /* Location of mode header. */
struct scsi_mode_page_header *mph;
- int index; /* Index for scanning mode params. */
+ int mode_idx; /* Index for scanning mode params. */
mode_sense(device, page, page_control, dbd, retries, timeout, data,
sizeof(data));
@@ -794,9 +785,9 @@
mode_pars = MODE_PAGE_DATA(mph);
/* Print the raw mode page data with newlines each 8 bytes. */
- for (index = 0; index < mph->page_length; index++) {
- printf("%02x%c",mode_pars[index],
- (((index + 1) % 8) == 0) ? '\n' : ' ');
+ for (mode_idx = 0; mode_idx < mph->page_length; mode_idx++) {
+ printf("%02x%c", mode_pars[mode_idx],
+ (((mode_idx + 1) % 8) == 0) ? '\n' : ' ');
}
putchar('\n');
}
@@ -815,7 +806,7 @@
mode_edit(struct cam_device *device, int page, int page_control, int dbd,
int edit, int binary, int retry_count, int timeout)
{
- char *pagedb_path; /* Path to modepage database. */
+ const char *pagedb_path; /* Path to modepage database. */
if (edit && binary)
errx(EX_USAGE, "cannot edit in binary mode.");
@@ -873,7 +864,7 @@
struct scsi_mode_header_6 *mh; /* Location of mode header. */
struct scsi_mode_page_header *mph;
struct pagename *nameentry;
- char *pagedb_path;
+ const char *pagedb_path;
int len;
if ((pagedb_path = getenv("SCSI_MODES")) == NULL)
Index: util.c
===================================================================
RCS file: /home/dcvs/src/sbin/camcontrol/util.c,v
retrieving revision 1.2
diff -u -r1.2 util.c
--- util.c 17 Jun 2003 04:27:32 -0000 1.2
+++ util.c 9 Jan 2005 06:08:49 -0000
@@ -106,7 +106,7 @@
/* arg_put: "put argument" callback
*/
void
-arg_put(void *hook, int letter, void *arg, int count, char *name)
+arg_put(void *hook __unused, int letter, void *arg, int count, char *name)
{
if (verbose && name && *name)
printf("%s: ", name);
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]