From c2531f3f54e08dcd2828a6c82778aca2f47f0c5a Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Mon, 29 Dec 2008 12:05:52 +0100 Subject: Add missing #include "utils.h" --- src/AFC.c | 1 + src/lockdown.c | 1 + src/usbmux.c | 1 + 3 files changed, 3 insertions(+) (limited to 'src') diff --git a/src/AFC.c b/src/AFC.c index 54ea1bb..99c1849 100644 --- a/src/AFC.c +++ b/src/AFC.c @@ -22,6 +22,7 @@ #include #include "AFC.h" #include "plist.h" +#include "utils.h" // This is the maximum size an AFC data packet can be diff --git a/src/lockdown.c b/src/lockdown.c index 65cbf90..80d3937 100644 --- a/src/lockdown.c +++ b/src/lockdown.c @@ -20,6 +20,7 @@ */ #include "usbmux.h" +#include "utils.h" #include "iphone.h" #include "lockdown.h" #include "userpref.h" diff --git a/src/usbmux.c b/src/usbmux.c index 2114758..9fb75ef 100644 --- a/src/usbmux.c +++ b/src/usbmux.c @@ -26,6 +26,7 @@ #include #include "usbmux.h" +#include "utils.h" static iphone_umux_client_t *connlist = NULL; static int clients = 0; -- cgit v1.1-32-gdbae From b22ea90796608bc4e44317275ee05944b0f45877 Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Mon, 29 Dec 2008 12:06:15 +0100 Subject: Fix "missing return value" warning --- src/usbmux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/usbmux.c b/src/usbmux.c index 9fb75ef..4512dad 100644 --- a/src/usbmux.c +++ b/src/usbmux.c @@ -179,7 +179,7 @@ iphone_error_t iphone_mux_new_client(iphone_device_t device, uint16_t src_port, iphone_error_t iphone_mux_free_client(iphone_umux_client_t client) { if (!client || !client->phone) - return; + return IPHONE_E_INVALID_ARG; client->header->tcp_flags = 0x04; client->header->scnt = htonl(client->header->scnt); -- cgit v1.1-32-gdbae From 0efa3bc3a3519695f288211d720620cc0672f054 Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Mon, 29 Dec 2008 12:06:30 +0100 Subject: Removed unused variables --- src/iphone.c | 2 +- src/userpref.c | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/iphone.c b/src/iphone.c index b7f6cc4..86226e7 100644 --- a/src/iphone.c +++ b/src/iphone.c @@ -146,7 +146,7 @@ iphone_error_t iphone_get_specific_device(int bus_n, int dev_n, iphone_device_t */ iphone_error_t iphone_get_device(iphone_device_t * device) { - struct usb_bus *bus, *busses; + struct usb_bus *bus; struct usb_device *dev; usb_init(); diff --git a/src/userpref.c b/src/userpref.c index db54679..6e2f9d8 100644 --- a/src/userpref.c +++ b/src/userpref.c @@ -92,9 +92,6 @@ int is_device_known(char *uid) { int ret = 0; gchar *config_file; - GKeyFile *key_file; - gchar **devices_list, **pcur, *keyfilepath, *stored_key; - GIOChannel *keyfile; /* first get config file */ gchar *device_file = g_strconcat(uid, ".pem", NULL); -- cgit v1.1-32-gdbae From d77ecbe3fbd73418dd72e147a0ac2a89e62b1cd9 Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Mon, 29 Dec 2008 12:35:51 +0100 Subject: Fix function prototypes Add missing static, const, change function() to function(void) --- src/AFC.c | 2 +- src/initconf.c | 4 ++-- src/iphone.c | 2 +- src/lockdown.c | 6 +++--- src/lockdown.h | 4 ++-- src/plist.c | 4 ++-- src/plist.h | 2 +- src/usbmux.c | 6 +++--- src/usbmux.h | 2 +- src/userpref.c | 6 +++--- src/userpref.h | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/AFC.c b/src/AFC.c index 99c1849..b665f8e 100644 --- a/src/AFC.c +++ b/src/AFC.c @@ -557,7 +557,7 @@ iphone_error_t iphone_afc_mkdir(iphone_afc_client_t client, const char *dir) * @return A pointer to an AFCFile struct containing the information received, * or NULL on failure. */ -iphone_afc_file_t afc_get_file_info(iphone_afc_client_t client, const char *path) +static iphone_afc_file_t afc_get_file_info(iphone_afc_client_t client, const char *path) { char *received, **list; iphone_afc_file_t my_file; diff --git a/src/initconf.c b/src/initconf.c index 8aca2a6..205c97a 100644 --- a/src/initconf.c +++ b/src/initconf.c @@ -36,7 +36,7 @@ * * @param key The pointer to the desired location of the new key. */ -void generate_key(gpointer key) +static void generate_key(gpointer key) { gnutls_x509_privkey_generate(*((gnutls_x509_privkey_t *) key), GNUTLS_PK_RSA, 2048, 0); g_thread_exit(0); @@ -44,7 +44,7 @@ void generate_key(gpointer key) /** Simple function that generates a spinner until the mutex is released. */ -void progress_bar(gpointer mutex) +static void progress_bar(gpointer mutex) { const char *spinner = "|/-\\|/-\\"; int i = 0; diff --git a/src/iphone.c b/src/iphone.c index 86226e7..f733219 100644 --- a/src/iphone.c +++ b/src/iphone.c @@ -42,7 +42,7 @@ * descriptor on return. * @return IPHONE_E_SUCCESS if ok, otherwise an error code. */ -iphone_error_t iphone_get_specific_device(int bus_n, int dev_n, iphone_device_t * device) +static iphone_error_t iphone_get_specific_device(unsigned int bus_n, int dev_n, iphone_device_t * device) { struct usb_bus *bus, *busses; struct usb_device *dev; diff --git a/src/lockdown.c b/src/lockdown.c index 80d3937..e0cbe78 100644 --- a/src/lockdown.c +++ b/src/lockdown.c @@ -40,7 +40,7 @@ const ASN1_ARRAY_TYPE pkcs1_asn1_tab[] = { {0, 0, 0} }; -int get_rand(int min, int max) +static int get_rand(int min, int max) { int retval = (rand() % (max - min)) + min; return retval; @@ -50,7 +50,7 @@ int get_rand(int min, int max) * * @param A null terminated string containing a valid HostID. */ -char *lockdownd_generate_hostid() +char *lockdownd_generate_hostid(void) { char *hostid = (char *) malloc(sizeof(char) * 37); // HostID's are just UUID's, and UUID's are 36 characters long const char *chars = "ABCDEF0123456789"; @@ -256,7 +256,7 @@ iphone_error_t lockdownd_hello(iphone_lckd_client_t control) * * @return IPHONE_E_SUCCESS on success. */ -iphone_error_t lockdownd_generic_get_value(iphone_lckd_client_t control, char *req_key, char *req_string, char **value) +iphone_error_t lockdownd_generic_get_value(iphone_lckd_client_t control, const char *req_key, const char *req_string, char **value) { if (!control || !req_key || !value || (value && *value)) return IPHONE_E_INVALID_ARG; diff --git a/src/lockdown.h b/src/lockdown.h index 9176524..012ac72 100644 --- a/src/lockdown.h +++ b/src/lockdown.h @@ -40,11 +40,11 @@ struct iphone_lckd_client_int { int gtls_buffer_hack_len; }; -char *lockdownd_generate_hostid(); +char *lockdownd_generate_hostid(void); iphone_lckd_client_t new_lockdownd_client(iphone_device_t phone); iphone_error_t lockdownd_hello(iphone_lckd_client_t control); -iphone_error_t lockdownd_generic_get_value(iphone_lckd_client_t control, char *req_key, char *req_string, char **value); +iphone_error_t lockdownd_generic_get_value(iphone_lckd_client_t control, const char *req_key, const char *req_string, char **value); iphone_error_t lockdownd_get_device_uid(iphone_lckd_client_t control, char **uid); iphone_error_t lockdownd_get_device_public_key(iphone_lckd_client_t control, char **public_key); diff --git a/src/plist.c b/src/plist.c index c4d6bfa..b9d9e6a 100644 --- a/src/plist.c +++ b/src/plist.c @@ -40,7 +40,7 @@ const char *plist_base = "\n\ * * @return The formatted string. */ -char *format_string(const char *buf, int cols, int depth) +static char *format_string(const char *buf, int cols, int depth) { int colw = depth + cols + 1; int len = strlen(buf); @@ -73,7 +73,7 @@ char *format_string(const char *buf, int cols, int depth) * * @return The plist XML document. */ -xmlDocPtr new_plist() +xmlDocPtr new_plist(void) { char *plist = strdup(plist_base); xmlDocPtr plist_xml = xmlReadMemory(plist, strlen(plist), NULL, NULL, 0); diff --git a/src/plist.h b/src/plist.h index b27a0c5..cd2028e 100644 --- a/src/plist.h +++ b/src/plist.h @@ -31,7 +31,7 @@ xmlNode *add_key_data_dict_element(xmlDocPtr plist, xmlNode * dict, const char * xmlNode *add_child_to_plist(xmlDocPtr plist, const char *name, const char *content, xmlNode * to_node, int depth); void free_plist(xmlDocPtr plist); -xmlDocPtr new_plist(); +xmlDocPtr new_plist(void); char **read_dict_element_strings(xmlNode * dict); void free_dictionary(char **dictionary); diff --git a/src/usbmux.c b/src/usbmux.c index 4512dad..770d0db 100644 --- a/src/usbmux.c +++ b/src/usbmux.c @@ -58,7 +58,7 @@ usbmux_tcp_header *new_mux_packet(uint16 s_port, uint16 d_port) * * @return A USBMux header */ -usbmux_version_header *version_header() +usbmux_version_header *version_header(void) { usbmux_version_header *version = (usbmux_version_header *) malloc(sizeof(usbmux_version_header)); version->type = 0; @@ -77,7 +77,7 @@ usbmux_version_header *version_header() * * @param connection The connection to delete from the tracking list. */ -void delete_connection(iphone_umux_client_t connection) +static void delete_connection(iphone_umux_client_t connection) { iphone_umux_client_t *newlist = (iphone_umux_client_t *) malloc(sizeof(iphone_umux_client_t) * (clients - 1)); int i = 0, j = 0; @@ -106,7 +106,7 @@ void delete_connection(iphone_umux_client_t connection) * @param connection The connection to add to the global list of connections. */ -void add_connection(iphone_umux_client_t connection) +static void add_connection(iphone_umux_client_t connection) { iphone_umux_client_t *newlist = (iphone_umux_client_t *) realloc(connlist, sizeof(iphone_umux_client_t) * (clients + 1)); diff --git a/src/usbmux.h b/src/usbmux.h index da8a361..fd5fc78 100644 --- a/src/usbmux.h +++ b/src/usbmux.h @@ -56,7 +56,7 @@ typedef struct { uint32 type, length, major, minor, allnull; } usbmux_version_header; -usbmux_version_header *version_header(); +usbmux_version_header *version_header(void); #endif diff --git a/src/userpref.c b/src/userpref.c index 6e2f9d8..5f227b0 100644 --- a/src/userpref.c +++ b/src/userpref.c @@ -39,7 +39,7 @@ /** Creates a freedesktop compatible configuration directory for libiphone. */ -inline void create_config_dir() +static void create_config_dir(void) { gchar *config_dir = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, NULL); @@ -56,7 +56,7 @@ inline void create_config_dir() * * @return The string containing the HostID or NULL */ -char *get_host_id() +char *get_host_id(void) { char *host_id = NULL; gchar *config_file; @@ -144,7 +144,7 @@ int store_device_public_key(char *uid, char *public_key) * * @return 1 if the file contents where read successfully and 0 otherwise. */ -int read_file_in_confdir(char *file, gnutls_datum_t * data) +static int read_file_in_confdir(const char *file, gnutls_datum_t * data) { gboolean success; gsize size; diff --git a/src/userpref.h b/src/userpref.h index 5171929..e7835d0 100644 --- a/src/userpref.h +++ b/src/userpref.h @@ -28,7 +28,7 @@ * * @return the HostID if exist in config file. Returns NULL otherwise. */ -char *get_host_id(); +char *get_host_id(void); /** * Determine if we already paired this device. -- cgit v1.1-32-gdbae From b30cd1dc05640ee6468b19e479162946a3722ac1 Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Mon, 29 Dec 2008 12:37:18 +0100 Subject: Some variables were unsigned while they should be dispatch_AFC_packet returns an int, but it was sometimes incorrectly assigned to a variable of type uint32_t which was then compared for being less or more than 0. --- src/AFC.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/AFC.c b/src/AFC.c index b665f8e..0c43d0d 100644 --- a/src/AFC.c +++ b/src/AFC.c @@ -796,7 +796,9 @@ iphone_afc_write_file(iphone_afc_client_t client, iphone_afc_file_t file, { char *acknowledgement = NULL; const int MAXIMUM_WRITE_SIZE = 1 << 15; - uint32 zero = 0, bytes_loc = 0, segments = (length / MAXIMUM_WRITE_SIZE), current_count = 0, i = 0; + uint32 zero = 0, current_count = 0, i = 0; + uint32 segments = (length / MAXIMUM_WRITE_SIZE); + int bytes_loc = 0; char *out_buffer = NULL; if (!client || !client->afc_packet || !client->connection || !file || !bytes) @@ -927,7 +929,8 @@ iphone_error_t iphone_afc_close_file(iphone_afc_client_t client, iphone_afc_file iphone_error_t iphone_afc_seek_file(iphone_afc_client_t client, iphone_afc_file_t file, int seekpos) { char *buffer = (char *) malloc(sizeof(char) * 24); - uint32 seekto = 0, bytes = 0, zero = 0; + uint32 seekto = 0, zero = 0; + int bytes = 0; if (seekpos < 0) seekpos = file->size - abs(seekpos); @@ -980,7 +983,8 @@ iphone_error_t iphone_afc_seek_file(iphone_afc_client_t client, iphone_afc_file_ iphone_error_t iphone_afc_truncate_file(iphone_afc_client_t client, iphone_afc_file_t file, uint32_t newsize) { char *buffer = (char *) malloc(sizeof(char) * 16); - uint32 bytes = 0, zero = 0; + int bytes = 0; + uint32 zero = 0; afc_lock(client); -- cgit v1.1-32-gdbae From a1b4064de6e3f28d8d3e1e5e9acdda5aee0f6a36 Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Mon, 29 Dec 2008 12:40:41 +0100 Subject: Add comment about some code that should not be reached --- src/iphone.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/iphone.c b/src/iphone.c index f733219..32d27f6 100644 --- a/src/iphone.c +++ b/src/iphone.c @@ -214,7 +214,7 @@ int send_to_phone(iphone_device_t phone, char *data, int datalen) } else { return bytes; } - + /* Should not be reached */ return -1; } -- cgit v1.1-32-gdbae From 5cde55426112a8cb79d809dae5f61e347c007212 Mon Sep 17 00:00:00 2001 From: Matt Colyer Date: Fri, 2 Jan 2009 09:56:18 -0800 Subject: Fix indent issues. --- src/AFC.c | 2 +- src/lockdown.c | 3 ++- src/lockdown.h | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/AFC.c b/src/AFC.c index 0c43d0d..6027ed2 100644 --- a/src/AFC.c +++ b/src/AFC.c @@ -983,7 +983,7 @@ iphone_error_t iphone_afc_seek_file(iphone_afc_client_t client, iphone_afc_file_ iphone_error_t iphone_afc_truncate_file(iphone_afc_client_t client, iphone_afc_file_t file, uint32_t newsize) { char *buffer = (char *) malloc(sizeof(char) * 16); - int bytes = 0; + int bytes = 0; uint32 zero = 0; afc_lock(client); diff --git a/src/lockdown.c b/src/lockdown.c index e0cbe78..cf0d99e 100644 --- a/src/lockdown.c +++ b/src/lockdown.c @@ -256,7 +256,8 @@ iphone_error_t lockdownd_hello(iphone_lckd_client_t control) * * @return IPHONE_E_SUCCESS on success. */ -iphone_error_t lockdownd_generic_get_value(iphone_lckd_client_t control, const char *req_key, const char *req_string, char **value) +iphone_error_t lockdownd_generic_get_value(iphone_lckd_client_t control, const char *req_key, const char *req_string, + char **value) { if (!control || !req_key || !value || (value && *value)) return IPHONE_E_INVALID_ARG; diff --git a/src/lockdown.h b/src/lockdown.h index 012ac72..79ca37e 100644 --- a/src/lockdown.h +++ b/src/lockdown.h @@ -44,7 +44,8 @@ char *lockdownd_generate_hostid(void); iphone_lckd_client_t new_lockdownd_client(iphone_device_t phone); iphone_error_t lockdownd_hello(iphone_lckd_client_t control); -iphone_error_t lockdownd_generic_get_value(iphone_lckd_client_t control, const char *req_key, const char *req_string, char **value); +iphone_error_t lockdownd_generic_get_value(iphone_lckd_client_t control, const char *req_key, const char *req_string, + char **value); iphone_error_t lockdownd_get_device_uid(iphone_lckd_client_t control, char **uid); iphone_error_t lockdownd_get_device_public_key(iphone_lckd_client_t control, char **public_key); -- cgit v1.1-32-gdbae