From 5072dea1373b7c4789a9ea1e65d05ea30acf41ed Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Sun, 5 Oct 2014 16:51:03 +0200 Subject: Convert int16_t macro error types into enum to improve debugging/type-checking This simple change provides various benefits for developers like compile time errors, better auto-completition in editors and the ability of a debugger to show the constant instead of just the raw value. Thanks to Aaron Burghardt for the proposal. --- include/libimobiledevice/service.h | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'include/libimobiledevice/service.h') diff --git a/include/libimobiledevice/service.h b/include/libimobiledevice/service.h index acf846b..760dbb4 100644 --- a/include/libimobiledevice/service.h +++ b/include/libimobiledevice/service.h @@ -30,23 +30,20 @@ extern "C" { #include #include -/** @name Error Codes */ -/*@{*/ -#define SERVICE_E_SUCCESS 0 -#define SERVICE_E_INVALID_ARG -1 -#define SERVICE_E_MUX_ERROR -3 -#define SERVICE_E_SSL_ERROR -4 -#define SERVICE_E_START_SERVICE_ERROR -5 -#define SERVICE_E_UNKNOWN_ERROR -256 -/*@}*/ - -/** Represents an error code. */ -typedef int16_t service_error_t; +/** Error Codes */ +typedef enum { + SERVICE_E_SUCCESS = 0, + SERVICE_E_INVALID_ARG = -1, + SERVICE_E_MUX_ERROR = -3, + SERVICE_E_SSL_ERROR = -4, + SERVICE_E_START_SERVICE_ERROR = -5, + SERVICE_E_UNKNOWN_ERROR = -256 +} service_error_t; typedef struct service_client_private service_client_private; typedef service_client_private* service_client_t; /**< The client handle. */ -#define SERVICE_CONSTRUCTOR(x) (int16_t (*)(idevice_t, lockdownd_service_descriptor_t, void**))(x) +#define SERVICE_CONSTRUCTOR(x) (int32_t (*)(idevice_t, lockdownd_service_descriptor_t, void**))(x) /* Interface */ @@ -79,7 +76,7 @@ service_error_t service_client_new(idevice_t device, lockdownd_service_descripto * @return SERVICE_E_SUCCESS on success, or a SERVICE_E_* error code * otherwise. */ -service_error_t service_client_factory_start_service(idevice_t device, const char* service_name, void **client, const char* label, int16_t (*constructor_func)(idevice_t, lockdownd_service_descriptor_t, void**), int16_t *error_code); +service_error_t service_client_factory_start_service(idevice_t device, const char* service_name, void **client, const char* label, int32_t (*constructor_func)(idevice_t, lockdownd_service_descriptor_t, void**), int32_t *error_code); /** * Frees a service instance. -- cgit v1.1-32-gdbae