DragonFly submit List (threaded) for 2005-01
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
camcontrol WARNS6 cleanup: take 2
Sorry, newbie at work. Resubmitting as unified diff, with only
the renamed locals version of camcontrol.c. Thanks for the
patience.
--
LarryLansing
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 03:48:48 -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 9 Jan 2005 07:54:04 -0000
@@ -105,7 +105,7 @@
} cam_argmask;
struct camcontrol_opts {
- char *optname;
+ const char *optname;
cam_cmdmask cmdnum;
cam_argmask argnum;
const char *subopt;
@@ -162,7 +162,7 @@
camcontrol_optret getoption(char *arg, cam_cmdmask *cmdnum, cam_argmask *argnum,
- char **subopt);
+ const char **subopt);
#ifndef MINIMALISTIC
static int getdevlist(struct cam_device *device);
static int getdevtree(void);
@@ -176,11 +176,11 @@
static int scsiserial(struct cam_device *device, int retry_count, int timeout);
static int scsixferrate(struct cam_device *device);
#endif /* MINIMALISTIC */
-static int parse_btl(char *tstr, int *bus, int *target, int *lun,
- cam_argmask *arglist);
+static int parse_btl(char *tstr, int *mybus, int *mytarget, int *mylun,
+ cam_argmask *myarglist);
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 rescan_or_reset_bus(int mybus, int rescan);
+static int scanlun_or_reset_dev(int mybus, int mytarget, int mylun, int scan);
#ifndef MINIMALISTIC
static int readdefects(struct cam_device *device, int argc, char **argv,
char *combinedopt, int retry_count, int timeout);
@@ -203,7 +203,8 @@
#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 +214,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);
}
@@ -986,7 +987,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 +998,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 +1024,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 +1038,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 +1049,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 +1071,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 +1089,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 +1223,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 +1231,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 +1258,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 +1266,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 +1301,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 +2045,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 +2106,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 +2133,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 +2162,7 @@
fprintf(stderr,
"Debugging enabled for "
"%d:%d:%d\n",
- bus, target, lun);
+ mybus, mytarget, mylun);
}
}
}
@@ -2388,7 +2391,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 +2428,7 @@
}
for (i = 1; i < 0xff; i = i << 1) {
- char *str;
+ const char *str;
if ((i & cpi->hba_misc) == 0)
continue;
@@ -2454,7 +2457,7 @@
}
for (i = 1; i < 0xff; i = i << 1) {
- char *str;
+ const char *str;
if ((i & cpi->target_sprt) == 0)
continue;
@@ -3286,8 +3289,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: 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 9 Jan 2005 06:23:57 -0000
@@ -116,7 +116,7 @@
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 load_format(const char *pagedb_path, int page);
static int modepage_write(FILE *file, int editonly);
static int modepage_read(FILE *file);
static void modepage_edit(void);
@@ -124,11 +124,6 @@
int page_control, int dbd, int retries,
int timeout);
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 +140,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 +162,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 +190,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 +287,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 +352,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 +714,7 @@
static void
modepage_edit(void)
{
- char *editor;
+ const char *editor;
char *commandline;
int fd;
int written;
@@ -784,7 +781,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 +791,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 +812,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 +870,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]