Skip to content

Commit

Permalink
switched up some int vs enum libusb_option to pacify C++ type str…
Browse files Browse the repository at this point in the history
…ictness
  • Loading branch information
seanm committed Apr 20, 2024
1 parent 17d5923 commit 7e6a70e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions libusb/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ void usbi_disconnect_device(struct libusb_device *dev)
/* Perform some final sanity checks on a newly discovered device. If this
* function fails (negative return code), the device should not be added
* to the discovered device list. */
int usbi_sanitize_device(struct libusb_device *dev)
enum libusb_error usbi_sanitize_device(struct libusb_device *dev)
{
uint8_t num_configurations;

Expand All @@ -775,7 +775,7 @@ int usbi_sanitize_device(struct libusb_device *dev)
usbi_dbg(DEVICE_CTX(dev), "zero configurations, maybe an unauthorized device");
}

return 0;
return LIBUSB_SUCCESS;
}

/* Examine libusb's internal list of known devices, looking for one with
Expand Down Expand Up @@ -2466,14 +2466,14 @@ int API_EXPORTED libusb_init_context(libusb_context **ctx, const struct libusb_i
list_init(&_ctx->open_devs);

/* apply default options to all new contexts */
for (enum libusb_option option = 0 ; option < LIBUSB_OPTION_MAX ; option++) {
for (int option = 0 ; option < LIBUSB_OPTION_MAX ; option++) {
if (LIBUSB_OPTION_LOG_LEVEL == option || !default_context_options[option].is_set) {
continue;
}
if (LIBUSB_OPTION_LOG_CB != option) {
r = libusb_set_option(_ctx, option);
r = libusb_set_option(_ctx, (enum libusb_option)option);
} else {
r = libusb_set_option(_ctx, option, default_context_options[option].arg.log_cbval);
r = libusb_set_option(_ctx, (enum libusb_option)option, default_context_options[option].arg.log_cbval);
}
if (LIBUSB_SUCCESS != r)
goto err_free_ctx;
Expand Down
2 changes: 1 addition & 1 deletion libusb/libusbi.h
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ struct libusb_device *usbi_alloc_device(struct libusb_context *ctx,
unsigned long session_id);
struct libusb_device *usbi_get_device_by_session_id(struct libusb_context *ctx,
unsigned long session_id);
int usbi_sanitize_device(struct libusb_device *dev);
enum libusb_error usbi_sanitize_device(struct libusb_device *dev);
void usbi_handle_disconnect(struct libusb_device_handle *dev_handle);

int usbi_handle_transfer_completion(struct usbi_transfer *itransfer,
Expand Down
24 changes: 12 additions & 12 deletions libusb/os/darwin_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ static bool get_ioregistry_value_data (io_service_t service, CFStringRef propert
return success;
}

static int darwin_device_from_service (struct libusb_context *ctx, io_service_t service, usb_device_t* device)
static enum libusb_error darwin_device_from_service (struct libusb_context *ctx, io_service_t service, usb_device_t* device)
{
io_cf_plugin_ref_t *plugInInterface = NULL;
IOReturn kresult;
Expand Down Expand Up @@ -1593,7 +1593,7 @@ static int darwin_get_configuration(struct libusb_device_handle *dev_handle, uin
return LIBUSB_SUCCESS;
}

static enum libusb_error darwin_set_configuration(struct libusb_device_handle *dev_handle, int config) {
static int darwin_set_configuration(struct libusb_device_handle *dev_handle, int config) {
struct darwin_cached_device *dpriv = DARWIN_CACHED_DEVICE(dev_handle->dev);
IOReturn kresult;
uint8_t i;
Expand Down Expand Up @@ -1672,7 +1672,7 @@ static const struct libusb_interface_descriptor *get_interface_descriptor_by_num
return NULL;
}

static enum libusb_error get_endpoints (struct libusb_device_handle *dev_handle, uint8_t iface) {
static int get_endpoints (struct libusb_device_handle *dev_handle, uint8_t iface) {
struct darwin_device_handle_priv *priv = (struct darwin_device_handle_priv *)usbi_get_device_handle_priv(dev_handle);

/* current interface */
Expand Down Expand Up @@ -1742,7 +1742,7 @@ static int darwin_claim_interface(struct libusb_device_handle *dev_handle, uint8
struct darwin_device_handle_priv *priv = (struct darwin_device_handle_priv *)usbi_get_device_handle_priv(dev_handle);
io_service_t usbInterface = IO_OBJECT_NULL;
IOReturn kresult;
enum libusb_error ret;
int ret;
IOCFPlugInInterface **plugInInterface = NULL;
SInt32 score;

Expand Down Expand Up @@ -1885,7 +1885,7 @@ static int darwin_release_interface(struct libusb_device_handle *dev_handle, uin
}

static int check_alt_setting_and_clear_halt(struct libusb_device_handle *dev_handle, uint8_t altsetting, struct darwin_interface *cInterface) {
enum libusb_error ret;
int ret;
IOReturn kresult;
uint8_t current_alt_setting;

Expand All @@ -1911,7 +1911,7 @@ static int check_alt_setting_and_clear_halt(struct libusb_device_handle *dev_han
static int darwin_set_interface_altsetting(struct libusb_device_handle *dev_handle, uint8_t iface, uint8_t altsetting) {
struct darwin_device_handle_priv *priv = (struct darwin_device_handle_priv *)usbi_get_device_handle_priv(dev_handle);
IOReturn kresult;
enum libusb_error ret;
int ret;

/* current interface */
struct darwin_interface *cInterface = &priv->interfaces[iface];
Expand Down Expand Up @@ -1979,8 +1979,8 @@ static int darwin_clear_halt(struct libusb_device_handle *dev_handle, unsigned c
return darwin_to_libusb (kresult);
}

static int darwin_restore_state (struct libusb_device_handle *dev_handle, uint8_t active_config,
unsigned long claimed_interfaces) {
static enum libusb_error darwin_restore_state (struct libusb_device_handle *dev_handle, uint8_t active_config,
unsigned long claimed_interfaces) {
struct darwin_cached_device *dpriv = DARWIN_CACHED_DEVICE(dev_handle->dev);
struct darwin_device_handle_priv *priv = (struct darwin_device_handle_priv *)usbi_get_device_handle_priv(dev_handle);
int open_count = dpriv->open_count;
Expand Down Expand Up @@ -2144,7 +2144,7 @@ static int darwin_reenumerate_device (struct libusb_device_handle *dev_handle, b
static int darwin_reset_device (struct libusb_device_handle *dev_handle) {
struct darwin_cached_device *dpriv = DARWIN_CACHED_DEVICE(dev_handle->dev);
IOReturn kresult;
enum libusb_error ret;
int ret;

#if !defined(TARGET_OS_OSX) || TARGET_OS_OSX == 1
if (dpriv->capture_count > 0) {
Expand Down Expand Up @@ -2797,7 +2797,7 @@ static int darwin_detach_kernel_driver (struct libusb_device_handle *dev_handle,
UNUSED(interface);
struct darwin_cached_device *dpriv = DARWIN_CACHED_DEVICE(dev_handle->dev);
IOReturn kresult;
enum libusb_error err;
int err;
struct libusb_context *ctx = HANDLE_CTX (dev_handle);

if (get_interface_interface_version() < 700) {
Expand Down Expand Up @@ -2859,7 +2859,7 @@ static int darwin_attach_kernel_driver (struct libusb_device_handle *dev_handle,
}

static int darwin_capture_claim_interface(struct libusb_device_handle *dev_handle, uint8_t iface) {
enum libusb_error ret;
int ret;
if (dev_handle->auto_detach_kernel_driver && darwin_kernel_driver_active(dev_handle, iface)) {
ret = darwin_detach_kernel_driver (dev_handle, iface);
if (ret != LIBUSB_SUCCESS) {
Expand All @@ -2871,7 +2871,7 @@ static int darwin_capture_claim_interface(struct libusb_device_handle *dev_handl
}

static int darwin_capture_release_interface(struct libusb_device_handle *dev_handle, uint8_t iface) {
enum libusb_error ret;
int ret;
struct darwin_cached_device *dpriv = DARWIN_CACHED_DEVICE(dev_handle->dev);

ret = darwin_release_interface (dev_handle, iface);
Expand Down

0 comments on commit 7e6a70e

Please sign in to comment.