diff options
author | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2020-04-04 19:11:17 +0200 |
---|---|---|
committer | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2020-06-11 12:45:38 +0200 |
commit | 4b24090addee364740a44eac294b253886b7c228 (patch) | |
tree | 97c1ae24c71b5b2e03074ac89a25187419e07c94 | |
parent | a4b38768b6f7bcba5d05476adb08975b222394ff (diff) | |
download | hardware_replicant_libsamsung-ipc-4b24090addee364740a44eac294b253886b7c228.tar.gz hardware_replicant_libsamsung-ipc-4b24090addee364740a44eac294b253886b7c228.tar.bz2 hardware_replicant_libsamsung-ipc-4b24090addee364740a44eac294b253886b7c228.zip |
samsung-ipc: net: switch to Linux code style
This contains no functional changes.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rw-r--r-- | samsung-ipc/net.c | 125 |
1 files changed, 66 insertions, 59 deletions
diff --git a/samsung-ipc/net.c b/samsung-ipc/net.c index 50cc18f..70a38cc 100644 --- a/samsung-ipc/net.c +++ b/samsung-ipc/net.c @@ -24,86 +24,93 @@ #include <samsung-ipc.h> int ipc_net_plmn_sel_setup(struct ipc_net_plmn_sel_request_data *data, - unsigned char mode_sel, const char *plmn, unsigned char act) + unsigned char mode_sel, const char *plmn, + unsigned char act) { - size_t plmn_length; - - if (data == NULL) - return -1; - - memset(data, 0, sizeof(struct ipc_net_plmn_sel_request_data)); - data->mode_sel = mode_sel; - - if (mode_sel == IPC_NET_PLMN_SEL_AUTO) { - data->act = IPC_NET_ACCESS_TECHNOLOGY_UNKNOWN; - } else { - plmn_length = strlen(plmn); - if (plmn_length > sizeof(data->plmn)) - plmn_length = sizeof(data->plmn); - - memcpy((void *) data->plmn, (void *) plmn, plmn_length); - - // If there are less (5 is the usual case) PLMN bytes, fill the rest with '#' - if (plmn_length < sizeof(data->plmn)) - memset((void *) ((unsigned char *) data->plmn + plmn_length), '#', sizeof(data->plmn) - plmn_length); - - data->act = act; - } - - return 0; + size_t plmn_length; + + if (data == NULL) + return -1; + + memset(data, 0, sizeof(struct ipc_net_plmn_sel_request_data)); + data->mode_sel = mode_sel; + + if (mode_sel == IPC_NET_PLMN_SEL_AUTO) { + data->act = IPC_NET_ACCESS_TECHNOLOGY_UNKNOWN; + } else { + plmn_length = strlen(plmn); + if (plmn_length > sizeof(data->plmn)) + plmn_length = sizeof(data->plmn); + + memcpy((void *) data->plmn, (void *) plmn, plmn_length); + + /* + * If there are less (5 is the usual case) PLMN bytes, fill the + * rest with '#' + */ + if (plmn_length < sizeof(data->plmn)) { + memset((void *) ((unsigned char *) data->plmn + + plmn_length), + '#', + sizeof(data->plmn) - plmn_length); + } + + data->act = act; + } + + return 0; } int ipc_net_regist_setup(struct ipc_net_regist_request_data *data, - unsigned char domain) + unsigned char domain) { - if (data == NULL) - return -1; + if (data == NULL) + return -1; - memset(data, 0, sizeof(struct ipc_net_regist_request_data)); - data->act = IPC_NET_ACCESS_TECHNOLOGY_UNKNOWN; - data->domain = domain; + memset(data, 0, sizeof(struct ipc_net_regist_request_data)); + data->act = IPC_NET_ACCESS_TECHNOLOGY_UNKNOWN; + data->domain = domain; - return 0; + return 0; } unsigned char ipc_net_plmn_list_count_extract(const void *data, size_t size) { - struct ipc_net_plmn_list_header *header; + struct ipc_net_plmn_list_header *header; - if (data == NULL || size < sizeof(struct ipc_net_plmn_list_header)) - return 0; + if (data == NULL || size < sizeof(struct ipc_net_plmn_list_header)) + return 0; - header = (struct ipc_net_plmn_list_header *) data; + header = (struct ipc_net_plmn_list_header *) data; - return header->count; + return header->count; } -struct ipc_net_plmn_list_entry *ipc_net_plmn_list_entry_extract(const void *data, - size_t size, unsigned int index) +struct ipc_net_plmn_list_entry *ipc_net_plmn_list_entry_extract( + const void *data, size_t size, unsigned int index) { - struct ipc_net_plmn_list_entry *entry = NULL; - unsigned char count; - unsigned char i; - unsigned int offset; + struct ipc_net_plmn_list_entry *entry = NULL; + unsigned char count; + unsigned char i; + unsigned int offset; - if (data == NULL) - return NULL; + if (data == NULL) + return NULL; - count = ipc_net_plmn_list_count_extract(data, size); - if (count == 0 || index >= count) - return NULL; + count = ipc_net_plmn_list_count_extract(data, size); + if (count == 0 || index >= count) + return NULL; - offset = sizeof(struct ipc_net_plmn_list_header); + offset = sizeof(struct ipc_net_plmn_list_header); - for (i = 0; i < (index + 1); i++) { - entry = (struct ipc_net_plmn_list_entry *) ((unsigned char *) data + offset); - offset += sizeof(struct ipc_net_plmn_list_entry); - } + for (i = 0; i < (index + 1); i++) { + entry = (struct ipc_net_plmn_list_entry *) ( + (unsigned char *) data + offset); + offset += sizeof(struct ipc_net_plmn_list_entry); + } - if (offset > size) - return NULL; + if (offset > size) + return NULL; - return entry; + return entry; } - -// vim:ts=4:sw=4:expandtab |