diff options
author | Simon Busch <morphis@gravedo.de> | 2012-09-05 09:53:36 +0200 |
---|---|---|
committer | Simon Busch <morphis@gravedo.de> | 2012-09-09 12:23:21 +0200 |
commit | 3a9c878ca37442aca10917306fffb625c46b0ec4 (patch) | |
tree | 0d60e6b6ab27f6e8e7746b3b1abb6f7097f1dc59 /samsung-ipc | |
parent | db180081a182a2cd5652f9b1c147b974bae54811 (diff) | |
download | external_libsamsung-ipc-3a9c878ca37442aca10917306fffb625c46b0ec4.zip external_libsamsung-ipc-3a9c878ca37442aca10917306fffb625c46b0ec4.tar.gz external_libsamsung-ipc-3a9c878ca37442aca10917306fffb625c46b0ec4.tar.bz2 |
ipc: refactor ipc_client_gprs_get_iface method to return iface name instead of using a parameter
Allocating memory and setting a pointer to it for the user via a parameter is kind of
unnecessary. It's better to return the pointer instead.
Diffstat (limited to 'samsung-ipc')
-rw-r--r-- | samsung-ipc/device/aries/aries_ipc.c | 9 | ||||
-rw-r--r-- | samsung-ipc/device/crespo/crespo_ipc.c | 6 | ||||
-rw-r--r-- | samsung-ipc/device/xmm6260/xmm6260_ipc.c | 12 | ||||
-rw-r--r-- | samsung-ipc/device/xmm6260/xmm6260_ipc.h | 2 | ||||
-rw-r--r-- | samsung-ipc/ipc.c | 6 | ||||
-rw-r--r-- | samsung-ipc/ipc_private.h | 2 |
6 files changed, 18 insertions, 19 deletions
diff --git a/samsung-ipc/device/aries/aries_ipc.c b/samsung-ipc/device/aries/aries_ipc.c index 4860724..d987822 100644 --- a/samsung-ipc/device/aries/aries_ipc.c +++ b/samsung-ipc/device/aries/aries_ipc.c @@ -835,9 +835,10 @@ int aries_ipc_gprs_deactivate(void *data) return 0; } -int aries_ipc_gprs_get_iface(char **iface, int cid) +char* aries_ipc_gprs_get_iface(int cid) { struct ifreq ifr; + char *iface; int fd; int rc; int i; @@ -854,13 +855,11 @@ int aries_ipc_gprs_get_iface(char **iface, int cid) continue; } else { asprintf(iface, "%s%d", GPRS_IFACE_PREFIX, i); - return 0; + return iface; } } - *iface = NULL; - - return -1; + return NULL; } int aries_ipc_gprs_get_capabilities(struct ipc_client_gprs_capabilities *cap) diff --git a/samsung-ipc/device/crespo/crespo_ipc.c b/samsung-ipc/device/crespo/crespo_ipc.c index 33386d9..437c680 100644 --- a/samsung-ipc/device/crespo/crespo_ipc.c +++ b/samsung-ipc/device/crespo/crespo_ipc.c @@ -587,11 +587,11 @@ int crespo_ipc_power_off(void *io_data) return 0; } -int crespo_ipc_gprs_get_iface(char **iface, int cid) +char* crespo_ipc_gprs_get_iface(int cid) { + char *iface; asprintf(iface, "%s%d", GPRS_IFACE_PREFIX, 0); - - return 0; + return iface; } int crespo_ipc_gprs_get_capabilities(struct ipc_client_gprs_capabilities *cap) diff --git a/samsung-ipc/device/xmm6260/xmm6260_ipc.c b/samsung-ipc/device/xmm6260/xmm6260_ipc.c index ccc7a2c..f7fbcc9 100644 --- a/samsung-ipc/device/xmm6260/xmm6260_ipc.c +++ b/samsung-ipc/device/xmm6260/xmm6260_ipc.c @@ -344,16 +344,16 @@ int xmm6260_ipc_power_off(void *io_data) return 0; } -int xmm6260_ipc_gprs_get_iface(char **iface, int cid) +char* xmm6260_ipc_gprs_get_iface(int cid) { - if(cid > GPRS_IFACE_COUNT) { - *iface = NULL; - return -1; - } + char *iface; + + if(cid > GPRS_IFACE_COUNT) + return NULL; asprintf(iface, "%s%d", GPRS_IFACE_PREFIX, cid - 1); - return 0; + return iface; } int xmm6260_ipc_gprs_get_capabilities(struct ipc_client_gprs_capabilities *cap) diff --git a/samsung-ipc/device/xmm6260/xmm6260_ipc.h b/samsung-ipc/device/xmm6260/xmm6260_ipc.h index 58bd8a2..ac006d5 100644 --- a/samsung-ipc/device/xmm6260/xmm6260_ipc.h +++ b/samsung-ipc/device/xmm6260/xmm6260_ipc.h @@ -46,7 +46,7 @@ int xmm6260_ipc_read(void *data, unsigned int size, void *io_data); int xmm6260_ipc_write(void *data, unsigned int size, void *io_data); int xmm6260_ipc_power_on(void *io_data); int xmm6260_ipc_power_off(void *io_data); -int xmm6260_ipc_gprs_get_iface(char **iface, int cid); +char* xmm6260_ipc_gprs_get_iface(int cid); int xmm6260_ipc_gprs_get_capabilities(struct ipc_client_gprs_capabilities *cap); void *xmm6260_ipc_common_data_create(void); int xmm6260_ipc_common_data_destroy(void *io_data); diff --git a/samsung-ipc/ipc.c b/samsung-ipc/ipc.c index 993a3ab..62bce28 100644 --- a/samsung-ipc/ipc.c +++ b/samsung-ipc/ipc.c @@ -399,14 +399,14 @@ int ipc_client_gprs_deactivate(struct ipc_client *client) return client->handlers->gprs_deactivate(client->handlers->gprs_deactivate_data); } -int ipc_client_gprs_get_iface(struct ipc_client *client, char **iface, int cid) +char* ipc_client_gprs_get_iface(struct ipc_client *client, int cid) { if (client == NULL || client->gprs_specs == NULL || client->gprs_specs->gprs_get_iface == NULL) - return -1; + return NULL; - return client->gprs_specs->gprs_get_iface(iface, cid); + return client->gprs_specs->gprs_get_iface(cid); } int ipc_client_gprs_get_capabilities(struct ipc_client *client, struct ipc_client_gprs_capabilities *cap) diff --git a/samsung-ipc/ipc_private.h b/samsung-ipc/ipc_private.h index 6c7e0ad..89d60df 100644 --- a/samsung-ipc/ipc_private.h +++ b/samsung-ipc/ipc_private.h @@ -63,7 +63,7 @@ struct ipc_handlers { }; struct ipc_gprs_specs { - int (*gprs_get_iface)(char **iface, int cid); + char* (*gprs_get_iface)(int cid); int (*gprs_get_capabilities)(struct ipc_client_gprs_capabilities *cap); }; |