Fixed various trivial cppcheck 1.80 warnings

Specifically:

redundantAssignment,examples/dpfp.c:422,style,Variable 'r' is reassigned a value before the old one has been used.
redundantAssignment,libusb/os/threads_posix.c:64,style,Variable 'ret' is reassigned a value before the old one has been used.
unreadVariable,libusb/os/netbsd_usb.c:217,style,Variable 'hpriv' is assigned a value that is never used.
unreadVariable,libusb/os/netbsd_usb.c:235,style,Variable 'hpriv' is assigned a value that is never used.
unreadVariable,libusb/os/openbsd_usb.c:251,style,Variable 'hpriv' is assigned a value that is never used.
unreadVariable,libusb/os/openbsd_usb.c:275,style,Variable 'hpriv' is assigned a value that is never used.
unsignedLessThanZero,libusb/os/windows_winusb.c:259,style,Checking if unsigned variable '_index' is less than zero.
unsignedLessThanZero,libusb/os/windows_winusb.c:298,style,Checking if unsigned variable '_index' is less than zero.
unsignedLessThanZero,libusb/os/windows_winusb.c:367,style,Checking if unsigned variable '_index' is less than zero.
invalidPrintfArgType_sint,examples/xusb.c:534,warning,%d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
This commit is contained in:
Sean McBride
2017-12-27 23:53:27 -05:00
committed by Chris Dickens
parent c1d8c8d654
commit 0b3d4c68d8
7 changed files with 9 additions and 11 deletions

View File

@@ -419,7 +419,7 @@ static void sighandler(int signum)
int main(void)
{
struct sigaction sigact;
int r = 1;
int r;
r = libusb_init(NULL);
if (r < 0) {

View File

@@ -531,7 +531,7 @@ static int test_mass_storage(libusb_device_handle *handle, uint8_t endpoint_in,
}
// Send Read
printf("Attempting to read %d bytes:\n", block_size);
printf("Attempting to read %u bytes:\n", block_size);
memset(cdb, 0, sizeof(cdb));
cdb[0] = 0x28; // Read(10)

View File

@@ -214,7 +214,6 @@ error:
int
netbsd_open(struct libusb_device_handle *handle)
{
struct handle_priv *hpriv = (struct handle_priv *)handle->os_priv;
struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
dpriv->fd = open(dpriv->devnode, O_RDWR);
@@ -232,7 +231,6 @@ netbsd_open(struct libusb_device_handle *handle)
void
netbsd_close(struct libusb_device_handle *handle)
{
struct handle_priv *hpriv = (struct handle_priv *)handle->os_priv;
struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
usbi_dbg("close: fd %d", dpriv->fd);

View File

@@ -248,7 +248,6 @@ obsd_get_device_list(struct libusb_context * ctx,
int
obsd_open(struct libusb_device_handle *handle)
{
struct handle_priv *hpriv = (struct handle_priv *)handle->os_priv;
struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
char devnode[16];
@@ -272,7 +271,6 @@ obsd_open(struct libusb_device_handle *handle)
void
obsd_close(struct libusb_device_handle *handle)
{
struct handle_priv *hpriv = (struct handle_priv *)handle->os_priv;
struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
if (dpriv->devname) {

View File

@@ -59,7 +59,7 @@ int usbi_cond_timedwait(pthread_cond_t *cond,
int usbi_get_tid(void)
{
int ret = -1;
int ret;
#if defined(__ANDROID__)
ret = gettid();
#elif defined(__linux__)
@@ -73,6 +73,8 @@ int usbi_get_tid(void)
mach_port_deallocate(mach_task_self(), ret);
#elif defined(__CYGWIN__)
ret = GetCurrentThreadId();
#else
ret = -1;
#endif
/* TODO: NetBSD thread ID support */
return ret;

View File

@@ -256,7 +256,7 @@ static void exit_dlls(void)
static bool get_devinfo_data(struct libusb_context *ctx,
HDEVINFO *dev_info, SP_DEVINFO_DATA *dev_info_data, const char *usb_class, unsigned _index)
{
if (_index <= 0) {
if (_index == 0) {
*dev_info = pSetupDiGetClassDevsA(NULL, usb_class, NULL, DIGCF_PRESENT|DIGCF_ALLCLASSES);
if (*dev_info == INVALID_HANDLE_VALUE)
return false;
@@ -295,7 +295,7 @@ static SP_DEVICE_INTERFACE_DETAIL_DATA_A *get_interface_details(struct libusb_co
SP_DEVICE_INTERFACE_DETAIL_DATA_A *dev_interface_details;
DWORD size;
if (_index <= 0)
if (_index == 0)
*dev_info = pSetupDiGetClassDevsA(guid, NULL, NULL, DIGCF_PRESENT|DIGCF_DEVICEINTERFACE);
if (dev_info_data != NULL) {
@@ -364,7 +364,7 @@ static SP_DEVICE_INTERFACE_DETAIL_DATA_A *get_interface_details_filter(struct li
SP_DEVICE_INTERFACE_DETAIL_DATA_A *dev_interface_details;
DWORD size;
if (_index <= 0)
if (_index == 0)
*dev_info = pSetupDiGetClassDevsA(guid, NULL, NULL, DIGCF_PRESENT|DIGCF_DEVICEINTERFACE);
if (dev_info_data != NULL) {

View File

@@ -1 +1 @@
#define LIBUSB_NANO 11238
#define LIBUSB_NANO 11239