PERFORCE change 152510 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Wed Nov 5 00:31:03 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=152510
Change 152510 by hselasky at hselasky_laptop001 on 2008/11/05 08:30:52
Fix some higher level warnings. Rename some shadow variables.
Affected files ...
.. //depot/projects/usb/src/lib/libusb20/libusb20.c#8 edit
.. //depot/projects/usb/src/lib/libusb20/libusb20.h#8 edit
.. //depot/projects/usb/src/lib/libusb20/libusb20_ugen20.c#8 edit
.. //depot/projects/usb/src/usr.sbin/usbconfig/dump.c#8 edit
.. //depot/projects/usb/src/usr.sbin/usbconfig/usbconfig.c#5 edit
Differences ...
==== //depot/projects/usb/src/lib/libusb20/libusb20.c#8 (text+ko) ====
@@ -647,7 +647,7 @@
int
libusb20_dev_req_string_sync(struct libusb20_device *pdev,
- uint8_t index, uint16_t langid, void *ptr, uint16_t len)
+ uint8_t strIndex, uint16_t langid, void *ptr, uint16_t len)
{
struct LIBUSB20_CONTROL_SETUP_DECODED req;
int error;
@@ -667,7 +667,7 @@
LIBUSB20_RECIPIENT_DEVICE |
LIBUSB20_ENDPOINT_IN;
req.bRequest = LIBUSB20_REQUEST_GET_DESCRIPTOR;
- req.wValue = (LIBUSB20_DT_STRING << 8) | index;
+ req.wValue = (LIBUSB20_DT_STRING << 8) | strIndex;
req.wIndex = langid;
req.wLength = 4; /* bytes */
@@ -695,7 +695,7 @@
int
libusb20_dev_req_string_simple_sync(struct libusb20_device *pdev,
- uint8_t index, void *ptr, uint16_t len)
+ uint8_t strIndex, void *ptr, uint16_t len)
{
char *buf;
int error;
@@ -725,7 +725,7 @@
langid = temp[2] | (temp[3] << 8);
- error = libusb20_dev_req_string_sync(pdev, index,
+ error = libusb20_dev_req_string_sync(pdev, strIndex,
langid, temp, sizeof(temp));
if (error < 0)
return (error);
@@ -836,7 +836,7 @@
libusb20_dev_get_config_index(struct libusb20_device *pdev)
{
int error;
- uint8_t index;
+ uint8_t cfg_index;
uint8_t do_close;
if (!pdev->is_opened) {
@@ -850,16 +850,16 @@
do_close = 0;
}
- error = (pdev->methods->get_config_index) (pdev, &index);
+ error = (pdev->methods->get_config_index) (pdev, &cfg_index);
if (error) {
- index = 0 - 1; /* current config index */
+ cfg_index = 0 - 1; /* current config index */
}
if (do_close) {
if (libusb20_dev_close(pdev)) {
/* ignore */
}
}
- return (index);
+ return (cfg_index);
}
uint8_t
@@ -1071,16 +1071,16 @@
int
libusb20_be_get_dev_quirk(struct libusb20_backend *pbe,
- uint16_t index, struct libusb20_quirk *pq)
+ uint16_t quirk_index, struct libusb20_quirk *pq)
{
- return ((pbe->methods->root_get_dev_quirk) (pbe, index, pq));
+ return ((pbe->methods->root_get_dev_quirk) (pbe, quirk_index, pq));
}
int
libusb20_be_get_quirk_name(struct libusb20_backend *pbe,
- uint16_t index, struct libusb20_quirk *pq)
+ uint16_t quirk_index, struct libusb20_quirk *pq)
{
- return ((pbe->methods->root_get_quirk_name) (pbe, index, pq));
+ return ((pbe->methods->root_get_quirk_name) (pbe, quirk_index, pq));
}
int
==== //depot/projects/usb/src/lib/libusb20/libusb20.h#8 (text+ko) ====
@@ -297,6 +297,7 @@
struct libusb20_backend *libusb20_be_alloc_default(void);
struct libusb20_backend *libusb20_be_alloc_freebsd(void);
struct libusb20_backend *libusb20_be_alloc_linux(void);
+struct libusb20_backend *libusb20_be_alloc_ugen20(void);
struct libusb20_device *libusb20_be_device_foreach(struct libusb20_backend *pbe, struct libusb20_device *pdev);
void libusb20_be_dequeue_device(struct libusb20_backend *pbe, struct libusb20_device *pdev);
void libusb20_be_enqueue_device(struct libusb20_backend *pbe, struct libusb20_device *pdev);
==== //depot/projects/usb/src/lib/libusb20/libusb20_ugen20.c#8 (text+ko) ====
@@ -410,7 +410,7 @@
static int
ugen20_get_config_desc_full(struct libusb20_device *pdev,
- uint8_t **ppbuf, uint16_t *plen, uint8_t index)
+ uint8_t **ppbuf, uint16_t *plen, uint8_t cfg_index)
{
struct usb2_gen_descriptor gen_desc = { /* zero */ };
struct usb2_config_descriptor cdesc;
@@ -420,7 +420,7 @@
gen_desc.ugd_data = &cdesc;
gen_desc.ugd_maxlen = sizeof(cdesc);
- gen_desc.ugd_config_index = index;
+ gen_desc.ugd_config_index = cfg_index;
error = ioctl(pdev->file_ctrl, USB_GET_FULL_DESC, &gen_desc);
if (error) {
@@ -466,9 +466,9 @@
}
static int
-ugen20_set_config_index(struct libusb20_device *pdev, uint8_t index)
+ugen20_set_config_index(struct libusb20_device *pdev, uint8_t cfg_index)
{
- int temp = index;
+ int temp = cfg_index;
if (ioctl(pdev->file_ctrl, USB_SET_CONFIG, &temp)) {
return (LIBUSB20_ERROR_OTHER);
@@ -795,21 +795,21 @@
ugen20_be_ioctl(uint32_t cmd, void *data)
{
int f;
- int err;
+ int error;
f = open("/dev/usb", O_RDONLY);
if (f < 0)
return (LIBUSB20_ERROR_OTHER);
- err = ioctl(f, cmd, data);
- if (err == -1) {
+ error = ioctl(f, cmd, data);
+ if (error == -1) {
if (errno == EPERM) {
- err = LIBUSB20_ERROR_ACCESS;
+ error = LIBUSB20_ERROR_ACCESS;
} else {
- err = LIBUSB20_ERROR_OTHER;
+ error = LIBUSB20_ERROR_OTHER;
}
}
close(f);
- return (err);
+ return (error);
}
static int
@@ -818,15 +818,15 @@
gid_t *gid, mode_t *mode)
{
struct usb2_dev_perm perm = { /* zero */ };
- int err;
+ int error;
perm.bus_index = bus;
perm.dev_index = dev;
perm.iface_index = iface;
- err = ugen20_be_ioctl(get_cmd, &perm);
- if (err)
- return (err);
+ error = ugen20_be_ioctl(get_cmd, &perm);
+ if (error)
+ return (error);
if (set_cmd == 0) {
if (uid)
@@ -934,18 +934,18 @@
static int
ugen20_root_get_dev_quirk(struct libusb20_backend *pbe,
- uint16_t index, struct libusb20_quirk *pq)
+ uint16_t quirk_index, struct libusb20_quirk *pq)
{
struct usb2_gen_quirk q;
- int err;
+ int error;
memset(&q, 0, sizeof(q));
- q.index = index;
+ q.index = quirk_index;
- err = ugen20_be_ioctl(USB_DEV_QUIRK_GET, &q);
+ error = ugen20_be_ioctl(USB_DEV_QUIRK_GET, &q);
- if (err) {
+ if (error) {
if (errno == EINVAL) {
return (LIBUSB20_ERROR_NOT_FOUND);
}
@@ -956,30 +956,30 @@
pq->bcdDeviceHigh = q.bcdDeviceHigh;
strlcpy(pq->quirkname, q.quirkname, sizeof(pq->quirkname));
}
- return (err);
+ return (error);
}
static int
-ugen20_root_get_quirk_name(struct libusb20_backend *pbe, uint16_t index,
+ugen20_root_get_quirk_name(struct libusb20_backend *pbe, uint16_t quirk_index,
struct libusb20_quirk *pq)
{
struct usb2_gen_quirk q;
- int err;
+ int error;
memset(&q, 0, sizeof(q));
- q.index = index;
+ q.index = quirk_index;
- err = ugen20_be_ioctl(USB_QUIRK_NAME_GET, &q);
+ error = ugen20_be_ioctl(USB_QUIRK_NAME_GET, &q);
- if (err) {
+ if (error) {
if (errno == EINVAL) {
return (LIBUSB20_ERROR_NOT_FOUND);
}
} else {
strlcpy(pq->quirkname, q.quirkname, sizeof(pq->quirkname));
}
- return (err);
+ return (error);
}
static int
@@ -987,7 +987,7 @@
struct libusb20_quirk *pq)
{
struct usb2_gen_quirk q;
- int err;
+ int error;
memset(&q, 0, sizeof(q));
@@ -997,13 +997,13 @@
q.bcdDeviceHigh = pq->bcdDeviceHigh;
strlcpy(q.quirkname, pq->quirkname, sizeof(q.quirkname));
- err = ugen20_be_ioctl(USB_DEV_QUIRK_ADD, &q);
- if (err) {
+ error = ugen20_be_ioctl(USB_DEV_QUIRK_ADD, &q);
+ if (error) {
if (errno == ENOMEM) {
return (LIBUSB20_ERROR_NO_MEM);
}
}
- return (err);
+ return (error);
}
static int
@@ -1011,7 +1011,7 @@
struct libusb20_quirk *pq)
{
struct usb2_gen_quirk q;
- int err;
+ int error;
memset(&q, 0, sizeof(q));
@@ -1021,13 +1021,13 @@
q.bcdDeviceHigh = pq->bcdDeviceHigh;
strlcpy(q.quirkname, pq->quirkname, sizeof(q.quirkname));
- err = ugen20_be_ioctl(USB_DEV_QUIRK_REMOVE, &q);
- if (err) {
+ error = ugen20_be_ioctl(USB_DEV_QUIRK_REMOVE, &q);
+ if (error) {
if (errno == EINVAL) {
return (LIBUSB20_ERROR_NOT_FOUND);
}
}
- return (err);
+ return (error);
}
static int
==== //depot/projects/usb/src/usr.sbin/usbconfig/dump.c#8 (text+ko) ====
@@ -98,7 +98,7 @@
{
struct LIBUSB20_CONTROL_SETUP_DECODED req;
uint16_t lang_id;
- uint8_t index;
+ uint8_t idx;
uint8_t temp_string[256];
printf("%s%s = 0x%04x ", plevel, field, value);
@@ -114,14 +114,14 @@
LIBUSB20_INIT(LIBUSB20_CONTROL_SETUP, &req);
lang_id = 0;
- index = 0;
+ idx = 0;
req.bmRequestType =
LIBUSB20_REQUEST_TYPE_STANDARD |
LIBUSB20_RECIPIENT_DEVICE |
LIBUSB20_ENDPOINT_IN;
req.bRequest = LIBUSB20_REQUEST_GET_DESCRIPTOR;
- req.wValue = (256 * LIBUSB20_DT_STRING) | index;
+ req.wValue = (256 * LIBUSB20_DT_STRING) | idx;
req.wIndex = lang_id;
req.wLength = 4; /* bytes */
@@ -133,9 +133,9 @@
printf(" LangId:0x%04x <", lang_id);
- index = value;
+ idx = value;
- req.wValue = (256 * LIBUSB20_DT_STRING) | index;
+ req.wValue = (256 * LIBUSB20_DT_STRING) | idx;
req.wIndex = lang_id;
req.wLength = 4; /* bytes */
@@ -144,7 +144,7 @@
printf("ERROR>\n");
goto done;
}
- req.wValue = (256 * LIBUSB20_DT_STRING) | index;
+ req.wValue = (256 * LIBUSB20_DT_STRING) | idx;
req.wIndex = lang_id;
req.wLength = temp_string[0]; /* bytes */
@@ -155,11 +155,11 @@
}
req.wLength /= 2;
- for (index = 1; index != req.wLength; index++) {
- if (isprint(temp_string[(2 * index) + 0])) {
- printf("%c", temp_string[(2 * index) + 0]);
- } else if (isprint(temp_string[(2 * index) + 1])) {
- printf("%c", temp_string[(2 * index) + 1]);
+ for (idx = 1; idx != req.wLength; idx++) {
+ if (isprint(temp_string[(2 * idx) + 0])) {
+ printf("%c", temp_string[(2 * idx) + 0]);
+ } else if (isprint(temp_string[(2 * idx) + 1])) {
+ printf("%c", temp_string[(2 * idx) + 1]);
} else {
printf("?");
}
@@ -244,7 +244,7 @@
{
struct libusb20_quirk q;
uint16_t x;
- int err;
+ int error;
memset(&q, 0, sizeof(q));
@@ -252,8 +252,8 @@
for (x = 0; x != 0xFFFF; x++) {
- err = libusb20_be_get_quirk_name(pbe, x, &q);
- if (err) {
+ error = libusb20_be_get_quirk_name(pbe, x, &q);
+ if (error) {
if (x == 0) {
printf("No quirk names - maybe the USB quirk "
"module has not been loaded.\n");
@@ -272,7 +272,7 @@
{
struct libusb20_quirk q;
uint16_t x;
- int err;
+ int error;
memset(&q, 0, sizeof(q));
@@ -280,8 +280,8 @@
for (x = 0; x != 0xFFFF; x++) {
- err = libusb20_be_get_dev_quirk(pbe, x, &q);
- if (err) {
+ error = libusb20_be_get_dev_quirk(pbe, x, &q);
+ if (error) {
if (x == 0) {
printf("No device quirks - maybe the USB quirk "
"module has not been loaded.\n");
==== //depot/projects/usb/src/usr.sbin/usbconfig/usbconfig.c#5 (text+ko) ====
@@ -144,7 +144,7 @@
const char *str)
{
struct libusb20_quirk q;
- int err;
+ int error;
memset(&q, 0, sizeof(q));
@@ -154,8 +154,8 @@
q.bcdDeviceHigh = hirev;
strlcpy(q.quirkname, str, sizeof(q.quirkname));
- err = libusb20_be_remove_dev_quirk(pbe, &q);
- if (err) {
+ error = libusb20_be_remove_dev_quirk(pbe, &q);
+ if (error) {
printf("Removing quirk '%s' failed, continuing.\n", str);
}
return;
@@ -167,7 +167,7 @@
const char *str)
{
struct libusb20_quirk q;
- int err;
+ int error;
memset(&q, 0, sizeof(q));
@@ -177,8 +177,8 @@
q.bcdDeviceHigh = hirev;
strlcpy(q.quirkname, str, sizeof(q.quirkname));
- err = libusb20_be_add_dev_quirk(pbe, &q);
- if (err) {
+ error = libusb20_be_add_dev_quirk(pbe, &q);
+ if (error) {
printf("Adding quirk '%s' failed, continuing.\n", str);
}
return;
More information about the p4-projects
mailing list