mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-20 00:33:57 +00:00
Make this WARNS=6 clean by:
1: add 'const' to char * where needed; 2: mark unused variables with __unused; 3: remove double prototypes for mode_edit and mode_list. 4: moves the global variables 'bus', 'target', and 'lun' into the main function and protect them with #ifndef MINIMALISTIC, 5: renames 3 variable in order not to shadow other things index -> indx -- in modepage_dump since index is a function from <strings.h.> arglist -> arglst -- in the function parse_btl since arglist is also a global variable convertend -> convertend2 -- in the function editentry_set since that name is used two times within the function. 6: cast 0xffffffff in the macro RESOLUTION_MAX(size) to (int) since it is unsigned otherwise. Tested by: make universe Approved by: ken
This commit is contained in:
parent
ce9ab5a613
commit
398676131f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=118478
|
@ -7,7 +7,7 @@ SRCS+= modeedit.c
|
||||||
.else
|
.else
|
||||||
CFLAGS+= -DMINIMALISTIC
|
CFLAGS+= -DMINIMALISTIC
|
||||||
.endif
|
.endif
|
||||||
WARNS= 1
|
WARNS?= 6
|
||||||
DPADD= ${LIBCAM} ${LIBSBUF}
|
DPADD= ${LIBCAM} ${LIBSBUF}
|
||||||
LDADD= -lcam -lsbuf
|
LDADD= -lcam -lsbuf
|
||||||
MAN= camcontrol.8
|
MAN= camcontrol.8
|
||||||
|
|
|
@ -107,7 +107,7 @@ typedef enum {
|
||||||
} cam_argmask;
|
} cam_argmask;
|
||||||
|
|
||||||
struct camcontrol_opts {
|
struct camcontrol_opts {
|
||||||
char *optname;
|
const char *optname;
|
||||||
cam_cmdmask cmdnum;
|
cam_cmdmask cmdnum;
|
||||||
cam_argmask argnum;
|
cam_argmask argnum;
|
||||||
const char *subopt;
|
const char *subopt;
|
||||||
|
@ -160,11 +160,10 @@ typedef enum {
|
||||||
|
|
||||||
cam_cmdmask cmdlist;
|
cam_cmdmask cmdlist;
|
||||||
cam_argmask arglist;
|
cam_argmask arglist;
|
||||||
int bus, target, lun;
|
|
||||||
|
|
||||||
|
|
||||||
camcontrol_optret getoption(char *arg, cam_cmdmask *cmdnum, cam_argmask *argnum,
|
camcontrol_optret getoption(char *arg, cam_cmdmask *cmdnum, cam_argmask *argnum,
|
||||||
char **subopt);
|
const char **subopt);
|
||||||
#ifndef MINIMALISTIC
|
#ifndef MINIMALISTIC
|
||||||
static int getdevlist(struct cam_device *device);
|
static int getdevlist(struct cam_device *device);
|
||||||
static int getdevtree(void);
|
static int getdevtree(void);
|
||||||
|
@ -179,7 +178,7 @@ static int scsiserial(struct cam_device *device, int retry_count, int timeout);
|
||||||
static int scsixferrate(struct cam_device *device);
|
static int scsixferrate(struct cam_device *device);
|
||||||
#endif /* MINIMALISTIC */
|
#endif /* MINIMALISTIC */
|
||||||
static int parse_btl(char *tstr, int *bus, int *target, int *lun,
|
static int parse_btl(char *tstr, int *bus, int *target, int *lun,
|
||||||
cam_argmask *arglist);
|
cam_argmask *arglst);
|
||||||
static int dorescan_or_reset(int argc, char **argv, int rescan);
|
static int dorescan_or_reset(int argc, char **argv, int rescan);
|
||||||
static int rescan_or_reset_bus(int bus, 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 scanlun_or_reset_dev(int bus, int target, int lun, int scan);
|
||||||
|
@ -205,7 +204,8 @@ static int scsiformat(struct cam_device *device, int argc, char **argv,
|
||||||
#endif /* MINIMALISTIC */
|
#endif /* MINIMALISTIC */
|
||||||
|
|
||||||
camcontrol_optret
|
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;
|
struct camcontrol_opts *opts;
|
||||||
int num_matches = 0;
|
int num_matches = 0;
|
||||||
|
@ -215,7 +215,7 @@ getoption(char *arg, cam_cmdmask *cmdnum, cam_argmask *argnum, char **subopt)
|
||||||
if (strncmp(opts->optname, arg, strlen(arg)) == 0) {
|
if (strncmp(opts->optname, arg, strlen(arg)) == 0) {
|
||||||
*cmdnum = opts->cmdnum;
|
*cmdnum = opts->cmdnum;
|
||||||
*argnum = opts->argnum;
|
*argnum = opts->argnum;
|
||||||
*subopt = (char *)opts->subopt;
|
*subopt = opts->subopt;
|
||||||
if (++num_matches > 1)
|
if (++num_matches > 1)
|
||||||
return(CC_OR_AMBIGUOUS);
|
return(CC_OR_AMBIGUOUS);
|
||||||
}
|
}
|
||||||
|
@ -952,7 +952,7 @@ scsixferrate(struct cam_device *device)
|
||||||
* Returns the number of parsed components, or 0.
|
* Returns the number of parsed components, or 0.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
parse_btl(char *tstr, int *bus, int *target, int *lun, cam_argmask *arglist)
|
parse_btl(char *tstr, int *bus, int *target, int *lun, cam_argmask *arglst)
|
||||||
{
|
{
|
||||||
char *tmpstr;
|
char *tmpstr;
|
||||||
int convs = 0;
|
int convs = 0;
|
||||||
|
@ -963,17 +963,17 @@ parse_btl(char *tstr, int *bus, int *target, int *lun, cam_argmask *arglist)
|
||||||
tmpstr = (char *)strtok(tstr, ":");
|
tmpstr = (char *)strtok(tstr, ":");
|
||||||
if ((tmpstr != NULL) && (*tmpstr != '\0')) {
|
if ((tmpstr != NULL) && (*tmpstr != '\0')) {
|
||||||
*bus = strtol(tmpstr, NULL, 0);
|
*bus = strtol(tmpstr, NULL, 0);
|
||||||
*arglist |= CAM_ARG_BUS;
|
*arglst |= CAM_ARG_BUS;
|
||||||
convs++;
|
convs++;
|
||||||
tmpstr = (char *)strtok(NULL, ":");
|
tmpstr = (char *)strtok(NULL, ":");
|
||||||
if ((tmpstr != NULL) && (*tmpstr != '\0')) {
|
if ((tmpstr != NULL) && (*tmpstr != '\0')) {
|
||||||
*target = strtol(tmpstr, NULL, 0);
|
*target = strtol(tmpstr, NULL, 0);
|
||||||
*arglist |= CAM_ARG_TARGET;
|
*arglst |= CAM_ARG_TARGET;
|
||||||
convs++;
|
convs++;
|
||||||
tmpstr = (char *)strtok(NULL, ":");
|
tmpstr = (char *)strtok(NULL, ":");
|
||||||
if ((tmpstr != NULL) && (*tmpstr != '\0')) {
|
if ((tmpstr != NULL) && (*tmpstr != '\0')) {
|
||||||
*lun = strtol(tmpstr, NULL, 0);
|
*lun = strtol(tmpstr, NULL, 0);
|
||||||
*arglist |= CAM_ARG_LUN;
|
*arglst |= CAM_ARG_LUN;
|
||||||
convs++;
|
convs++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2349,7 +2349,7 @@ cpi_print(struct ccb_pathinq *cpi)
|
||||||
cpi->version_num);
|
cpi->version_num);
|
||||||
|
|
||||||
for (i = 1; i < 0xff; i = i << 1) {
|
for (i = 1; i < 0xff; i = i << 1) {
|
||||||
char *str;
|
const char *str;
|
||||||
|
|
||||||
if ((i & cpi->hba_inquiry) == 0)
|
if ((i & cpi->hba_inquiry) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -2386,7 +2386,7 @@ cpi_print(struct ccb_pathinq *cpi)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 1; i < 0xff; i = i << 1) {
|
for (i = 1; i < 0xff; i = i << 1) {
|
||||||
char *str;
|
const char *str;
|
||||||
|
|
||||||
if ((i & cpi->hba_misc) == 0)
|
if ((i & cpi->hba_misc) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -2415,7 +2415,7 @@ cpi_print(struct ccb_pathinq *cpi)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 1; i < 0xff; i = i << 1) {
|
for (i = 1; i < 0xff; i = i << 1) {
|
||||||
char *str;
|
const char *str;
|
||||||
|
|
||||||
if ((i & cpi->target_sprt) == 0)
|
if ((i & cpi->target_sprt) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -3264,11 +3264,14 @@ main(int argc, char **argv)
|
||||||
int timeout = 0, retry_count = 1;
|
int timeout = 0, retry_count = 1;
|
||||||
camcontrol_optret optreturn;
|
camcontrol_optret optreturn;
|
||||||
char *tstr;
|
char *tstr;
|
||||||
char *mainopt = "C:En:t:u:v";
|
const char *mainopt = "C:En:t:u:v";
|
||||||
char *subopt = NULL;
|
const char *subopt = NULL;
|
||||||
char combinedopt[256];
|
char combinedopt[256];
|
||||||
int error = 0, optstart = 2;
|
int error = 0, optstart = 2;
|
||||||
int devopen = 1;
|
int devopen = 1;
|
||||||
|
#ifndef MINIMALISTIC
|
||||||
|
int bus, target, lun;
|
||||||
|
#endif /* MINIMALISTIC */
|
||||||
|
|
||||||
cmdlist = CAM_CMD_NONE;
|
cmdlist = CAM_CMD_NONE;
|
||||||
arglist = CAM_ARG_NONE;
|
arglist = CAM_ARG_NONE;
|
||||||
|
|
|
@ -116,7 +116,7 @@ static void editlist_save(struct cam_device *device, int modepage,
|
||||||
int timeout);
|
int timeout);
|
||||||
static void nameentry_create(int pagenum, char *name);
|
static void nameentry_create(int pagenum, char *name);
|
||||||
static struct pagename *nameentry_lookup(int pagenum);
|
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_write(FILE *file, int editonly);
|
||||||
static int modepage_read(FILE *file);
|
static int modepage_read(FILE *file);
|
||||||
static void modepage_edit(void);
|
static void modepage_edit(void);
|
||||||
|
@ -124,11 +124,6 @@ static void modepage_dump(struct cam_device *device, int page,
|
||||||
int page_control, int dbd, int retries,
|
int page_control, int dbd, int retries,
|
||||||
int timeout);
|
int timeout);
|
||||||
static void cleanup_editfile(void);
|
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 { \
|
#define returnerr(code) do { \
|
||||||
|
@ -145,7 +140,8 @@ void mode_list(struct cam_device *device, int page_control,
|
||||||
|
|
||||||
|
|
||||||
static void
|
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. */
|
struct editentry *newentry; /* Buffer to hold new entry. */
|
||||||
|
|
||||||
|
@ -166,7 +162,8 @@ editentry_create(void *hook, int letter, void *arg, int count, char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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. */
|
struct editentry *dest; /* Buffer to hold entry to update. */
|
||||||
|
|
||||||
|
@ -193,7 +190,7 @@ editentry_update(void *hook, int letter, void *arg, int count, char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
editentry_save(void *hook, char *name)
|
editentry_save(void *hook __unused, char *name)
|
||||||
{
|
{
|
||||||
struct editentry *src; /* Entry value to save. */
|
struct editentry *src; /* Entry value to save. */
|
||||||
|
|
||||||
|
@ -251,7 +248,7 @@ editentry_set(char *name, char *newvalue, int editonly)
|
||||||
* currently workaround it (even for int64's), so we have to kludge it.
|
* currently workaround it (even for int64's), so we have to kludge it.
|
||||||
*/
|
*/
|
||||||
#define RESOLUTION_MAX(size) ((resolution * (size) == 32)? \
|
#define RESOLUTION_MAX(size) ((resolution * (size) == 32)? \
|
||||||
0xffffffff: (1 << (resolution * (size))) - 1)
|
(int)0xffffffff: (1 << (resolution * (size))) - 1)
|
||||||
|
|
||||||
assert(newvalue != NULL);
|
assert(newvalue != NULL);
|
||||||
if (*newvalue == '\0')
|
if (*newvalue == '\0')
|
||||||
|
@ -290,13 +287,13 @@ editentry_set(char *name, char *newvalue, int editonly)
|
||||||
strncpy(cval, newvalue, dest->size);
|
strncpy(cval, newvalue, dest->size);
|
||||||
if (dest->type == 'z') {
|
if (dest->type == 'z') {
|
||||||
/* Convert trailing spaces to nulls. */
|
/* Convert trailing spaces to nulls. */
|
||||||
char *convertend;
|
char *convertend2;
|
||||||
|
|
||||||
for (convertend = cval + dest->size;
|
for (convertend2 = cval + dest->size;
|
||||||
convertend >= cval; convertend--) {
|
convertend2 >= cval; convertend2--) {
|
||||||
if (*convertend == ' ')
|
if (*convertend2 == ' ')
|
||||||
*convertend = '\0';
|
*convertend2 = '\0';
|
||||||
else if (*convertend != '\0')
|
else if (*convertend2 != '\0')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -355,7 +352,7 @@ nameentry_lookup(int pagenum) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
load_format(char *pagedb_path, int page)
|
load_format(const char *pagedb_path, int page)
|
||||||
{
|
{
|
||||||
FILE *pagedb;
|
FILE *pagedb;
|
||||||
char str_pagenum[MAX_PAGENUM_LEN];
|
char str_pagenum[MAX_PAGENUM_LEN];
|
||||||
|
@ -717,7 +714,7 @@ modepage_read(FILE *file)
|
||||||
static void
|
static void
|
||||||
modepage_edit(void)
|
modepage_edit(void)
|
||||||
{
|
{
|
||||||
char *editor;
|
const char *editor;
|
||||||
char *commandline;
|
char *commandline;
|
||||||
int fd;
|
int fd;
|
||||||
int written;
|
int written;
|
||||||
|
@ -784,7 +781,7 @@ modepage_dump(struct cam_device *device, int page, int page_control, int dbd,
|
||||||
u_int8_t *mode_pars; /* Pointer to modepage params. */
|
u_int8_t *mode_pars; /* Pointer to modepage params. */
|
||||||
struct scsi_mode_header_6 *mh; /* Location of mode header. */
|
struct scsi_mode_header_6 *mh; /* Location of mode header. */
|
||||||
struct scsi_mode_page_header *mph;
|
struct scsi_mode_page_header *mph;
|
||||||
int index; /* Index for scanning mode params. */
|
int indx; /* Index for scanning mode params. */
|
||||||
|
|
||||||
mode_sense(device, page, page_control, dbd, retries, timeout, data,
|
mode_sense(device, page, page_control, dbd, retries, timeout, data,
|
||||||
sizeof(data));
|
sizeof(data));
|
||||||
|
@ -794,9 +791,9 @@ modepage_dump(struct cam_device *device, int page, int page_control, int dbd,
|
||||||
mode_pars = MODE_PAGE_DATA(mph);
|
mode_pars = MODE_PAGE_DATA(mph);
|
||||||
|
|
||||||
/* Print the raw mode page data with newlines each 8 bytes. */
|
/* Print the raw mode page data with newlines each 8 bytes. */
|
||||||
for (index = 0; index < mph->page_length; index++) {
|
for (indx = 0; indx < mph->page_length; indx++) {
|
||||||
printf("%02x%c",mode_pars[index],
|
printf("%02x%c",mode_pars[indx],
|
||||||
(((index + 1) % 8) == 0) ? '\n' : ' ');
|
(((indx + 1) % 8) == 0) ? '\n' : ' ');
|
||||||
}
|
}
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
}
|
}
|
||||||
|
@ -815,7 +812,7 @@ void
|
||||||
mode_edit(struct cam_device *device, int page, int page_control, int dbd,
|
mode_edit(struct cam_device *device, int page, int page_control, int dbd,
|
||||||
int edit, int binary, int retry_count, int timeout)
|
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)
|
if (edit && binary)
|
||||||
errx(EX_USAGE, "cannot edit in binary mode.");
|
errx(EX_USAGE, "cannot edit in binary mode.");
|
||||||
|
@ -873,7 +870,7 @@ mode_list(struct cam_device *device, int page_control, int dbd,
|
||||||
struct scsi_mode_header_6 *mh; /* Location of mode header. */
|
struct scsi_mode_header_6 *mh; /* Location of mode header. */
|
||||||
struct scsi_mode_page_header *mph;
|
struct scsi_mode_page_header *mph;
|
||||||
struct pagename *nameentry;
|
struct pagename *nameentry;
|
||||||
char *pagedb_path;
|
const char *pagedb_path;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if ((pagedb_path = getenv("SCSI_MODES")) == NULL)
|
if ((pagedb_path = getenv("SCSI_MODES")) == NULL)
|
||||||
|
|
|
@ -107,7 +107,7 @@ cget(void *hook, char *name)
|
||||||
/* arg_put: "put argument" callback
|
/* arg_put: "put argument" callback
|
||||||
*/
|
*/
|
||||||
void
|
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)
|
if (verbose && name && *name)
|
||||||
printf("%s: ", name);
|
printf("%s: ", name);
|
||||||
|
|
Loading…
Reference in a new issue