aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Schink <jaylink-dev@marcschink.de>2016-11-13 15:30:06 +0100
committerMarc Schink <jaylink-dev@marcschink.de>2016-11-15 13:15:25 +0100
commitdd1fa724b60029ace9ca28023cd3d8b5735c950c (patch)
tree3f66d77f272b8f4816aced3df03443555e4a7116
parent58953bbfecc13f79d59549cb9aabd898c8ab5714 (diff)
Minor code and documentation cleanups
Signed-off-by: Marc Schink <jaylink-dev@marcschink.de>
-rw-r--r--README2
-rw-r--r--libjaylink/buffer.c2
-rw-r--r--libjaylink/core.c3
-rw-r--r--libjaylink/device.c53
-rw-r--r--libjaylink/discovery.c27
-rw-r--r--libjaylink/emucom.c4
-rw-r--r--libjaylink/fileio.c3
-rw-r--r--libjaylink/jtag.c4
-rw-r--r--libjaylink/libjaylink-internal.h11
-rw-r--r--libjaylink/libjaylink.h11
-rw-r--r--libjaylink/list.c12
-rw-r--r--libjaylink/log.c2
-rw-r--r--libjaylink/strutil.c6
-rw-r--r--libjaylink/swd.c4
-rw-r--r--libjaylink/swo.c18
-rw-r--r--libjaylink/target.c9
-rw-r--r--libjaylink/transport.c16
17 files changed, 93 insertions, 94 deletions
diff --git a/README b/README
index e75c009..492e34a 100644
--- a/README
+++ b/README
@@ -61,7 +61,7 @@ Copyright and license
---------------------
libjaylink is licensed under the terms of the GNU General Public License (GPL),
-version 2 or later. See COPYING for details.
+version 2 or later. See COPYING file for details.
Website
diff --git a/libjaylink/buffer.c b/libjaylink/buffer.c
index d23818d..527c25e 100644
--- a/libjaylink/buffer.c
+++ b/libjaylink/buffer.c
@@ -20,7 +20,9 @@
#include <stdint.h>
#include <string.h>
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
#include "libjaylink-internal.h"
/**
diff --git a/libjaylink/core.c b/libjaylink/core.c
index 9097f83..9f0d8b1 100644
--- a/libjaylink/core.c
+++ b/libjaylink/core.c
@@ -18,6 +18,7 @@
*/
#include <stdlib.h>
+#include <stdbool.h>
#ifdef _WIN32
#include <winsock2.h>
#endif
@@ -50,7 +51,7 @@
* perspective and because there is only a single reason for failure which is
* clearly distinguishable from the result.
*
- * @section sec_license License
+ * @section sec_license Copyright and license
*
* libjaylink is licensed under the terms of the GNU General Public
* License (GPL), version 2 or later.
diff --git a/libjaylink/device.c b/libjaylink/device.c
index 1b2a75e..8b4ad16 100644
--- a/libjaylink/device.c
+++ b/libjaylink/device.c
@@ -109,10 +109,10 @@ static struct jaylink_device **allocate_device_list(size_t length)
* Get available devices.
*
* @param[in,out] ctx libjaylink context.
- * @param[out] devices Newly allocated array which contains instances of
- * available devices on success, and undefined on failure.
- * The array is NULL-terminated and must be free'd by the
- * caller with jaylink_free_devices().
+ * @param[out] devs Newly allocated array which contains instances of available
+ * devices on success, and undefined on failure. The array is
+ * NULL-terminated and must be free'd by the caller with
+ * jaylink_free_devices().
* @param[out] count Number of available devices on success, and undefined on
* failure. Can be NULL.
*
@@ -126,21 +126,21 @@ static struct jaylink_device **allocate_device_list(size_t length)
* @since 0.1.0
*/
JAYLINK_API int jaylink_get_devices(struct jaylink_context *ctx,
- struct jaylink_device ***devices, size_t *count)
+ struct jaylink_device ***devs, size_t *count)
{
size_t num;
struct list *item;
- struct jaylink_device **devs;
+ struct jaylink_device **tmp;
struct jaylink_device *dev;
size_t i;
- if (!ctx || !devices)
+ if (!ctx || !devs)
return JAYLINK_ERR_ARG;
num = list_length(ctx->discovered_devs);
- devs = allocate_device_list(num);
+ tmp = allocate_device_list(num);
- if (!devs) {
+ if (!tmp) {
log_err(ctx, "Failed to allocate device list.");
return JAYLINK_ERR_MALLOC;
}
@@ -149,14 +149,14 @@ JAYLINK_API int jaylink_get_devices(struct jaylink_context *ctx,
for (i = 0; i < num; i++) {
dev = (struct jaylink_device *)item->data;
- devs[i] = jaylink_ref_device(dev);
+ tmp[i] = jaylink_ref_device(dev);
item = item->next;
}
if (count)
*count = num;
- *devices = devs;
+ *devs = tmp;
return JAYLINK_OK;
}
@@ -164,7 +164,7 @@ JAYLINK_API int jaylink_get_devices(struct jaylink_context *ctx,
/**
* Free devices.
*
- * @param[in,out] devices Array of device instances. Must be NULL-terminated.
+ * @param[in,out] devs Array of device instances. Must be NULL-terminated.
* @param[in] unref Determines whether the device instances should be
* unreferenced.
*
@@ -172,20 +172,19 @@ JAYLINK_API int jaylink_get_devices(struct jaylink_context *ctx,
*
* @since 0.1.0
*/
-JAYLINK_API void jaylink_free_devices(struct jaylink_device **devices,
- bool unref)
+JAYLINK_API void jaylink_free_devices(struct jaylink_device **devs, bool unref)
{
size_t i;
- if (!devices)
+ if (!devs)
return;
if (unref) {
- for (i = 0; devices[i]; i++)
- jaylink_unref_device(devices[i]);
+ for (i = 0; devs[i]; i++)
+ jaylink_unref_device(devs[i]);
}
- free(devices);
+ free(devs);
}
/**
@@ -1062,7 +1061,7 @@ JAYLINK_API int jaylink_write_raw_config(struct jaylink_device_handle *devh,
return JAYLINK_OK;
}
-static void parse_conntable(struct jaylink_connection *conns,
+static void parse_conn_table(struct jaylink_connection *conns,
const uint8_t *buffer, uint16_t num, uint16_t entry_size)
{
unsigned int i;
@@ -1209,7 +1208,7 @@ JAYLINK_API int jaylink_register(struct jaylink_device_handle *devh,
uint16_t entry_size;
uint32_t size;
uint32_t table_size;
- uint16_t addinfo_size;
+ uint16_t info_size;
struct in_addr in;
if (!devh || !connection || !connections || !count)
@@ -1257,7 +1256,7 @@ JAYLINK_API int jaylink_register(struct jaylink_device_handle *devh,
handle = buffer_get_u16(buf, 0);
num = buffer_get_u16(buf, 2);
entry_size = buffer_get_u16(buf, 4);
- addinfo_size = buffer_get_u16(buf, 6);
+ info_size = buffer_get_u16(buf, 6);
if (num > JAYLINK_MAX_CONNECTIONS) {
log_err(ctx, "Maximum number of device connections exceeded: "
@@ -1272,7 +1271,7 @@ JAYLINK_API int jaylink_register(struct jaylink_device_handle *devh,
}
table_size = num * entry_size;
- size = REG_HEADER_SIZE + table_size + addinfo_size;
+ size = REG_HEADER_SIZE + table_size + info_size;
if (size > REG_MAX_SIZE) {
log_err(ctx, "Maximum registration information size exceeded: "
@@ -1305,7 +1304,7 @@ JAYLINK_API int jaylink_register(struct jaylink_device_handle *devh,
}
connection->handle = handle;
- parse_conntable(connections, buf + REG_HEADER_SIZE, num, entry_size);
+ parse_conn_table(connections, buf + REG_HEADER_SIZE, num, entry_size);
*count = num;
@@ -1349,7 +1348,7 @@ JAYLINK_API int jaylink_unregister(struct jaylink_device_handle *devh,
uint16_t entry_size;
uint32_t size;
uint32_t table_size;
- uint16_t addinfo_size;
+ uint16_t info_size;
struct in_addr in;
if (!devh || !connection || !connections || !count)
@@ -1396,7 +1395,7 @@ JAYLINK_API int jaylink_unregister(struct jaylink_device_handle *devh,
num = buffer_get_u16(buf, 2);
entry_size = buffer_get_u16(buf, 4);
- addinfo_size = buffer_get_u16(buf, 6);
+ info_size = buffer_get_u16(buf, 6);
if (num > JAYLINK_MAX_CONNECTIONS) {
log_err(ctx, "Maximum number of device connections exceeded: "
@@ -1411,7 +1410,7 @@ JAYLINK_API int jaylink_unregister(struct jaylink_device_handle *devh,
}
table_size = num * entry_size;
- size = REG_HEADER_SIZE + table_size + addinfo_size;
+ size = REG_HEADER_SIZE + table_size + info_size;
if (size > REG_MAX_SIZE) {
log_err(ctx, "Maximum registration information size exceeded: "
@@ -1438,7 +1437,7 @@ JAYLINK_API int jaylink_unregister(struct jaylink_device_handle *devh,
}
}
- parse_conntable(connections, buf + REG_HEADER_SIZE, num, entry_size);
+ parse_conn_table(connections, buf + REG_HEADER_SIZE, num, entry_size);
*count = num;
diff --git a/libjaylink/discovery.c b/libjaylink/discovery.c
index aa294d6..a389f26 100644
--- a/libjaylink/discovery.c
+++ b/libjaylink/discovery.c
@@ -18,8 +18,7 @@
*/
#include <stdlib.h>
-#include <stdio.h>
-#include <inttypes.h>
+#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <sys/types.h>
@@ -89,24 +88,24 @@ static bool parse_serial_number(const char *str, uint32_t *serial_number)
if (length > MAX_SERIAL_NUMBER_DIGITS)
str = str + (length - MAX_SERIAL_NUMBER_DIGITS);
- if (sscanf(str, "%" SCNu32, serial_number) != 1)
+ if (jaylink_parse_serial_number(str, serial_number) != JAYLINK_OK)
return false;
return true;
}
-static bool compare_devices(const void *a, const void *b)
+static bool compare_devices(const void *data, const void *user_data)
{
const struct jaylink_device *dev;
const struct libusb_device *usb_dev;
- dev = a;
- usb_dev = b;
+ dev = data;
+ usb_dev = user_data;
if (dev->usb_dev == usb_dev)
- return false;
+ return true;
- return true;
+ return false;
}
static struct jaylink_device *find_device(const struct jaylink_context *ctx,
@@ -300,10 +299,10 @@ static void clear_discovery_list(struct jaylink_context *ctx)
* Scan for devices.
*
* @param[in,out] ctx libjaylink context.
- * @param[in] hostifs Host interfaces to scan for devices. Use bitwise OR to
- * specify multiple interfaces, or 0 to use all available
- * interfaces. See #jaylink_host_interface for a description
- * of the interfaces.
+ * @param[in] ifaces Host interfaces to scan for devices. Use bitwise OR to
+ * specify multiple interfaces, or 0 to use all available
+ * interfaces. See #jaylink_host_interface for a description
+ * of the interfaces.
*
* @retval JAYLINK_OK Success.
* @retval JAYLINK_ERR_ARG Invalid arguments.
@@ -315,14 +314,14 @@ static void clear_discovery_list(struct jaylink_context *ctx)
* @since 0.1.0
*/
JAYLINK_API int jaylink_discovery_scan(struct jaylink_context *ctx,
- uint32_t hostifs)
+ uint32_t ifaces)
{
int ret;
if (!ctx)
return JAYLINK_ERR_ARG;
- (void)hostifs;
+ (void)ifaces;
clear_discovery_list(ctx);
diff --git a/libjaylink/emucom.c b/libjaylink/emucom.c
index 8affc97..035cb99 100644
--- a/libjaylink/emucom.c
+++ b/libjaylink/emucom.c
@@ -79,13 +79,13 @@
* @retval JAYLINK_ERR_TIMEOUT A timeout occurred.
* @retval JAYLINK_ERR_PROTO Protocol violation.
* @retval JAYLINK_ERR_IO Input/output error.
- * @retval JAYLINK_ERR_DEV Unspecified device error.
* @retval JAYLINK_ERR_DEV_NOT_SUPPORTED Channel is not supported by the
* device.
* @retval JAYLINK_ERR_DEV_NOT_AVAILABLE Channel is not available for the
* requested amount of data. @p length is
* updated with the number of bytes
* available on this channel.
+ * @retval JAYLINK_ERR_DEV Unspecified device error.
* @retval JAYLINK_ERR Other error conditions.
*
* @since 0.1.0
@@ -196,9 +196,9 @@ JAYLINK_API int jaylink_emucom_read(struct jaylink_device_handle *devh,
* @retval JAYLINK_ERR_TIMEOUT A timeout occurred.
* @retval JAYLINK_ERR_PROTO Protocol violation.
* @retval JAYLINK_ERR_IO Input/output error.
- * @retval JAYLINK_ERR_DEV Unspecified device error.
* @retval JAYLINK_ERR_DEV_NOT_SUPPORTED Channel is not supported by the
* device.
+ * @retval JAYLINK_ERR_DEV Unspecified device error.
* @retval JAYLINK_ERR Other error conditions.
*
* @since 0.1.0
diff --git a/libjaylink/fileio.c b/libjaylink/fileio.c
index 1908803..933c366 100644
--- a/libjaylink/fileio.c
+++ b/libjaylink/fileio.c
@@ -17,10 +17,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <stddef.h>
-#include <string.h>
#include <stdint.h>
#include <stdbool.h>
+#include <string.h>
#include "libjaylink.h"
#include "libjaylink-internal.h"
diff --git a/libjaylink/jtag.c b/libjaylink/jtag.c
index 4143e62..c0c65de 100644
--- a/libjaylink/jtag.c
+++ b/libjaylink/jtag.c
@@ -62,9 +62,9 @@
* @retval JAYLINK_ERR_ARG Invalid arguments.
* @retval JAYLINK_ERR_TIMEOUT A timeout occurred.
* @retval JAYLINK_ERR_IO Input/output error.
- * @retval JAYLINK_ERR_DEV Unspecified device error.
* @retval JAYLINK_ERR_DEV_NO_MEMORY Not enough memory on the device to perform
* the operation.
+ * @retval JAYLINK_ERR_DEV Unspecified device error.
* @retval JAYLINK_ERR Other error conditions.
*
* @see jaylink_select_interface()
@@ -163,7 +163,7 @@ JAYLINK_API int jaylink_jtag_io(struct jaylink_device_handle *devh,
if (status == JTAG_IO_ERR_NO_MEMORY) {
return JAYLINK_ERR_DEV_NO_MEMORY;
} else if (status > 0) {
- log_err(ctx, "JTAG I/O operation failed: %02x.", status);
+ log_err(ctx, "JTAG I/O operation failed: 0x%x.", status);
return JAYLINK_ERR_DEV;
}
diff --git a/libjaylink/libjaylink-internal.h b/libjaylink/libjaylink-internal.h
index f22cb2a..8ce28d7 100644
--- a/libjaylink/libjaylink-internal.h
+++ b/libjaylink/libjaylink-internal.h
@@ -23,7 +23,7 @@
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
-#include <sys/types.h>
+#include <stdarg.h>
#include "libjaylink.h"
@@ -137,7 +137,7 @@ struct list {
struct list *next;
};
-typedef bool (*list_compare_callback)(const void *a, const void *b);
+typedef bool (*list_compare_callback)(const void *data, const void *user_data);
/*--- buffer.c --------------------------------------------------------------*/
@@ -153,17 +153,12 @@ JAYLINK_PRIV uint32_t buffer_get_u32(const uint8_t *buffer, size_t offset);
JAYLINK_PRIV struct jaylink_device *device_allocate(
struct jaylink_context *ctx);
-/*--- discovery.c -----------------------------------------------------------*/
-
-JAYLINK_PRIV ssize_t discovery_get_device_list(struct jaylink_context *ctx,
- struct jaylink_device ***list);
-
/*--- list.c ----------------------------------------------------------------*/
JAYLINK_PRIV struct list *list_prepend(struct list *list, void *data);
JAYLINK_PRIV struct list *list_remove(struct list *list, const void *data);
JAYLINK_PRIV struct list *list_find_custom(struct list *list,
- list_compare_callback cb, const void *cb_data);
+ list_compare_callback callback, const void *user_data);
JAYLINK_PRIV size_t list_length(struct list *list);
JAYLINK_PRIV void list_free(struct list *list);
diff --git a/libjaylink/libjaylink.h b/libjaylink/libjaylink.h
index 36b4a61..9c34119 100644
--- a/libjaylink/libjaylink.h
+++ b/libjaylink/libjaylink.h
@@ -24,7 +24,6 @@
#include <stdint.h>
#include <stdbool.h>
#include <stdarg.h>
-#include <sys/types.h>
#ifdef _WIN32
#include <ws2tcpip.h>
#else
@@ -388,8 +387,8 @@ JAYLINK_API bool jaylink_library_has_cap(enum jaylink_capability cap);
/*--- device.c --------------------------------------------------------------*/
JAYLINK_API int jaylink_get_devices(struct jaylink_context *ctx,
- struct jaylink_device ***devices, size_t *count);
-JAYLINK_API void jaylink_free_devices(struct jaylink_device **devices,
+ struct jaylink_device ***devs, size_t *count);
+JAYLINK_API void jaylink_free_devices(struct jaylink_device **devs,
bool unref);
JAYLINK_API int jaylink_device_get_host_interface(
const struct jaylink_device *dev,
@@ -437,7 +436,7 @@ JAYLINK_API int jaylink_unregister(struct jaylink_device_handle *devh,
/*--- discovery.c -----------------------------------------------------------*/
JAYLINK_API int jaylink_discovery_scan(struct jaylink_context *ctx,
- uint32_t hostifs);
+ uint32_t ifaces);
/*--- emucom.c --------------------------------------------------------------*/
@@ -481,7 +480,7 @@ JAYLINK_API int jaylink_log_get_level(const struct jaylink_context *ctx,
JAYLINK_API int jaylink_log_set_callback(struct jaylink_context *ctx,
jaylink_log_callback callback, void *user_data);
JAYLINK_API int jaylink_log_set_domain(struct jaylink_context *ctx,
- char *domain);
+ const char *domain);
JAYLINK_API const char *jaylink_log_get_domain(
const struct jaylink_context *ctx);
@@ -516,7 +515,7 @@ JAYLINK_API int jaylink_select_interface(struct jaylink_device_handle *devh,
enum jaylink_target_interface iface,
enum jaylink_target_interface *prev_iface);
JAYLINK_API int jaylink_get_available_interfaces(
- struct jaylink_device_handle *devh, uint32_t *interfaces);
+ struct jaylink_device_handle *devh, uint32_t *ifaces);
JAYLINK_API int jaylink_get_selected_interface(
struct jaylink_device_handle *devh,
enum jaylink_target_interface *iface);
diff --git a/libjaylink/list.c b/libjaylink/list.c
index 7fab4d6..7c54e50 100644
--- a/libjaylink/list.c
+++ b/libjaylink/list.c
@@ -76,13 +76,13 @@ JAYLINK_PRIV struct list *list_remove(struct list *list, const void *data)
/** @private */
JAYLINK_PRIV struct list *list_find_custom(struct list *list,
- list_compare_callback cb, const void *cb_data)
+ list_compare_callback callback, const void *user_data)
{
- if (!cb)
+ if (!callback)
return NULL;
while (list) {
- if (!cb(list->data, cb_data))
+ if (callback(list->data, user_data))
return list;
list = list->next;
@@ -94,12 +94,12 @@ JAYLINK_PRIV struct list *list_find_custom(struct list *list,
/** @private */
JAYLINK_PRIV size_t list_length(struct list *list)
{
- size_t n;
+ size_t length;
- for (n = 0; list; n++)
+ for (length = 0; list; length++)
list = list->next;
- return n;
+ return length;
}
/** @private */
diff --git a/libjaylink/log.c b/libjaylink/log.c
index 8e75bee..af9bfd3 100644
--- a/libjaylink/log.c
+++ b/libjaylink/log.c
@@ -131,7 +131,7 @@ JAYLINK_API int jaylink_log_set_callback(struct jaylink_context *ctx,
* @since 0.1.0
*/
JAYLINK_API int jaylink_log_set_domain(struct jaylink_context *ctx,
- char *domain)
+ const char *domain)
{
int ret;
diff --git a/libjaylink/strutil.c b/libjaylink/strutil.c
index 2bfd899..283ed17 100644
--- a/libjaylink/strutil.c
+++ b/libjaylink/strutil.c
@@ -48,16 +48,16 @@
JAYLINK_API int jaylink_parse_serial_number(const char *str,
uint32_t *serial_number)
{
- char *endptr;
+ char *end_ptr;
unsigned long long tmp;
if (!str || !serial_number)
return JAYLINK_ERR_ARG;
errno = 0;
- tmp = strtoull(str, &endptr, 10);
+ tmp = strtoull(str, &end_ptr, 10);
- if (*endptr != '\0' || errno != 0 || tmp > UINT32_MAX)
+ if (*end_ptr != '\0' || errno != 0 || tmp > UINT32_MAX)
return JAYLINK_ERR;
*serial_number = tmp;
diff --git a/libjaylink/swd.c b/libjaylink/swd.c
index 2dcf16d..29265b7 100644
--- a/libjaylink/swd.c
+++ b/libjaylink/swd.c
@@ -58,9 +58,9 @@
* @retval JAYLINK_ERR_ARG Invalid arguments.
* @retval JAYLINK_ERR_TIMEOUT A timeout occurred.
* @retval JAYLINK_ERR_IO Input/output error.
- * @retval JAYLINK_ERR_DEV Unspecified device error.
* @retval JAYLINK_ERR_DEV_NO_MEMORY Not enough memory on the device to perform
* the operation.
+ * @retval JAYLINK_ERR_DEV Unspecified device error.
* @retval JAYLINK_ERR Other error conditions.
*
* @see jaylink_select_interface()
@@ -140,7 +140,7 @@ JAYLINK_API int jaylink_swd_io(struct jaylink_device_handle *devh,
if (status == SWD_IO_ERR_NO_MEMORY) {
return JAYLINK_ERR_DEV_NO_MEMORY;
} else if (status > 0) {
- log_err(ctx, "SWD I/O operation failed: %02x.", status);
+ log_err(ctx, "SWD I/O operation failed: 0x%x.", status);
return JAYLINK_ERR_DEV;
}
diff --git a/libjaylink/swo.c b/libjaylink/swo.c
index 7dfa7f7..6037f64 100644
--- a/libjaylink/swo.c
+++ b/libjaylink/swo.c
@@ -74,7 +74,7 @@ JAYLINK_API int jaylink_swo_start(struct jaylink_device_handle *devh,
int ret;
struct jaylink_context *ctx;
uint8_t buf[32];
- uint32_t tmp;
+ uint32_t status;
if (!devh || !baudrate || !size)
return JAYLINK_ERR_ARG;
@@ -124,10 +124,10 @@ JAYLINK_API int jaylink_swo_start(struct jaylink_device_handle *devh,
return ret;
}
- tmp = buffer_get_u32(buf, 0);
+ status = buffer_get_u32(buf, 0);
- if (tmp > 0) {
- log_err(ctx, "Failed to start capture: %u.", tmp);
+ if (status > 0) {
+ log_err(ctx, "Failed to start capture: 0x%x.", status);
return JAYLINK_ERR_DEV;
}
@@ -158,7 +158,7 @@ JAYLINK_API int jaylink_swo_stop(struct jaylink_device_handle *devh)
int ret;
struct jaylink_context *ctx;
uint8_t buf[4];
- uint32_t tmp;
+ uint32_t status;
if (!devh)
return JAYLINK_ERR_ARG;
@@ -192,10 +192,10 @@ JAYLINK_API int jaylink_swo_stop(struct jaylink_device_handle *devh)
return ret;
}
- tmp = buffer_get_u32(buf, 0);
+ status = buffer_get_u32(buf, 0);
- if (tmp > 0) {
- log_err(ctx, "Failed to stop capture: %u.", tmp);
+ if (status > 0) {
+ log_err(ctx, "Failed to stop capture: 0x%x.", status);
return JAYLINK_ERR_DEV;
}
@@ -303,7 +303,7 @@ JAYLINK_API int jaylink_swo_read(struct jaylink_device_handle *devh,
}
if (status > 0) {
- log_err(ctx, "Failed to read data: %u.", status);
+ log_err(ctx, "Failed to read data: 0x%x.", status);
return JAYLINK_ERR_DEV;
}
diff --git a/libjaylink/target.c b/libjaylink/target.c
index 923e3ad..264335b 100644
--- a/libjaylink/target.c
+++ b/libjaylink/target.c
@@ -268,8 +268,7 @@ JAYLINK_API int jaylink_select_interface(struct jaylink_device_handle *devh,
* #JAYLINK_DEV_CAP_SELECT_TIF capability.
*
* @param[in,out] devh Device handle.
- * @param[out] interfaces Target interfaces on success, and undefined on
- * failure.
+ * @param[out] ifaces Target interfaces on success, and undefined on failure.
*
* @retval JAYLINK_OK Success.
* @retval JAYLINK_ERR_ARG Invalid arguments.
@@ -282,13 +281,13 @@ JAYLINK_API int jaylink_select_interface(struct jaylink_device_handle *devh,
* @since 0.1.0
*/
JAYLINK_API int jaylink_get_available_interfaces(
- struct jaylink_device_handle *devh, uint32_t *interfaces)
+ struct jaylink_device_handle *devh, uint32_t *ifaces)
{
int ret;
struct jaylink_context *ctx;
uint8_t buf[4];
- if (!devh || !interfaces)
+ if (!devh || !ifaces)
return JAYLINK_ERR_ARG;
ctx = devh->dev->ctx;
@@ -319,7 +318,7 @@ JAYLINK_API int jaylink_get_available_interfaces(
return ret;
}
- *interfaces = buffer_get_u32(buf, 0);
+ *ifaces = buffer_get_u32(buf, 0);
return JAYLINK_OK;
}
diff --git a/libjaylink/transport.c b/libjaylink/transport.c
index a82b83d..5000a20 100644
--- a/libjaylink/transport.c
+++ b/libjaylink/transport.c
@@ -25,6 +25,12 @@
#include "libjaylink.h"
#include "libjaylink-internal.h"
+/*
+ * libusb.h includes windows.h and therefore must be included after anything
+ * that includes winsock2.h.
+ */
+#include <libusb.h>
+
/**
* @file
*
@@ -50,7 +56,7 @@ static int initialize_handle(struct jaylink_device_handle *devh)
struct libusb_config_descriptor *config;
const struct libusb_interface *interface;
const struct libusb_interface_descriptor *desc;
- const struct libusb_endpoint_descriptor *epdesc;
+ const struct libusb_endpoint_descriptor *ep_desc;
bool found_interface;
bool found_endpoint_in;
bool found_endpoint_out;
@@ -105,13 +111,13 @@ static int initialize_handle(struct jaylink_device_handle *devh)
found_endpoint_out = false;
for (i = 0; i < desc->bNumEndpoints; i++) {
- epdesc = &desc->endpoint[i];
+ ep_desc = &desc->endpoint[i];
- if (epdesc->bEndpointAddress & LIBUSB_ENDPOINT_IN) {
- devh->endpoint_in = epdesc->bEndpointAddress;
+ if (ep_desc->bEndpointAddress & LIBUSB_ENDPOINT_IN) {
+ devh->endpoint_in = ep_desc->bEndpointAddress;
found_endpoint_in = true;
} else {
- devh->endpoint_out = epdesc->bEndpointAddress;
+ devh->endpoint_out = ep_desc->bEndpointAddress;
found_endpoint_out = true;
}
}