summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McBride <sean@rogue-research.com>2017-12-27 23:53:27 -0500
committerChris Dickens <christopher.a.dickens@gmail.com>2017-12-28 22:40:30 -0800
commit0b3d4c68d87a4ffda2a4e0ff86983f69599048ce (patch)
tree30df5e745d05b3628ab37021df0ebb8d730ba62b
parentc1d8c8d654fbb30f420ce273a41f954342f47174 (diff)
downloadlibusb-0b3d4c68d87a4ffda2a4e0ff86983f69599048ce.tar.gz
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>
-rw-r--r--examples/dpfp.c2
-rw-r--r--examples/xusb.c2
-rw-r--r--libusb/os/netbsd_usb.c2
-rw-r--r--libusb/os/openbsd_usb.c2
-rw-r--r--libusb/os/threads_posix.c4
-rw-r--r--libusb/os/windows_winusb.c6
-rw-r--r--libusb/version_nano.h2
7 files changed, 9 insertions, 11 deletions
diff --git a/examples/dpfp.c b/examples/dpfp.c
index b23a8fc..77f9476 100644
--- a/examples/dpfp.c
+++ b/examples/dpfp.c
@@ -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) {
diff --git a/examples/xusb.c b/examples/xusb.c
index e852292..4ac11b8 100644
--- a/examples/xusb.c
+++ b/examples/xusb.c
@@ -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)
diff --git a/libusb/os/netbsd_usb.c b/libusb/os/netbsd_usb.c
index 8f9fa36..d9c059a 100644
--- a/libusb/os/netbsd_usb.c
+++ b/libusb/os/netbsd_usb.c
@@ -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);
diff --git a/libusb/os/openbsd_usb.c b/libusb/os/openbsd_usb.c
index ac770f4..f174e49 100644
--- a/libusb/os/openbsd_usb.c
+++ b/libusb/os/openbsd_usb.c
@@ -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) {
diff --git a/libusb/os/threads_posix.c b/libusb/os/threads_posix.c
index 2d580c3..ce14445 100644
--- a/libusb/os/threads_posix.c
+++ b/libusb/os/threads_posix.c
@@ -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;
diff --git a/libusb/os/windows_winusb.c b/libusb/os/windows_winusb.c
index 6ec5f70..05a360e 100644
--- a/libusb/os/windows_winusb.c
+++ b/libusb/os/windows_winusb.c
@@ -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) {
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index cdcaa78..55188bd 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11238
+#define LIBUSB_NANO 11239