mirror of https://github.com/nirenjan/libx52.git
Update libusbx52 to address code-inspector violations
This change addresses the code inspector violations reported in https://frontend.code-inspector.com/analysis/result/8899/550515pull/22/head
parent
8e77d6f09b
commit
011bb737af
|
@ -16,8 +16,8 @@ int libusb_init(libusb_context **ctx)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
int dev_count;
|
int dev_count;
|
||||||
int vid;
|
unsigned int vid;
|
||||||
int pid;
|
unsigned int pid;
|
||||||
int parsed;
|
int parsed;
|
||||||
char *dev_list_file;
|
char *dev_list_file;
|
||||||
FILE *dev_list;
|
FILE *dev_list;
|
||||||
|
@ -180,9 +180,8 @@ ssize_t libusb_get_device_list(libusb_context *ctx, libusb_device ***list)
|
||||||
|
|
||||||
void libusb_free_device_list(libusb_device **list, int unref_devices)
|
void libusb_free_device_list(libusb_device **list, int unref_devices)
|
||||||
{
|
{
|
||||||
libusb_device **dev;
|
|
||||||
|
|
||||||
if (unref_devices) {
|
if (unref_devices) {
|
||||||
|
libusb_device **dev;
|
||||||
for (dev = list; *dev; dev++) {
|
for (dev = list; *dev; dev++) {
|
||||||
/* Decrement the refcount */
|
/* Decrement the refcount */
|
||||||
(*dev)->ref_count -= 1;
|
(*dev)->ref_count -= 1;
|
||||||
|
@ -277,14 +276,13 @@ int libusb_control_transfer(libusb_device_handle *dev_handle,
|
||||||
uint16_t wLength,
|
uint16_t wLength,
|
||||||
unsigned int timeout)
|
unsigned int timeout)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Always log the control transfer */
|
/* Always log the control transfer */
|
||||||
fprintf(dev_handle->packet_data_file,
|
fprintf(dev_handle->packet_data_file,
|
||||||
"%s: RqType: %02x bRequest: %02x wValue: %04x wIndex: %04x timeout: %d\n",
|
"%s: RqType: %02x bRequest: %02x wValue: %04x wIndex: %04x timeout: %d\n",
|
||||||
__func__, request_type, bRequest, wValue, wIndex, timeout);
|
__func__, request_type, bRequest, wValue, wIndex, timeout);
|
||||||
if (data != NULL) {
|
if (data != NULL) {
|
||||||
fprintf(dev_handle->packet_data_file, "%s: Data[%d]: ", __func__,
|
int i;
|
||||||
|
fprintf(dev_handle->packet_data_file, "%s: Data[%u]: ", __func__,
|
||||||
wLength);
|
wLength);
|
||||||
for (i = 0; i < wLength; i++) {
|
for (i = 0; i < wLength; i++) {
|
||||||
fprintf(dev_handle->packet_data_file, "%02x ", data[i]);
|
fprintf(dev_handle->packet_data_file, "%02x ", data[i]);
|
||||||
|
|
|
@ -19,9 +19,8 @@ int main(int argc, char *argv[])
|
||||||
char *data_file;
|
char *data_file;
|
||||||
FILE *data;
|
FILE *data;
|
||||||
char **id_pair;
|
char **id_pair;
|
||||||
int vid;
|
unsigned int vid;
|
||||||
int pid;
|
unsigned int pid;
|
||||||
int parsed;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
data_file = getenv(INPUT_DEVICE_LIST_ENV);
|
data_file = getenv(INPUT_DEVICE_LIST_ENV);
|
||||||
|
@ -36,6 +35,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
/* Process arguments until there are fewer than 2 remaining */
|
/* Process arguments until there are fewer than 2 remaining */
|
||||||
for (i = 1; i < argc && (argc - i) >= 2; i += 2) {
|
for (i = 1; i < argc && (argc - i) >= 2; i += 2) {
|
||||||
|
int parsed;
|
||||||
parsed = sscanf(argv[i], "%x", &vid);
|
parsed = sscanf(argv[i], "%x", &vid);
|
||||||
if (parsed != 1) break;
|
if (parsed != 1) break;
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ static libusb_device_handle *libusbx52_init(void)
|
||||||
ssize_t count;
|
ssize_t count;
|
||||||
int i;
|
int i;
|
||||||
libusb_device **list;
|
libusb_device **list;
|
||||||
libusb_device *device;
|
|
||||||
libusb_device_handle *hdl = NULL;
|
libusb_device_handle *hdl = NULL;
|
||||||
struct libusb_device_descriptor desc;
|
struct libusb_device_descriptor desc;
|
||||||
|
|
||||||
|
@ -54,7 +53,7 @@ static libusb_device_handle *libusbx52_init(void)
|
||||||
|
|
||||||
count = libusb_get_device_list(global_context, &list);
|
count = libusb_get_device_list(global_context, &list);
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
device = list[i];
|
libusb_device *device = list[i];
|
||||||
if (!libusb_get_device_descriptor(device, &desc)) {
|
if (!libusb_get_device_descriptor(device, &desc)) {
|
||||||
if (desc.idVendor == 0x06a3) {
|
if (desc.idVendor == 0x06a3) {
|
||||||
if (desc.idProduct == 0x0762) {
|
if (desc.idProduct == 0x0762) {
|
||||||
|
@ -76,9 +75,8 @@ static libusb_device_handle *libusbx52_init(void)
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int index;
|
unsigned int index;
|
||||||
int value;
|
unsigned int value;
|
||||||
int parsed;
|
|
||||||
int i;
|
int i;
|
||||||
libusb_device_handle *hdl;
|
libusb_device_handle *hdl;
|
||||||
libusb_context *ctx;
|
libusb_context *ctx;
|
||||||
|
@ -88,6 +86,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
/* Process arguments until there are fewer than 2 remaining */
|
/* Process arguments until there are fewer than 2 remaining */
|
||||||
for (i = 1; i < argc && (argc - i) >= 2; i += 2) {
|
for (i = 1; i < argc && (argc - i) >= 2; i += 2) {
|
||||||
|
int parsed;
|
||||||
parsed = sscanf(argv[i], "%x", &index);
|
parsed = sscanf(argv[i], "%x", &index);
|
||||||
if (parsed != 1) break;
|
if (parsed != 1) break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue