DragonFly submit List (threaded) for 2005-01
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
Re: camcontrol WARNS6 and style(9): take 3
Simon 'corecode' Schubert wrote:
should be WARNS?= 6
I would remove parameter names here:
more space after commas! :)
Done, done, and done. Some other style(9) issues fixed, too. Patch below.
--
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 10 Jan 2005 05:45:47 -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 = (const char *)opts->subopt;
if (++num_matches > 1)
return(CC_OR_AMBIGUOUS);
}
@@ -565,9 +560,9 @@
if (startstop) {
fprintf(stdout, "Unit started successfully");
if (loadeject)
- fprintf(stdout,", Media loaded\n");
+ fprintf(stdout, ", Media loaded\n");
else
- fprintf(stdout,"\n");
+ fprintf(stdout, "\n");
} else {
fprintf(stdout, "Unit stopped successfully");
if (loadeject)
@@ -684,7 +679,7 @@
* - The SCSI spec says that when a length field is only 1 byte,
* a value of 0 will be interpreted as 256. Therefore
* scsi_inquiry() will convert an inq_len (which is passed in as
- * a u_int32_t, but the field in the CDB is only 1 byte) of 256
+ * a uint32_t, but the field in the CDB is only 1 byte) of 256
* to 0. Evidently, very few devices meet the spec in that
* regard. Some devices, like many Seagate disks, take the 0 as
* 0, and don't return any data. One Pioneer DVD-R drive
@@ -712,7 +707,7 @@
/* retries */ retry_count,
/* cbfcnp */ NULL,
/* tag_action */ MSG_SIMPLE_Q_TAG,
- /* inq_buf */ (u_int8_t *)inq_buf,
+ /* inq_buf */ (uint8_t *)inq_buf,
/* inq_len */ SHORT_INQUIRY_LENGTH,
/* evpd */ 0,
/* page_code */ 0,
@@ -802,7 +797,7 @@
/*retries*/ retry_count,
/*cbfcnp*/ NULL,
/* tag_action */ MSG_SIMPLE_Q_TAG,
- /* inq_buf */ (u_int8_t *)serial_buf,
+ /* inq_buf */ (uint8_t *)serial_buf,
/* inq_len */ sizeof(*serial_buf),
/* evpd */ 1,
/* page_code */ SVPD_UNIT_SERIAL_NUMBER,
@@ -870,10 +865,10 @@
static int
scsixferrate(struct cam_device *device)
{
- u_int32_t freq;
- u_int32_t speed;
+ uint32_t freq;
+ uint32_t speed;
union ccb *ccb;
- u_int mb;
+ uint mb;
int retval = 0;
ccb = cam_getccb(device);
@@ -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);
}
@@ -1315,11 +1312,11 @@
{
union ccb *ccb = NULL;
struct scsi_read_defect_data_10 *rdd_cdb;
- u_int8_t *defect_list = NULL;
- u_int32_t dlist_length = 65000;
- u_int32_t returned_length = 0;
- u_int32_t num_returned = 0;
- u_int8_t returned_format;
+ uint8_t *defect_list = NULL;
+ uint32_t dlist_length = 65000;
+ uint32_t returned_length = 0;
+ uint32_t num_returned = 0;
+ uint8_t returned_format;
unsigned int i;
int c, error = 0;
int lists_specified = 0;
@@ -1597,7 +1594,7 @@
#if 0
void
-reassignblocks(struct cam_device *device, u_int32_t *blocks, int
num_blocks)
+reassignblocks(struct cam_device *device, uint32_t *blocks, int num_blocks)
{
union ccb *ccb;
@@ -1610,7 +1607,7 @@
#ifndef MINIMALISTIC
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)
+ int dbd, int retry_count, int timeout, uint8_t *data, int datalen)
{
union ccb *ccb;
int retval;
@@ -1664,7 +1661,7 @@
void
mode_select(struct cam_device *device, int save_pages, int retry_count,
- int timeout, u_int8_t *data, int datalen)
+ int timeout, uint8_t *data, int datalen)
{
union ccb *ccb;
int retval;
@@ -1773,9 +1770,9 @@
int retry_count, int timeout)
{
union ccb *ccb;
- u_int32_t flags = CAM_DIR_NONE;
- u_int8_t *data_ptr = NULL;
- u_int8_t cdb[20];
+ uint32_t flags = CAM_DIR_NONE;
+ uint8_t *data_ptr = NULL;
+ uint8_t cdb[20];
struct get_hook hook;
int c, data_bytes = 0;
int cdb_len = 0;
@@ -1847,7 +1844,7 @@
&& (datastr[0] == '-'))
fd_data = 1;
- data_ptr = (u_int8_t *)malloc(data_bytes);
+ data_ptr = (uint8_t *)malloc(data_bytes);
if (data_ptr == NULL) {
warnx("can't malloc memory for data_ptr");
error = 1;
@@ -1874,7 +1871,7 @@
hook.argv = argv + optind;
hook.got = 0;
datastr = cget(&hook, NULL);
- data_ptr = (u_int8_t *)malloc(data_bytes);
+ data_ptr = (uint8_t *)malloc(data_bytes);
if (data_ptr == NULL) {
warnx("can't malloc memory for data_ptr");
error = 1;
@@ -1904,7 +1901,7 @@
if ((fd_data == 1) && (arglist & CAM_ARG_CMD_OUT)) {
ssize_t amt_read;
int amt_to_read = data_bytes;
- u_int8_t *buf_ptr = data_ptr;
+ uint8_t *buf_ptr = data_ptr;
for (amt_read = 0; amt_to_read > 0;
amt_read = read(STDIN_FILENO, buf_ptr, amt_to_read)) {
@@ -2009,10 +2006,11 @@
} else {
ssize_t amt_written;
int amt_to_write = data_bytes;
- u_int8_t *buf_ptr = data_ptr;
+ uint8_t *buf_ptr = data_ptr;
for (amt_written = 0; (amt_to_write > 0) &&
- (amt_written =write(1, buf_ptr,amt_to_write))> 0;){
+ (amt_written = write(1, buf_ptr, amt_to_write))
+ > 0;) {
amt_to_write -= amt_written;
buf_ptr += amt_written;
}
@@ -2042,7 +2040,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;
@@ -2103,20 +2101,20 @@
if (strncmp(tstr, "off", 3) == 0) {
ccb.cdbg.flags = CAM_DEBUG_NONE;
arglist &= ~(CAM_ARG_DEBUG_INFO|CAM_ARG_DEBUG_PERIPH|
- CAM_ARG_DEBUG_TRACE|CAM_ARG_DEBUG_SUBTRACE|
- CAM_ARG_DEBUG_XPT);
+ CAM_ARG_DEBUG_TRACE|CAM_ARG_DEBUG_SUBTRACE|
+ CAM_ARG_DEBUG_XPT);
} 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 +2128,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 +2157,7 @@
fprintf(stderr,
"Debugging enabled for "
"%d:%d:%d\n",
- bus, target, lun);
+ mybus, mytarget, mylun);
}
}
}
@@ -2295,7 +2293,7 @@
cts->sync_period);
if (cts->sync_offset != 0) {
- u_int freq;
+ uint freq;
freq = scsi_calc_syncsrate(cts->sync_period);
fprintf(stdout, "%sfrequency: %d.%03dMHz\n", pathstr,
@@ -2388,7 +2386,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 +2423,7 @@
}
for (i = 1; i < 0xff; i = i << 1) {
- char *str;
+ const char *str;
if ((i & cpi->hba_misc) == 0)
continue;
@@ -2454,7 +2452,7 @@
}
for (i = 1; i < 0xff; i = i << 1) {
- char *str;
+ const char *str;
if ((i & cpi->target_sprt) == 0)
continue;
@@ -2735,7 +2733,7 @@
if (syncrate != -1) {
int prelim_sync_period;
- u_int freq;
+ uint freq;
if ((cpi.hba_inquiry & PI_SDTR_ABLE) == 0) {
warnx("HBA at %s%d is not cable of changing "
@@ -2868,9 +2866,9 @@
int use_timeout = 10800 * 1000;
int immediate = 1;
struct format_defect_list_header fh;
- u_int8_t *data_ptr = NULL;
- u_int32_t dxfer_len = 0;
- u_int8_t byte2 = 0;
+ uint8_t *data_ptr = NULL;
+ uint32_t dxfer_len = 0;
+ uint8_t byte2 = 0;
int num_warnings = 0;
ccb = cam_getccb(device);
@@ -2983,7 +2981,7 @@
*/
if (immediate != 0) {
fh.byte2 = FU_DLH_IMMED;
- data_ptr = (u_int8_t *)&fh;
+ data_ptr = (uint8_t *)&fh;
dxfer_len = sizeof(fh);
byte2 = FU_FMT_DATA;
} else if (quiet == 0) {
@@ -3110,7 +3108,7 @@
SSD_SCS_VALID) != 0)
&& (quiet == 0)) {
int val;
- u_int64_t percentage;
+ uint64_t percentage;
val = scsi_2btoul(
&sense->sense_key_spec[1]);
@@ -3286,8 +3284,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;
@@ -3478,9 +3476,10 @@
if ((cam_dev = ((arglist & (CAM_ARG_BUS | CAM_ARG_TARGET))?
cam_open_btl(bus, target, lun, O_RDWR, NULL) :
- cam_open_spec_device(device,unit,O_RDWR,NULL)))
+ cam_open_spec_device(device, unit, O_RDWR,
+ NULL)))
== NULL)
- errx(1,"%s", cam_errbuf);
+ errx(1, "%s", cam_errbuf);
}
#endif /* MINIMALISTIC */
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 10 Jan 2005 05:33:47 -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, uint8_t *,
+ int);
+void mode_select(struct cam_device *, int, int, int, uint8_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 10 Jan 2005 05:46:05 -0000
@@ -69,7 +69,7 @@
(struct scsi_mode_page_header *)find_mode_page_6(mh)
#define MODE_PAGE_DATA(mph) \
- (u_int8_t *)(mph) + sizeof(struct scsi_mode_page_header)
+ (uint8_t *)(mph) + sizeof(struct scsi_mode_page_header)
struct editentry {
@@ -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];
@@ -530,8 +521,8 @@
editlist_populate(struct cam_device *device, int modepage, int
page_control,
int dbd, int retries, int timeout)
{
- u_int8_t data[MAX_COMMAND_SIZE];/* Buffer to hold sense data. */
- u_int8_t *mode_pars; /* Pointer to modepage params. */
+ uint8_t data[MAX_COMMAND_SIZE];/* Buffer to hold sense data. */
+ uint8_t *mode_pars; /* Pointer to modepage params. */
struct scsi_mode_header_6 *mh; /* Location of mode header. */
struct scsi_mode_page_header *mph;
@@ -560,8 +551,8 @@
editlist_save(struct cam_device *device, int modepage, int page_control,
int dbd, int retries, int timeout)
{
- u_int8_t data[MAX_COMMAND_SIZE];/* Buffer to hold sense data. */
- u_int8_t *mode_pars; /* Pointer to modepage params. */
+ uint8_t data[MAX_COMMAND_SIZE];/* Buffer to hold sense data. */
+ uint8_t *mode_pars; /* Pointer to modepage params. */
struct scsi_mode_header_6 *mh; /* Location of mode header. */
struct scsi_mode_page_header *mph;
@@ -588,7 +579,7 @@
editentry_save, 0);
/* Eliminate block descriptors. */
- bcopy(mph, ((u_int8_t *)mh) + sizeof(*mh),
+ bcopy(mph, ((uint8_t *)mh) + sizeof(*mh),
sizeof(*mph) + mph->page_length);
/* Recalculate headers & offsets. */
@@ -607,7 +598,7 @@
*/
mode_select(device,
(page_control << PAGE_CTRL_SHIFT == SMS_PAGE_CTRL_SAVED),
- retries, timeout, (u_int8_t *)mh,
+ retries, timeout, (uint8_t *)mh,
sizeof(*mh) + mh->blk_desc_len + sizeof(*mph) + mph->page_length);
}
@@ -717,7 +708,7 @@
static void
modepage_edit(void)
{
- char *editor;
+ const char *editor;
char *commandline;
int fd;
int written;
@@ -780,11 +771,11 @@
modepage_dump(struct cam_device *device, int page, int page_control,
int dbd,
int retries, int timeout)
{
- u_int8_t data[MAX_COMMAND_SIZE];/* Buffer to hold sense data. */
- u_int8_t *mode_pars; /* Pointer to modepage params. */
+ uint8_t data[MAX_COMMAND_SIZE];/* Buffer to hold sense data. */
+ uint8_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.");
@@ -868,12 +859,12 @@
mode_list(struct cam_device *device, int page_control, int dbd,
int retry_count, int timeout)
{
- u_int8_t data[MAX_COMMAND_SIZE];/* Buffer to hold sense data. */
- u_int8_t *mode_pars; /* Pointer to modepage params. */
+ uint8_t data[MAX_COMMAND_SIZE];/* Buffer to hold sense data. */
+ uint8_t *mode_pars; /* Pointer to modepage params. */
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]