mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-27 17:52:43 +00:00
Const'ify the CDB format string passed to the CDB parsing routines
(csio_decode_visit() and family). Reviewed by: ken
This commit is contained in:
parent
7e1f6dfe9d
commit
cb28eb78cb
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=88090
@ -88,7 +88,7 @@
|
||||
.Fa "u_int32_t flags"
|
||||
.Fa "int retry_count"
|
||||
.Fa "int timeout"
|
||||
.Fa "char *cmd_spec"
|
||||
.Fa "const char *cmd_spec"
|
||||
.Fa "..."
|
||||
.Fc
|
||||
.Ft int
|
||||
@ -99,20 +99,20 @@
|
||||
.Fa "u_int32_t flags"
|
||||
.Fa "int retry_count"
|
||||
.Fa "int timeout"
|
||||
.Fa "char *cmd_spec"
|
||||
.Fa "const char *cmd_spec"
|
||||
.Fa "int (*arg_get)(void *hook, char *field_name)"
|
||||
.Fa "void *gethook"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo csio_decode
|
||||
.Fa "struct ccb_scsiio *csio"
|
||||
.Fa "char *fmt"
|
||||
.Fa "const char *fmt"
|
||||
.Fa "..."
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo csio_decode_visit
|
||||
.Fa "struct ccb_scsiio *csio"
|
||||
.Fa "char *fmt"
|
||||
.Fa "const char *fmt"
|
||||
.Fa "void (*arg_put)(void *hook"
|
||||
.Fa "int letter"
|
||||
.Fa "void *val"
|
||||
@ -124,27 +124,27 @@
|
||||
.Fo buff_decode
|
||||
.Fa "u_int8_t *buff"
|
||||
.Fa "size_t len"
|
||||
.Fa "char *fmt"
|
||||
.Fa "const char *fmt"
|
||||
.Fa "..."
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo buff_decode_visit
|
||||
.Fa "u_int8_t *buff"
|
||||
.Fa "size_t len"
|
||||
.Fa "char *fmt"
|
||||
.Fa "const char *fmt"
|
||||
.Fa "void (*arg_put)(void *, int, void *, int, char *)"
|
||||
.Fa "void *puthook"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo csio_encode
|
||||
.Fa "struct ccb_scsiio *csio"
|
||||
.Fa "char *fmt"
|
||||
.Fa "const char *fmt"
|
||||
.Fa "..."
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo csio_encode_visit
|
||||
.Fa "struct ccb_scsiio *csio"
|
||||
.Fa "char *fmt"
|
||||
.Fa "const char *fmt"
|
||||
.Fa "int (*arg_get)(void *hook, char *field_name)"
|
||||
.Fa "void *gethook"
|
||||
.Fc
|
||||
@ -152,7 +152,7 @@
|
||||
.Fo buff_encode_visit
|
||||
.Fa "u_int8_t *buff"
|
||||
.Fa "size_t len"
|
||||
.Fa "char *fmt"
|
||||
.Fa "const char *fmt"
|
||||
.Fa "int (*arg_get)(void *hook, char *field_name)"
|
||||
.Fa "void *gethook"
|
||||
.Fc
|
||||
|
@ -150,27 +150,30 @@ int cam_get_device(const char *path, char *dev_name,
|
||||
/*
|
||||
* Buffer encoding/decoding routines, from the old SCSI library.
|
||||
*/
|
||||
int csio_decode(struct ccb_scsiio *csio, char *fmt, ...) __printflike(2, 3);
|
||||
int csio_decode_visit(struct ccb_scsiio *csio, char *fmt,
|
||||
int csio_decode(struct ccb_scsiio *csio, const char *fmt, ...)
|
||||
__printflike(2, 3);
|
||||
int csio_decode_visit(struct ccb_scsiio *csio, const char *fmt,
|
||||
void (*arg_put)(void *, int, void *, int, char *),
|
||||
void *puthook);
|
||||
int buff_decode(u_int8_t *buff, size_t len, char *fmt, ...) __printflike(3, 4);
|
||||
int buff_decode_visit(u_int8_t *buff, size_t len, char *fmt,
|
||||
int buff_decode(u_int8_t *buff, size_t len, const char *fmt, ...)
|
||||
__printflike(3, 4);
|
||||
int buff_decode_visit(u_int8_t *buff, size_t len, const char *fmt,
|
||||
void (*arg_put)(void *, int, void *, int, char *),
|
||||
void *puthook);
|
||||
int csio_build(struct ccb_scsiio *csio, u_int8_t *data_ptr,
|
||||
u_int32_t dxfer_len, u_int32_t flags, int retry_count,
|
||||
int timeout, char *cmd_spec, ...);
|
||||
int timeout, const char *cmd_spec, ...);
|
||||
int csio_build_visit(struct ccb_scsiio *csio, u_int8_t *data_ptr,
|
||||
u_int32_t dxfer_len, u_int32_t flags, int retry_count,
|
||||
int timeout, char *cmd_spec,
|
||||
int timeout, const char *cmd_spec,
|
||||
int (*arg_get)(void *hook, char *field_name),
|
||||
void *gethook);
|
||||
int csio_encode(struct ccb_scsiio *csio, char *fmt, ...) __printflike(2, 3);
|
||||
int buff_encode_visit(u_int8_t *buff, size_t len, char *fmt,
|
||||
int csio_encode(struct ccb_scsiio *csio, const char *fmt, ...)
|
||||
__printflike(2, 3);
|
||||
int buff_encode_visit(u_int8_t *buff, size_t len, const char *fmt,
|
||||
int (*arg_get)(void *hook, char *field_name),
|
||||
void *gethook);
|
||||
int csio_encode_visit(struct ccb_scsiio *csio, char *fmt,
|
||||
int csio_encode_visit(struct ccb_scsiio *csio, const char *fmt,
|
||||
int (*arg_get)(void *hook, char *field_name),
|
||||
void *gethook);
|
||||
__END_DECLS
|
||||
|
@ -100,7 +100,7 @@ __FBSDID("$FreeBSD$");
|
||||
static int
|
||||
do_buff_decode(u_int8_t *databuf, size_t len,
|
||||
void (*arg_put)(void *, int , void *, int, char *),
|
||||
void *puthook, char *fmt, va_list ap)
|
||||
void *puthook, const char *fmt, va_list ap)
|
||||
{
|
||||
int assigned = 0;
|
||||
int width;
|
||||
@ -111,6 +111,7 @@ do_buff_decode(u_int8_t *databuf, size_t len,
|
||||
0x1f, 0x3f, 0x7f, 0xff};
|
||||
int value;
|
||||
u_char *base = databuf;
|
||||
char *intendp;
|
||||
char letter;
|
||||
char field_name[80];
|
||||
|
||||
@ -178,7 +179,8 @@ do_buff_decode(u_int8_t *databuf, size_t len,
|
||||
case 't': /* Bit (field) */
|
||||
case 'b': /* Bits */
|
||||
fmt++;
|
||||
width = strtol(fmt, &fmt, 10);
|
||||
width = strtol(fmt, &intendp, 10);
|
||||
fmt = intendp;
|
||||
if (width > 8)
|
||||
done = 1;
|
||||
else {
|
||||
@ -203,7 +205,8 @@ do_buff_decode(u_int8_t *databuf, size_t len,
|
||||
case 'i': /* Integral values */
|
||||
shift = 0;
|
||||
fmt++;
|
||||
width = strtol(fmt, &fmt, 10);
|
||||
width = strtol(fmt, &intendp, 10);
|
||||
fmt = intendp;
|
||||
switch(width) {
|
||||
case 1:
|
||||
ARG_PUT(*databuf);
|
||||
@ -241,7 +244,8 @@ do_buff_decode(u_int8_t *databuf, size_t len,
|
||||
spaces */
|
||||
shift = 0;
|
||||
fmt++;
|
||||
width = strtol(fmt, &fmt, 10);
|
||||
width = strtol(fmt, &intendp, 10);
|
||||
fmt = intendp;
|
||||
if (!suppress) {
|
||||
if (arg_put)
|
||||
(*arg_put)(puthook,
|
||||
@ -283,8 +287,10 @@ do_buff_decode(u_int8_t *databuf, size_t len,
|
||||
*/
|
||||
width = (arg_put) ? 0 : va_arg(ap, int);
|
||||
fmt++;
|
||||
} else
|
||||
width = strtol(fmt, &fmt, 10);
|
||||
} else {
|
||||
width = strtol(fmt, &intendp, 10);
|
||||
fmt = intendp;
|
||||
}
|
||||
|
||||
if (plus)
|
||||
databuf += width; /* Relative seek */
|
||||
@ -341,10 +347,11 @@ do_buff_decode(u_int8_t *databuf, size_t len,
|
||||
*/
|
||||
|
||||
static int
|
||||
next_field(char **pp, char *fmt, int *width_p, int *value_p, char *name,
|
||||
next_field(const char **pp, char *fmt, int *width_p, int *value_p, char *name,
|
||||
int n_name, int *error_p, int *suppress_p)
|
||||
{
|
||||
char *p = *pp;
|
||||
const char *p = *pp;
|
||||
char *intendp;
|
||||
|
||||
int something = 0;
|
||||
|
||||
@ -404,7 +411,8 @@ next_field(char **pp, char *fmt, int *width_p, int *value_p, char *name,
|
||||
suppress = 1;
|
||||
} else if (isxdigit(*p)) {
|
||||
something = 1;
|
||||
value = strtol(p, &p, 16);
|
||||
value = strtol(p, &intendp, 16);
|
||||
p = intendp;
|
||||
state = START_FIELD;
|
||||
} else if (tolower(*p) == 'v') {
|
||||
p++;
|
||||
@ -421,7 +429,8 @@ next_field(char **pp, char *fmt, int *width_p, int *value_p, char *name,
|
||||
|
||||
*fmt = 'i';
|
||||
field_size = 8;
|
||||
field_width = strtol(p, &p, 10);
|
||||
field_width = strtol(p, &intendp, 10);
|
||||
p = intendp;
|
||||
state = DONE;
|
||||
|
||||
} else if (tolower(*p) == 't') {
|
||||
@ -436,7 +445,8 @@ next_field(char **pp, char *fmt, int *width_p, int *value_p, char *name,
|
||||
|
||||
*fmt = 'b';
|
||||
field_size = 1;
|
||||
field_width = strtol(p, &p, 10);
|
||||
field_width = strtol(p, &intendp, 10);
|
||||
p = intendp;
|
||||
state = DONE;
|
||||
} else if (tolower(*p) == 's') {
|
||||
/* Seek */
|
||||
@ -448,7 +458,8 @@ next_field(char **pp, char *fmt, int *width_p, int *value_p, char *name,
|
||||
value = *value_p;
|
||||
} else {
|
||||
something = 1;
|
||||
value = strtol(p, &p, 0);
|
||||
value = strtol(p, &intendp, 0);
|
||||
p = intendp;
|
||||
}
|
||||
state = DONE;
|
||||
} else {
|
||||
@ -473,7 +484,8 @@ next_field(char **pp, char *fmt, int *width_p, int *value_p, char *name,
|
||||
if (isdigit(*p)) {
|
||||
*fmt = 'b';
|
||||
field_size = 1;
|
||||
field_width = strtol(p, &p, 10);
|
||||
field_width = strtol(p, &intendp, 10);
|
||||
p = intendp;
|
||||
state = DONE;
|
||||
} else if (*p == 'i') {
|
||||
|
||||
@ -482,7 +494,8 @@ next_field(char **pp, char *fmt, int *width_p, int *value_p, char *name,
|
||||
|
||||
*fmt = 'i';
|
||||
field_size = 8;
|
||||
field_width = strtol(p, &p, 10);
|
||||
field_width = strtol(p, &intendp, 10);
|
||||
p = intendp;
|
||||
state = DONE;
|
||||
} else if (*p == 'b') {
|
||||
|
||||
@ -491,7 +504,8 @@ next_field(char **pp, char *fmt, int *width_p, int *value_p, char *name,
|
||||
|
||||
*fmt = 'b';
|
||||
field_size = 1;
|
||||
field_width = strtol(p, &p, 10);
|
||||
field_width = strtol(p, &intendp, 10);
|
||||
p = intendp;
|
||||
state = DONE;
|
||||
} else {
|
||||
fprintf(stderr, "Invalid startfield %c "
|
||||
@ -522,7 +536,8 @@ next_field(char **pp, char *fmt, int *width_p, int *value_p, char *name,
|
||||
|
||||
static int
|
||||
do_encode(u_char *buff, size_t vec_max, size_t *used,
|
||||
int (*arg_get)(void *, char *), void *gethook, char *fmt, va_list ap)
|
||||
int (*arg_get)(void *, char *), void *gethook, const char *fmt,
|
||||
va_list ap)
|
||||
{
|
||||
int ind;
|
||||
int shift;
|
||||
@ -642,7 +657,7 @@ do_encode(u_char *buff, size_t vec_max, size_t *used,
|
||||
}
|
||||
|
||||
int
|
||||
csio_decode(struct ccb_scsiio *csio, char *fmt, ...)
|
||||
csio_decode(struct ccb_scsiio *csio, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@ -653,7 +668,7 @@ csio_decode(struct ccb_scsiio *csio, char *fmt, ...)
|
||||
}
|
||||
|
||||
int
|
||||
csio_decode_visit(struct ccb_scsiio *csio, char *fmt,
|
||||
csio_decode_visit(struct ccb_scsiio *csio, const char *fmt,
|
||||
void (*arg_put)(void *, int, void *, int, char *),
|
||||
void *puthook)
|
||||
{
|
||||
@ -673,7 +688,7 @@ csio_decode_visit(struct ccb_scsiio *csio, char *fmt,
|
||||
}
|
||||
|
||||
int
|
||||
buff_decode(u_int8_t *buff, size_t len, char *fmt, ...)
|
||||
buff_decode(u_int8_t *buff, size_t len, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@ -683,7 +698,7 @@ buff_decode(u_int8_t *buff, size_t len, char *fmt, ...)
|
||||
}
|
||||
|
||||
int
|
||||
buff_decode_visit(u_int8_t *buff, size_t len, char *fmt,
|
||||
buff_decode_visit(u_int8_t *buff, size_t len, const char *fmt,
|
||||
void (*arg_put)(void *, int, void *, int, char *),
|
||||
void *puthook)
|
||||
{
|
||||
@ -707,7 +722,8 @@ buff_decode_visit(u_int8_t *buff, size_t len, char *fmt,
|
||||
*/
|
||||
int
|
||||
csio_build(struct ccb_scsiio *csio, u_int8_t *data_ptr, u_int32_t dxfer_len,
|
||||
u_int32_t flags, int retry_count, int timeout, char *cmd_spec, ...)
|
||||
u_int32_t flags, int retry_count, int timeout, const char *cmd_spec,
|
||||
...)
|
||||
{
|
||||
size_t cmdlen;
|
||||
int retval;
|
||||
@ -741,7 +757,7 @@ csio_build(struct ccb_scsiio *csio, u_int8_t *data_ptr, u_int32_t dxfer_len,
|
||||
int
|
||||
csio_build_visit(struct ccb_scsiio *csio, u_int8_t *data_ptr,
|
||||
u_int32_t dxfer_len, u_int32_t flags, int retry_count,
|
||||
int timeout, char *cmd_spec,
|
||||
int timeout, const char *cmd_spec,
|
||||
int (*arg_get)(void *hook, char *field_name), void *gethook)
|
||||
{
|
||||
va_list ap;
|
||||
@ -781,7 +797,7 @@ csio_build_visit(struct ccb_scsiio *csio, u_int8_t *data_ptr,
|
||||
}
|
||||
|
||||
int
|
||||
csio_encode(struct ccb_scsiio *csio, char *fmt, ...)
|
||||
csio_encode(struct ccb_scsiio *csio, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@ -794,7 +810,7 @@ csio_encode(struct ccb_scsiio *csio, char *fmt, ...)
|
||||
}
|
||||
|
||||
int
|
||||
buff_encode_visit(u_int8_t *buff, size_t len, char *fmt,
|
||||
buff_encode_visit(u_int8_t *buff, size_t len, const char *fmt,
|
||||
int (*arg_get)(void *hook, char *field_name), void *gethook)
|
||||
{
|
||||
va_list ap;
|
||||
@ -812,7 +828,7 @@ buff_encode_visit(u_int8_t *buff, size_t len, char *fmt,
|
||||
}
|
||||
|
||||
int
|
||||
csio_encode_visit(struct ccb_scsiio *csio, char *fmt,
|
||||
csio_encode_visit(struct ccb_scsiio *csio, const char *fmt,
|
||||
int (*arg_get)(void *hook, char *field_name), void *gethook)
|
||||
{
|
||||
va_list ap;
|
||||
|
Loading…
Reference in New Issue
Block a user