diff options
author | Paul Kocialkowski <contact@paulk.fr> | 2013-02-09 10:51:13 +0100 |
---|---|---|
committer | Paul Kocialkowski <contact@paulk.fr> | 2013-02-09 10:51:13 +0100 |
commit | e1a4eb9c0632d60ad96c685330202593775bb716 (patch) | |
tree | c90b6c5c7092100d5eff1e81daab9df3d40679a2 | |
parent | f53bf346ed8a843414a339646b9362d4015bfc25 (diff) | |
download | hardware_ril_samsung-ril-e1a4eb9c0632d60ad96c685330202593775bb716.zip hardware_ril_samsung-ril-e1a4eb9c0632d60ad96c685330202593775bb716.tar.gz hardware_ril_samsung-ril-e1a4eb9c0632d60ad96c685330202593775bb716.tar.bz2 |
Change coding style: add a space after if, for and while
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r-- | call.c | 16 | ||||
-rw-r--r-- | client.c | 32 | ||||
-rw-r--r-- | disp.c | 14 | ||||
-rw-r--r-- | gen.c | 34 | ||||
-rw-r--r-- | gprs.c | 158 | ||||
-rw-r--r-- | ipc.c | 76 | ||||
-rw-r--r-- | misc.c | 34 | ||||
-rw-r--r-- | net.c | 100 | ||||
-rw-r--r-- | pwr.c | 6 | ||||
-rw-r--r-- | rfs.c | 8 | ||||
-rw-r--r-- | samsung-ril.c | 70 | ||||
-rw-r--r-- | sat.c | 10 | ||||
-rw-r--r-- | sec.c | 64 | ||||
-rw-r--r-- | sms.c | 140 | ||||
-rw-r--r-- | srs.c | 124 | ||||
-rw-r--r-- | ss.c | 10 | ||||
-rw-r--r-- | util.c | 42 |
17 files changed, 469 insertions, 469 deletions
@@ -104,7 +104,7 @@ void ril_request_dial(RIL_Token t, void *data, size_t datalen) struct ipc_call_outgoing call; int clir; - if(strlen(dial->address) > sizeof(call.number)) { + if (strlen(dial->address) > sizeof(call.number)) { printf("Outgoing call number too long\n"); return; } @@ -168,7 +168,7 @@ void ipc_call_list(struct ipc_message_info *info) num_entries = *((unsigned char *) info->data); - if(num_entries == 0) { + if (num_entries == 0) { // Don't bother with mem alloc ril_request_complete(ril_request_get_token(info->aseq), RIL_E_SUCCESS, NULL, 0); @@ -179,7 +179,7 @@ void ipc_call_list(struct ipc_message_info *info) RIL_Call **calls = (RIL_Call **) malloc(num_entries * sizeof(RIL_Call *)); - for(i = 0; i < num_entries; i++) { + for (i = 0; i < num_entries; i++) { RIL_Call *call = (RIL_Call *) malloc(sizeof(RIL_Call)); /* Number is located after call list entry */ @@ -211,7 +211,7 @@ void ipc_call_list(struct ipc_message_info *info) ril_request_complete(ril_request_get_token(info->aseq), RIL_E_SUCCESS, calls, (num_entries * sizeof(RIL_Call *))); - for(i = 0; i < num_entries; i++) { + for (i = 0; i < num_entries; i++) { free(calls[i]); } @@ -288,7 +288,7 @@ void ril_request_dtmf(RIL_Token t, void *data, int length) unsigned char dtmf_count = 1; int i; - if(ril_data.state.dtmf_tone != 0) { + if (ril_data.state.dtmf_tone != 0) { LOGD("Another tone wasn't stopped, stopping that one before anything"); cont_dtmf.state = IPC_CALL_DTMF_STATE_STOP; @@ -305,7 +305,7 @@ void ril_request_dtmf(RIL_Token t, void *data, int length) burst[0] = dtmf_count; - for(i=0 ; i < dtmf_count ; i++) { + for (i=0 ; i < dtmf_count ; i++) { // Apparently, it's possible to set multiple DTMF tones on this message cont_dtmf.state = IPC_CALL_DTMF_STATE_START; @@ -326,7 +326,7 @@ void ipc_call_burst_dtmf(struct ipc_message_info *info) unsigned char ret = *((unsigned char *) info->data); // This apparently should return 1, or perhaps that is the DTMF tones count - if(ret == 0) { + if (ret == 0) { LOGD("Apparently, something went wrong with DTMF burst"); ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); @@ -339,7 +339,7 @@ void ril_request_dtmf_start(RIL_Token t, void *data, int length) { struct ipc_call_cont_dtmf cont_dtmf; - if(ril_data.state.dtmf_tone != 0) { + if (ril_data.state.dtmf_tone != 0) { LOGD("Another tone wasn't stopped, stopping that one before anything"); cont_dtmf.state = IPC_CALL_DTMF_STATE_STOP; @@ -37,13 +37,13 @@ struct ril_client *ril_client_new(struct ril_client_funcs *client_funcs) ril_client = malloc(sizeof(struct ril_client)); memset(ril_client, 0, sizeof(struct ril_client)); - if(client_funcs->create) + if (client_funcs->create) ril_client->funcs.create = client_funcs->create; - if(client_funcs->destroy) + if (client_funcs->destroy) ril_client->funcs.destroy = client_funcs->destroy; - if(client_funcs->read_loop) + if (client_funcs->read_loop) ril_client->funcs.read_loop = client_funcs->read_loop; pthread_mutex_init(&(ril_client->mutex), NULL); @@ -65,12 +65,12 @@ int ril_client_create(struct ril_client *client) int rc; int c; - for(c = 10 ; c > 0 ; c--) { + for (c = 10 ; c > 0 ; c--) { LOGD("Creating RIL client inners, try #%d", 11-c); rc = client->funcs.create(client); - if(rc < 0) + if (rc < 0) LOGD("RIL client inners creation failed!"); else break; @@ -78,7 +78,7 @@ int ril_client_create(struct ril_client *client) usleep(500000); } - if(c == 0) { + if (c == 0) { client->state = RIL_CLIENT_ERROR; return -1; } @@ -93,12 +93,12 @@ int ril_client_destroy(struct ril_client *client) int rc; int c; - for(c = 5 ; c > 0 ; c--) { + for (c = 5 ; c > 0 ; c--) { LOGD("Destroying RIL client inners, try #%d", 6-c); rc = client->funcs.destroy(client); - if(rc < 0) + if (rc < 0) LOGD("RIL client inners destroying failed!"); else break; @@ -106,7 +106,7 @@ int ril_client_destroy(struct ril_client *client) usleep(500000); } - if(c == 0) { + if (c == 0) { client->state = RIL_CLIENT_ERROR; return -1; } @@ -122,7 +122,7 @@ void *ril_client_thread(void *data) int rc; int c; - if(data == NULL) { + if (data == NULL) { LOGE("Data passed to thread is NULL!"); return 0; @@ -130,12 +130,12 @@ void *ril_client_thread(void *data) client = (struct ril_client *) data; - for(c = 5 ; c > 0 ; c--) { + for (c = 5 ; c > 0 ; c--) { client->state = RIL_CLIENT_READY; rc = client->funcs.read_loop(client); - if(rc < 0) { + if (rc < 0) { client->state = RIL_CLIENT_ERROR; LOGE("There was an error with the read loop! Trying to destroy and recreate client object"); @@ -152,19 +152,19 @@ void *ril_client_thread(void *data) } } - if(c == 0) { + if (c == 0) { LOGE("FATAL: Main loop failed too many times."); } // We are destroying everything here rc = ril_client_destroy(client); - if(rc < 0) { + if (rc < 0) { LOGE("RIL client destroy failed!"); } rc = ril_client_free(client); - if(rc < 0) { + if (rc < 0) { LOGE("RIL client free failed!"); } @@ -181,7 +181,7 @@ int ril_client_thread_start(struct ril_client *client) rc = pthread_create(&(client->thread), &attr, ril_client_thread, (void *) client); - if(rc != 0) { + if (rc != 0) { LOGE("pthread creation failed"); return -1; } @@ -36,11 +36,11 @@ void ipc2ril_rssi(unsigned char rssi, RIL_SignalStrength *ss) { int ril_rssi = 0; - if(rssi > 0x6f) { + if (rssi > 0x6f) { ril_rssi = 0; } else { ril_rssi = (((rssi - 0x71) * -1) - ((rssi - 0x71) * -1) % 2) / 2; - if(ril_rssi > 31) + if (ril_rssi > 31) ril_rssi = 31; } @@ -74,18 +74,18 @@ void ipc_disp_icon_info(struct ipc_message_info *info) #endif /* Don't consider this if modem isn't in normal power mode. */ - if(ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL) + if (ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL) return; - if(info->type == IPC_TYPE_NOTI && icon_info->rssi == 0xff) + if (info->type == IPC_TYPE_NOTI && icon_info->rssi == 0xff) return; ipc2ril_rssi(icon_info->rssi, &ss); - if(info->type == IPC_TYPE_NOTI) { + if (info->type == IPC_TYPE_NOTI) { LOGD("Unsol request!"); ril_request_unsolicited(RIL_UNSOL_SIGNAL_STRENGTH, &ss, sizeof(ss)); - } else if(info->type == IPC_TYPE_RESP) { + } else if (info->type == IPC_TYPE_RESP) { LOGD("Sol request!"); ril_request_complete(ril_request_get_token(info->aseq), RIL_E_SUCCESS, &ss, sizeof(ss)); } @@ -102,7 +102,7 @@ void ipc_disp_rssi_info(struct ipc_message_info *info) int rssi; /* Don't consider this if modem isn't in normal power mode. */ - if(ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL) + if (ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL) return; ipc2ril_rssi(rssi_info->rssi, &ss); @@ -58,7 +58,7 @@ int ipc_gen_phone_res_expect_register(unsigned char aseq, unsigned short command struct list_head *list; expect = calloc(1, sizeof(struct ipc_gen_phone_res_expect_info)); - if(expect == NULL) + if (expect == NULL) return -1; expect->aseq = aseq; @@ -68,12 +68,12 @@ int ipc_gen_phone_res_expect_register(unsigned char aseq, unsigned short command expect->abort = abort; list_end = ril_data.generic_responses; - while(list_end != NULL && list_end->next != NULL) + while (list_end != NULL && list_end->next != NULL) list_end = list_end->next; list = list_head_alloc((void *) expect, list_end, NULL); - if(ril_data.generic_responses == NULL) + if (ril_data.generic_responses == NULL) ril_data.generic_responses = list; return 0; @@ -83,16 +83,16 @@ void ipc_gen_phone_res_expect_unregister(struct ipc_gen_phone_res_expect_info *e { struct list_head *list; - if(expect == NULL) + if (expect == NULL) return; list = ril_data.generic_responses; - while(list != NULL) { - if(list->data == (void *) expect) { + while (list != NULL) { + if (list->data == (void *) expect) { memset(expect, 0, sizeof(struct ipc_gen_phone_res_expect_info)); free(expect); - if(list == ril_data.generic_responses) + if (list == ril_data.generic_responses) ril_data.generic_responses = list->next; list_head_free(list); @@ -110,12 +110,12 @@ struct ipc_gen_phone_res_expect_info *ipc_gen_phone_res_expect_info_find_aseq(un struct list_head *list; list = ril_data.generic_responses; - while(list != NULL) { + while (list != NULL) { expect = (struct ipc_gen_phone_res_expect_info *) list->data; - if(expect == NULL) + if (expect == NULL) goto list_continue; - if(expect->aseq == aseq) + if (expect->aseq == aseq) return expect; list_continue: @@ -156,42 +156,42 @@ void ipc_gen_phone_res(struct ipc_message_info *info) RIL_Errno e; int rc; - if(info->data == NULL || info->length < sizeof(struct ipc_gen_phone_res)) + if (info->data == NULL || info->length < sizeof(struct ipc_gen_phone_res)) return; phone_res = (struct ipc_gen_phone_res *) info->data; expect = ipc_gen_phone_res_expect_info_find_aseq(info->aseq); - if(expect == NULL) { + if (expect == NULL) { LOGD("aseq: 0x%x not found in the IPC_GEN_PHONE_RES queue", info->aseq); return; } LOGD("aseq: 0x%x found in the IPC_GEN_PHONE_RES queue!", info->aseq); - if(expect->command != IPC_COMMAND(phone_res)) { + if (expect->command != IPC_COMMAND(phone_res)) { LOGE("IPC_GEN_PHONE_RES aseq (0x%x) doesn't match the queued one with command (0x%x)", expect->aseq, expect->command); - if(expect->func != NULL) { + if (expect->func != NULL) { LOGE("Not safe to run the custom function, reporting generic failure"); ril_request_complete(ril_request_get_token(expect->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); goto unregister; } } - if(expect->func != NULL) { + if (expect->func != NULL) { expect->func(info); goto unregister; } rc = ipc_gen_phone_res_check(phone_res); - if(rc < 0) + if (rc < 0) e = RIL_E_GENERIC_FAILURE; else e = RIL_E_SUCCESS; - if(expect->complete || (expect->abort && e == RIL_E_GENERIC_FAILURE)) + if (expect->complete || (expect->abort && e == RIL_E_GENERIC_FAILURE)) ril_request_complete(ril_request_get_token(expect->aseq), e, NULL, 0); unregister: @@ -86,18 +86,18 @@ int ril_gprs_connection_register(int cid) struct list_head *list; gprs_connection = calloc(1, sizeof(struct ril_gprs_connection)); - if(gprs_connection == NULL) + if (gprs_connection == NULL) return -1; gprs_connection->cid = cid; list_end = ril_data.gprs_connections; - while(list_end != NULL && list_end->next != NULL) + while (list_end != NULL && list_end->next != NULL) list_end = list_end->next; list = list_head_alloc((void *) gprs_connection, list_end, NULL); - if(ril_data.gprs_connections == NULL) + if (ril_data.gprs_connections == NULL) ril_data.gprs_connections = list; return 0; @@ -107,16 +107,16 @@ void ril_gprs_connection_unregister(struct ril_gprs_connection *gprs_connection) { struct list_head *list; - if(gprs_connection == NULL) + if (gprs_connection == NULL) return; list = ril_data.gprs_connections; - while(list != NULL) { - if(list->data == (void *) gprs_connection) { + while (list != NULL) { + if (list->data == (void *) gprs_connection) { memset(gprs_connection, 0, sizeof(struct ril_gprs_connection)); free(gprs_connection); - if(list == ril_data.gprs_connections) + if (list == ril_data.gprs_connections) ril_data.gprs_connections = list->next; list_head_free(list); @@ -134,12 +134,12 @@ struct ril_gprs_connection *ril_gprs_connection_find_cid(int cid) struct list_head *list; list = ril_data.gprs_connections; - while(list != NULL) { + while (list != NULL) { gprs_connection = (struct ril_gprs_connection *) list->data; - if(gprs_connection == NULL) + if (gprs_connection == NULL) goto list_continue; - if(gprs_connection->cid == cid) + if (gprs_connection->cid == cid) return gprs_connection; list_continue: @@ -155,12 +155,12 @@ struct ril_gprs_connection *ril_gprs_connection_find_token(RIL_Token t) struct list_head *list; list = ril_data.gprs_connections; - while(list != NULL) { + while (list != NULL) { gprs_connection = (struct ril_gprs_connection *) list->data; - if(gprs_connection == NULL) + if (gprs_connection == NULL) goto list_continue; - if(gprs_connection->token == t) + if (gprs_connection->token == t) return gprs_connection; list_continue: @@ -184,15 +184,15 @@ struct ril_gprs_connection *ril_gprs_connection_start(void) ipc_client_gprs_get_capabilities(ipc_client, &gprs_capabilities); cid_max = gprs_capabilities.cid_max; - for(i=0 ; i < cid_max ; i++) { + for (i=0 ; i < cid_max ; i++) { cid = i + 1; list = ril_data.gprs_connections; - while(list != NULL) { - if(list->data == NULL) + while (list != NULL) { + if (list->data == NULL) goto list_continue; gprs_connection = (struct ril_gprs_connection *) list->data; - if(gprs_connection->cid == cid) { + if (gprs_connection->cid == cid) { cid = 0; break; } @@ -201,18 +201,18 @@ list_continue: list = list->next; } - if(cid > 0) + if (cid > 0) break; } - if(cid <= 0) { + if (cid <= 0) { LOGE("Unable to find an unused cid, aborting"); return NULL; } LOGD("Using GPRS connection cid: %d", cid); rc = ril_gprs_connection_register(cid); - if(rc < 0) + if (rc < 0) return NULL; gprs_connection = ril_gprs_connection_find_cid(cid); @@ -221,10 +221,10 @@ list_continue: void ril_gprs_connection_stop(struct ril_gprs_connection *gprs_connection) { - if(gprs_connection == NULL) + if (gprs_connection == NULL) return; - if(gprs_connection->interface != NULL) + if (gprs_connection->interface != NULL) free(gprs_connection->interface); ril_gprs_connection_unregister(gprs_connection); @@ -238,7 +238,7 @@ void ipc_gprs_pdp_context_enable_complete(struct ipc_message_info *info) gprs_connection = ril_gprs_connection_find_token(ril_request_get_token(info->aseq)); - if(!gprs_connection) { + if (!gprs_connection) { LOGE("Unable to find GPRS connection, aborting"); ril_request_complete(ril_request_get_token(info->aseq), @@ -247,7 +247,7 @@ void ipc_gprs_pdp_context_enable_complete(struct ipc_message_info *info) } rc = ipc_gen_phone_res_check(phone_res); - if(rc < 0) { + if (rc < 0) { LOGE("There was an error, aborting PDP context complete"); gprs_connection->fail_cause = PDP_FAIL_ERROR_UNSPECIFIED; @@ -272,7 +272,7 @@ void ipc_gprs_define_pdp_context_complete(struct ipc_message_info *info) gprs_connection = ril_gprs_connection_find_token(ril_request_get_token(info->aseq)); - if(!gprs_connection) { + if (!gprs_connection) { LOGE("Unable to find GPRS connection, aborting"); ril_request_complete(ril_request_get_token(info->aseq), @@ -281,7 +281,7 @@ void ipc_gprs_define_pdp_context_complete(struct ipc_message_info *info) } rc = ipc_gen_phone_res_check(phone_res); - if(rc < 0) { + if (rc < 0) { LOGE("There was an error, aborting define PDP context complete"); gprs_connection->fail_cause = PDP_FAIL_ERROR_UNSPECIFIED; @@ -296,7 +296,7 @@ void ipc_gprs_define_pdp_context_complete(struct ipc_message_info *info) request = ril_request_info_find_id(info->aseq); aseq = ril_request_id_get(); - if(request != NULL) + if (request != NULL) request->id = aseq; ipc_gen_phone_res_expect_to_func(aseq, IPC_GPRS_PDP_CONTEXT, @@ -317,7 +317,7 @@ void ipc_gprs_port_list_complete(struct ipc_message_info *info) gprs_connection = ril_gprs_connection_find_token(ril_request_get_token(info->aseq)); - if(!gprs_connection) { + if (!gprs_connection) { LOGE("Unable to find GPRS connection, aborting"); ril_request_complete(ril_request_get_token(info->aseq), @@ -326,7 +326,7 @@ void ipc_gprs_port_list_complete(struct ipc_message_info *info) } rc = ipc_gen_phone_res_check(phone_res); - if(rc < 0) { + if (rc < 0) { LOGE("There was an error, aborting port list complete"); gprs_connection->fail_cause = PDP_FAIL_ERROR_UNSPECIFIED; @@ -341,7 +341,7 @@ void ipc_gprs_port_list_complete(struct ipc_message_info *info) request = ril_request_info_find_id(info->aseq); aseq = ril_request_id_get(); - if(request != NULL) + if (request != NULL) request->id = aseq; ipc_gen_phone_res_expect_to_func(aseq, IPC_GPRS_DEFINE_PDP_CONTEXT, ipc_gprs_define_pdp_context_complete); @@ -373,7 +373,7 @@ void ril_request_setup_data_call(RIL_Token t, void *data, int length) gprs_connection = ril_gprs_connection_start(); - if(!gprs_connection) { + if (!gprs_connection) { LOGE("Unable to create GPRS connection, aborting"); ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); @@ -393,7 +393,7 @@ void ril_request_setup_data_call(RIL_Token t, void *data, int length) ipc_client_gprs_get_capabilities(ipc_client, &gprs_capabilities); // If the device has the capability, deal with port list - if(gprs_capabilities.port_list) { + if (gprs_capabilities.port_list) { ipc_gprs_port_list_setup(&port_list); ipc_gen_phone_res_expect_to_func(ril_request_get_id(t), IPC_GPRS_PORT_LIST, @@ -419,7 +419,7 @@ void ipc_gprs_ip_configuration(struct ipc_message_info *info) gprs_connection = ril_gprs_connection_find_cid(ip_configuration->cid); - if(!gprs_connection) { + if (!gprs_connection) { LOGE("Unable to find GPRS connection, aborting"); ril_request_complete(ril_request_get_token(info->aseq), @@ -444,7 +444,7 @@ void ipc_gprs_pdp_context_disable_complete(struct ipc_message_info *info) gprs_connection = ril_gprs_connection_find_token(ril_request_get_token(info->aseq)); - if(!gprs_connection) { + if (!gprs_connection) { LOGE("Unable to find GPRS connection, aborting"); ril_request_complete(ril_request_get_token(info->aseq), @@ -453,7 +453,7 @@ void ipc_gprs_pdp_context_disable_complete(struct ipc_message_info *info) } rc = ipc_gen_phone_res_check(phone_res); - if(rc < 0) { + if (rc < 0) { LOGE("There was an error, aborting PDP context complete"); // RILJ is not going to ask for fail reason @@ -477,7 +477,7 @@ void ril_request_deactivate_data_call(RIL_Token t, void *data, int length) gprs_connection = ril_gprs_connection_find_cid(atoi(cid)); - if(!gprs_connection) { + if (!gprs_connection) { LOGE("Unable to find GPRS connection, aborting"); ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); @@ -549,22 +549,22 @@ int ipc_gprs_connection_enable(struct ril_gprs_connection *gprs_connection, (ip_configuration->dns2)[2], (ip_configuration->dns2)[3]); - if(ipc_client_gprs_handlers_available(ipc_client)) { + if (ipc_client_gprs_handlers_available(ipc_client)) { rc = ipc_client_gprs_activate(ipc_client, gprs_connection->cid); - if(rc < 0) { + if (rc < 0) { // This is not a critical issue LOGE("Failed to activate interface!"); } } interface = ipc_client_gprs_get_iface(ipc_client, gprs_connection->cid); - if(interface == NULL) { + if (interface == NULL) { // This is not a critical issue, fallback to rmnet LOGE("Failed to get interface name!"); asprintf(&interface, "rmnet%d", gprs_connection->cid - 1); } - if(gprs_connection->interface == NULL && interface != NULL) { + if (gprs_connection->interface == NULL && interface != NULL) { gprs_connection->interface = strdup(interface); } @@ -588,7 +588,7 @@ int ipc_gprs_connection_enable(struct ril_gprs_connection *gprs_connection, inet_addr(dns1), inet_addr(dns2)); #endif - if(rc < 0) { + if (rc < 0) { LOGE("ifc_configure failed"); free(interface); @@ -636,9 +636,9 @@ int ipc_gprs_connection_disable(struct ril_gprs_connection *gprs_connection) ipc_client = ((struct ipc_client_data *) ril_data.ipc_fmt_client->data)->ipc_client; - if(gprs_connection->interface == NULL) { + if (gprs_connection->interface == NULL) { interface = ipc_client_gprs_get_iface(ipc_client, gprs_connection->cid); - if(interface == NULL) { + if (interface == NULL) { // This is not a critical issue, fallback to rmnet LOGE("Failed to get interface name!"); asprintf(&interface, "rmnet%d", gprs_connection->cid); @@ -651,16 +651,16 @@ int ipc_gprs_connection_disable(struct ril_gprs_connection *gprs_connection) rc = ifc_down(interface); - if(gprs_connection->interface == NULL) + if (gprs_connection->interface == NULL) free(interface); - if(rc < 0) { + if (rc < 0) { LOGE("ifc_down failed"); } - if(ipc_client_gprs_handlers_available(ipc_client)) { + if (ipc_client_gprs_handlers_available(ipc_client)) { rc = ipc_client_gprs_deactivate(ipc_client, gprs_connection->cid); - if(rc < 0) { + if (rc < 0) { // This is not a critical issue LOGE("Failed to deactivate interface!"); } @@ -675,25 +675,25 @@ void ril_data_call_response_free(RIL_Data_Call_Response_v6 *response) void ril_data_call_response_free(RIL_Data_Call_Response *response) #endif { - if(response == NULL) + if (response == NULL) return; - if(response->type != NULL) + if (response->type != NULL) free(response->type); #if RIL_VERSION >= 6 - if(response->addresses) + if (response->addresses) free(response->addresses); - if(response->ifname) + if (response->ifname) free(response->ifname); - if(response->dnses) + if (response->dnses) free(response->dnses); - if(response->gateways) + if (response->gateways) free(response->gateways); #else - if(response->apn) + if (response->apn) free(response->apn); - if(response->address) + if (response->address) free(response->address); #endif } @@ -715,7 +715,7 @@ void ipc_gprs_call_status(struct ipc_message_info *info) gprs_connection = ril_gprs_connection_find_cid(call_status->cid); - if(!gprs_connection) { + if (!gprs_connection) { LOGE("Unable to find GPRS connection, aborting"); ril_request_complete(ril_request_get_token(info->aseq), @@ -723,15 +723,15 @@ void ipc_gprs_call_status(struct ipc_message_info *info) return; } - if(call_status->fail_cause == 0) { - if(!gprs_connection->enabled && + if (call_status->fail_cause == 0) { + if (!gprs_connection->enabled && call_status->state == IPC_GPRS_STATE_ENABLED && gprs_connection->token != (RIL_Token) 0x00) { LOGD("GPRS connection is now enabled"); rc = ipc_gprs_connection_enable(gprs_connection, &setup_data_call_response); - if(rc < 0) { + if (rc < 0) { LOGE("Failed to enable and configure GPRS interface"); gprs_connection->enabled = 0; @@ -753,20 +753,20 @@ void ipc_gprs_call_status(struct ipc_message_info *info) #if RIL_VERSION >= 6 ril_data_call_response_free(&setup_data_call_response); #else - if(setup_data_call_response[0] != NULL) + if (setup_data_call_response[0] != NULL) free(setup_data_call_response[0]); - if(setup_data_call_response[1] != NULL) + if (setup_data_call_response[1] != NULL) free(setup_data_call_response[1]); - if(setup_data_call_response[2] != NULL) + if (setup_data_call_response[2] != NULL) free(setup_data_call_response[2]); #endif - } else if(gprs_connection->enabled && + } else if (gprs_connection->enabled && call_status->state == IPC_GPRS_STATE_DISABLED && gprs_connection->token != (RIL_Token) 0x00) { LOGD("GPRS connection is now disabled"); rc = ipc_gprs_connection_disable(gprs_connection); - if(rc < 0) { + if (rc < 0) { LOGE("Failed to disable GPRS interface"); ril_request_complete(gprs_connection->token, @@ -792,7 +792,7 @@ void ipc_gprs_call_status(struct ipc_message_info *info) ril_unsol_data_call_list_changed(); } } else { - if(!gprs_connection->enabled && + if (!gprs_connection->enabled && (call_status->state == IPC_GPRS_STATE_NOT_ENABLED || call_status->state == IPC_GPRS_STATE_DISABLED) && gprs_connection->token != (RIL_Token) 0x00) { @@ -808,12 +808,12 @@ void ipc_gprs_call_status(struct ipc_message_info *info) gprs_connection->token = (RIL_Token) 0x00; ril_unsol_data_call_list_changed(); - } else if(gprs_connection->enabled && + } else if (gprs_connection->enabled && call_status->state == IPC_GPRS_STATE_DISABLED) { LOGE("GPRS connection suddently got disabled"); rc = ipc_gprs_connection_disable(gprs_connection); - if(rc < 0) { + if (rc < 0) { LOGE("Failed to disable GPRS interface"); // RILJ is not going to ask for fail reason @@ -844,7 +844,7 @@ void ril_request_last_data_call_fail_cause(RIL_Token t) last_failed_cid = ril_data.state.gprs_last_failed_cid; - if(!last_failed_cid) { + if (!last_failed_cid) { LOGE("No GPRS connection was reported to have failed"); goto fail_cause_unspecified; @@ -852,7 +852,7 @@ void ril_request_last_data_call_fail_cause(RIL_Token t) gprs_connection = ril_gprs_connection_find_cid(last_failed_cid); - if(!gprs_connection) { + if (!gprs_connection) { LOGE("Unable to find GPRS connection"); goto fail_cause_unspecified; @@ -887,11 +887,11 @@ void ipc_gprs_pdp_context_fix(RIL_Data_Call_Response *data_call_list, int c) { int i, j, k; - for(i=0 ; i < c ; i++) { - for(j=i-1 ; j >= 0 ; j--) { - if(data_call_list[i].cid == data_call_list[j].cid) { - for(k=0 ; k < c ; k++) { - if(data_call_list[k].cid == 1) { + for (i=0 ; i < c ; i++) { + for (j=i-1 ; j >= 0 ; j--) { + if (data_call_list[i].cid == data_call_list[j].cid) { + for (k=0 ; k < c ; k++) { + if (data_call_list[k].cid == 1) { data_call_list[i].cid = 0; break; } @@ -920,15 +920,15 @@ void ipc_gprs_pdp_context(struct ipc_message_info *info) int i; - for(i=0 ; i < IPC_GPRS_PDP_CONTEXT_GET_DESC_COUNT ; i++) { + for (i=0 ; i < IPC_GPRS_PDP_CONTEXT_GET_DESC_COUNT ; i++) { data_call_list[i].cid = context->desc[i].cid; data_call_list[i].active = ipc2ril_gprs_connection_active(context->desc[i].state); - if(context->desc[i].state == IPC_GPRS_STATE_ENABLED) { + if (context->desc[i].state == IPC_GPRS_STATE_ENABLED) { gprs_connection = ril_gprs_connection_find_cid(context->desc[i].cid); - if(gprs_connection == NULL) { + if (gprs_connection == NULL) { LOGE("CID %d reported as enabled but not listed here", context->desc[i].cid); continue; @@ -975,14 +975,14 @@ void ipc_gprs_pdp_context(struct ipc_message_info *info) ipc_gprs_pdp_context_fix(data_call_list, IPC_GPRS_PDP_CONTEXT_GET_DESC_COUNT); - if(info->aseq == 0xff) + if (info->aseq == 0xff) ril_request_unsolicited(RIL_UNSOL_DATA_CALL_LIST_CHANGED, &data_call_list, sizeof(data_call_list)); else ril_request_complete(ril_request_get_token(info->aseq), RIL_E_SUCCESS, &data_call_list, sizeof(data_call_list)); - for(i = 0; i < IPC_GPRS_PDP_CONTEXT_GET_DESC_COUNT; i++) { + for (i = 0; i < IPC_GPRS_PDP_CONTEXT_GET_DESC_COUNT; i++) { ril_data_call_response_free(data_call_list + i); } } @@ -42,12 +42,12 @@ void ipc_fmt_send(const unsigned short command, const char type, unsigned char * { struct ipc_client *ipc_client; - if(ril_data.ipc_fmt_client == NULL) { + if (ril_data.ipc_fmt_client == NULL) { LOGE("ipc_fmt_client is null, aborting!"); return; } - if(ril_data.ipc_fmt_client->data == NULL) { + if (ril_data.ipc_fmt_client->data == NULL) { LOGE("ipc_fmt_client data is null, aborting!"); return; } @@ -66,12 +66,12 @@ int ipc_fmt_read_loop(struct ril_client *client) int ipc_client_fd; fd_set fds; - if(client == NULL) { + if (client == NULL) { LOGE("client is NULL, aborting!"); return -1; } - if(client->data == NULL) { + if (client->data == NULL) { LOGE("client data is NULL, aborting!"); return -1; } @@ -82,17 +82,17 @@ int ipc_fmt_read_loop(struct ril_client *client) FD_ZERO(&fds); FD_SET(ipc_client_fd, &fds); - while(1) { - if(ipc_client_fd < 0) { + while (1) { + if (ipc_client_fd < 0) { LOGE("IPC FMT client fd is negative, aborting!"); return -1; } select(FD_SETSIZE, &fds, NULL, NULL, NULL); - if(FD_ISSET(ipc_client_fd, &fds)) { + if (FD_ISSET(ipc_client_fd, &fds)) { RIL_CLIENT_LOCK(client); - if(ipc_client_recv(ipc_client, &info) < 0) { + if (ipc_client_recv(ipc_client, &info) < 0) { RIL_CLIENT_UNLOCK(client); LOGE("IPC FMT recv failed, aborting!"); return -1; @@ -101,7 +101,7 @@ int ipc_fmt_read_loop(struct ril_client *client) ipc_fmt_dispatch(&info); - if(info.data != NULL) + if (info.data != NULL) free(info.data); } } @@ -127,7 +127,7 @@ int ipc_fmt_create(struct ril_client *client) LOGD("Creating new FMT client"); ipc_client = ipc_client_new(IPC_CLIENT_TYPE_FMT); - if(ipc_client == NULL) { + if (ipc_client == NULL) { LOGE("FMT client creation failed!"); return -1; } @@ -137,7 +137,7 @@ int ipc_fmt_create(struct ril_client *client) LOGD("Setting log handler"); rc = ipc_client_set_log_handler(ipc_client, ipc_log_handler, NULL); - if(rc < 0) { + if (rc < 0) { LOGE("Setting log handler failed!"); return -1; } @@ -147,7 +147,7 @@ int ipc_fmt_create(struct ril_client *client) LOGD("Creating handlers common data"); rc = ipc_client_create_handlers_common_data(ipc_client); - if(rc < 0) { + if (rc < 0) { LOGE("Creating handlers common data failed!"); return -1; } @@ -155,7 +155,7 @@ int ipc_fmt_create(struct ril_client *client) LOGD("Starting modem bootstrap"); rc = ipc_client_bootstrap_modem(ipc_client); - if(rc < 0) { + if (rc < 0) { LOGE("Modem bootstrap failed!"); return -1; } @@ -163,7 +163,7 @@ int ipc_fmt_create(struct ril_client *client) LOGD("Client open..."); rc = ipc_client_open(ipc_client); - if(rc < 0) { + if (rc < 0) { LOGE("%s: failed to open ipc client", __FUNCTION__); return -1; } @@ -172,13 +172,13 @@ int ipc_fmt_create(struct ril_client *client) ipc_client_fd = ipc_client_get_handlers_common_data_fd(ipc_client); client_data->ipc_client_fd = ipc_client_fd; - if(ipc_client_fd < 0) { + if (ipc_client_fd < 0) { LOGE("%s: client_fmt_fd is negative, aborting", __FUNCTION__); return -1; } LOGD("Client power on..."); - if(ipc_client_power_on(ipc_client)) { + if (ipc_client_power_on(ipc_client)) { LOGE("%s: failed to power on ipc client", __FUNCTION__); return -1; } @@ -196,24 +196,24 @@ int ipc_fmt_destroy(struct ril_client *client) LOGD("Destrying ipc fmt client"); - if(client == NULL) { + if (client == NULL) { LOGE("client was already destroyed"); return 0; } - if(client->data == NULL) { + if (client->data == NULL) { LOGE("client data was already destroyed"); return 0; } ipc_client_fd = ((struct ipc_client_data *) client->data)->ipc_client_fd; - if(ipc_client_fd) + if (ipc_client_fd) close(ipc_client_fd); ipc_client = ((struct ipc_client_data *) client->data)->ipc_client; - if(ipc_client != NULL) { + if (ipc_client != NULL) { ipc_client_destroy_handlers_common_data(ipc_client); ipc_client_power_off(ipc_client); ipc_client_close(ipc_client); @@ -233,12 +233,12 @@ void ipc_rfs_send(const unsigned short command, unsigned char *data, const int l { struct ipc_client *ipc_client; - if(ril_data.ipc_rfs_client == NULL) { + if (ril_data.ipc_rfs_client == NULL) { LOGE("ipc_rfs_client is null, aborting!"); return; } - if(ril_data.ipc_rfs_client->data == NULL) { + if (ril_data.ipc_rfs_client->data == NULL) { LOGE("ipc_rfs_client data is null, aborting!"); return; } @@ -257,12 +257,12 @@ int ipc_rfs_read_loop(struct ril_client *client) int ipc_client_fd; fd_set fds; - if(client == NULL) { + if (client == NULL) { LOGE("client is NULL, aborting!"); return -1; } - if(client->data == NULL) { + if (client->data == NULL) { LOGE("client data is NULL, aborting!"); return -1; } @@ -273,17 +273,17 @@ int ipc_rfs_read_loop(struct ril_client *client) FD_ZERO(&fds); FD_SET(ipc_client_fd, &fds); - while(1) { - if(ipc_client_fd < 0) { + while (1) { + if (ipc_client_fd < 0) { LOGE("IPC RFS client fd is negative, aborting!"); return -1; } select(FD_SETSIZE, &fds, NULL, NULL, NULL); - if(FD_ISSET(ipc_client_fd, &fds)) { + if (FD_ISSET(ipc_client_fd, &fds)) { RIL_CLIENT_LOCK(client); - if(ipc_client_recv(ipc_client, &info) < 0) { + if (ipc_client_recv(ipc_client, &info) < 0) { RIL_CLIENT_UNLOCK(client); LOGE("IPC RFS recv failed, aborting!"); return -1; @@ -292,7 +292,7 @@ int ipc_rfs_read_loop(struct ril_client *client) ipc_rfs_dispatch(&info); - if(info.data != NULL) + if (info.data != NULL) free(info.data); } } @@ -318,7 +318,7 @@ int ipc_rfs_create(struct ril_client *client) LOGD("Creating new RFS client"); ipc_client = ipc_client_new(IPC_CLIENT_TYPE_RFS); - if(ipc_client == NULL) { + if (ipc_client == NULL) { LOGE("RFS client creation failed!"); return -1; } @@ -328,7 +328,7 @@ int ipc_rfs_create(struct ril_client *client) LOGD("Setting log handler"); rc = ipc_client_set_log_handler(ipc_client, ipc_log_handler, NULL); - if(rc < 0) { + if (rc < 0) { LOGE("Setting log handler failed!"); return -1; } @@ -338,7 +338,7 @@ int ipc_rfs_create(struct ril_client *client) LOGD("Creating handlers common data"); rc = ipc_client_create_handlers_common_data(ipc_client); - if(rc < 0) { + if (rc < 0) { LOGE("Creating handlers common data failed!"); return -1; } @@ -346,7 +346,7 @@ int ipc_rfs_create(struct ril_client *client) LOGD("Client open..."); rc = ipc_client_open(ipc_client); - if(rc < 0) { + if (rc < 0) { LOGE("%s: failed to open ipc client", __FUNCTION__); return -1; } @@ -355,7 +355,7 @@ int ipc_rfs_create(struct ril_client *client) ipc_client_fd = ipc_client_get_handlers_common_data_fd(ipc_client); client_data->ipc_client_fd = ipc_client_fd; - if(ipc_client_fd < 0) { + if (ipc_client_fd < 0) { LOGE("%s: client_rfs_fd is negative, aborting", __FUNCTION__); return -1; } @@ -374,24 +374,24 @@ int ipc_rfs_destroy(struct ril_client *client) LOGD("Destrying ipc rfs client"); - if(client == NULL) { + if (client == NULL) { LOGE("client was already destroyed"); return 0; } - if(client->data == NULL) { + if (client->data == NULL) { LOGE("client data was already destroyed"); return 0; } ipc_client_fd = ((struct ipc_client_data *) client->data)->ipc_client_fd; - if(ipc_client_fd) + if (ipc_client_fd) close(ipc_client_fd); ipc_client = ((struct ipc_client_data *) client->data)->ipc_client; - if(ipc_client != NULL) { + if (ipc_client != NULL) { ipc_client_destroy_handlers_common_data(ipc_client); ipc_client_close(ipc_client); ipc_client_free(ipc_client); @@ -36,7 +36,7 @@ void ril_request_get_imei_send(RIL_Token t) void ril_request_get_imei(RIL_Token t) { - if(ril_data.tokens.get_imei) { + if (ril_data.tokens.get_imei) { LOGD("Another IMEI request is waiting, aborting"); ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); return; @@ -44,10 +44,10 @@ void ril_request_get_imei(RIL_Token t) ril_data.tokens.get_imei = t; - if(ril_data.tokens.get_imeisv) { + if (ril_data.tokens.get_imeisv) { LOGD("IMEISV token found: %p", ril_data.tokens.get_imeisv); - if(ril_data.state.radio_state != RADIO_STATE_OFF) { + if (ril_data.state.radio_state != RADIO_STATE_OFF) { ril_request_get_imei_send(ril_data.tokens.get_imei); } else { LOGD("Radio is off, waiting"); @@ -59,7 +59,7 @@ void ril_request_get_imei(RIL_Token t) void ril_request_get_imeisv(RIL_Token t) { - if(ril_data.tokens.get_imeisv) { + if (ril_data.tokens.get_imeisv) { LOGD("Another IMEISV request is waiting, aborting"); ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); return; @@ -67,10 +67,10 @@ void ril_request_get_imeisv(RIL_Token t) ril_data.tokens.get_imeisv = t; - if(ril_data.tokens.get_imei) { + if (ril_data.tokens.get_imei) { LOGD("IMEI token found: %p", ril_data.tokens.get_imei); - if(ril_data.state.radio_state != RADIO_STATE_OFF) { + if (ril_data.state.radio_state != RADIO_STATE_OFF) { ril_request_get_imei_send(ril_data.tokens.get_imei); } else { LOGD("Radio is off, waiting"); @@ -88,11 +88,11 @@ void ipc_misc_me_sn_imei(RIL_Token t, void *data, int length) imei_info = (struct ipc_misc_me_sn *) data; - if(ril_data.tokens.get_imei != t) + if (ril_data.tokens.get_imei != t) LOGE("IMEI tokens mismatch (%p and %p)", ril_data.tokens.get_imei, t); - if(imei_info->length > 32) + if (imei_info->length > 32) return; memset(imei, 0, sizeof(imei)); @@ -104,19 +104,19 @@ void ipc_misc_me_sn_imei(RIL_Token t, void *data, int length) memcpy(imeisv, (imei_info->data + imei_info->length - 2), 2); // In case of token mismatch, complete both requests - if(t && ril_data.tokens.get_imei != t) { + if (t && ril_data.tokens.get_imei != t) { ril_request_complete(t, RIL_E_SUCCESS, imei, sizeof(char *)); } // IMEI - if(ril_data.tokens.get_imei) { + if (ril_data.tokens.get_imei) { ril_request_complete(ril_data.tokens.get_imei, RIL_E_SUCCESS, imei, sizeof(char *)); ril_data.tokens.get_imei = 0; } // IMEI SV - if(ril_data.tokens.get_imeisv) { + if (ril_data.tokens.get_imeisv) { ril_request_complete(ril_data.tokens.get_imeisv, RIL_E_SUCCESS, imeisv, sizeof(char *)); ril_data.tokens.get_imeisv = 0; @@ -141,7 +141,7 @@ void ipc_misc_me_sn(struct ipc_message_info *info) void ril_request_baseband_version(RIL_Token t) { unsigned char data; - if(ril_data.tokens.baseband_version) { + if (ril_data.tokens.baseband_version) { LOGD("Another Baseband version request is waiting, aborting"); ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); return; @@ -149,7 +149,7 @@ void ril_request_baseband_version(RIL_Token t) ril_data.tokens.baseband_version = t; - if(ril_data.state.radio_state != RADIO_STATE_OFF) { + if (ril_data.state.radio_state != RADIO_STATE_OFF) { data = 0xff; ipc_fmt_send(IPC_MISC_ME_VERSION, IPC_TYPE_GET, @@ -164,7 +164,7 @@ void ipc_misc_me_version(struct ipc_message_info *info) (struct ipc_misc_me_version *) info->data; RIL_Token t = ril_request_get_token(info->aseq); - if(ril_data.tokens.baseband_version != t) + if (ril_data.tokens.baseband_version != t) LOGE("Baseband tokens mismatch (%p and %p)", ril_data.tokens.baseband_version, t); @@ -203,10 +203,10 @@ void ipc_misc_me_imsi(struct ipc_message_info *info) char *imsi; /* Don't consider this if modem isn't in normal power mode. */ - if(ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL) + if (ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL) return; - if(info->length < 1) { + if (info->length < 1) { LOGE("%s: zero data length", __FUNCTION__); ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); @@ -215,7 +215,7 @@ void ipc_misc_me_imsi(struct ipc_message_info *info) imsi_length = (unsigned char*) info->data; - if(((int) info->length) < *imsi_length + 1) { + if (((int) info->length) < *imsi_length + 1) { LOGE("%s: missing IMSI data", __FUNCTION__); ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); @@ -230,15 +230,15 @@ void ril_plmn_split(char *plmn_data, char **plmn, unsigned int *mcc, unsigned in memset(plmn_t, 0, sizeof(plmn_t)); memcpy(plmn_t, plmn_data, 6); - if(plmn_t[5] == '#') + if (plmn_t[5] == '#') plmn_t[5] = '\0'; - if(plmn != NULL) { + if (plmn != NULL) { *plmn = malloc(sizeof(plmn_t)); memcpy(*plmn, plmn_t, sizeof(plmn_t)); } - if(mcc == NULL || mnc == NULL) + if (mcc == NULL || mnc == NULL) return; sscanf(plmn_t, "%3u%2u", mcc, mnc); @@ -261,8 +261,8 @@ void ril_plmn_string(char *plmn_data, char *response[3]) LOGD("Found %d plmn records", plmn_entries); - for(i=0 ; i < plmn_entries ; i++) { - if(plmn_list[i].mcc == mcc && plmn_list[i].mnc == mnc) { + for (i=0 ; i < plmn_entries ; i++) { + if (plmn_list[i].mcc == mcc && plmn_list[i].mnc == mnc) { asprintf(&response[0], "%s", plmn_list[i].operator_short); asprintf(&response[1], "%s", plmn_list[i].operator_long); return; @@ -326,7 +326,7 @@ void ril_request_operator(RIL_Token t) size_t i; // IPC_NET_REGISTRATION_STATE_ROAMING is the biggest valid value - if(ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_NONE || + if (ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_NONE || ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_SEARCHING || ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_UNKNOWN || ril_data.state.netinfo.reg_state > IPC_NET_REGISTRATION_STATE_ROAMING) { @@ -336,7 +336,7 @@ void ril_request_operator(RIL_Token t) return; } - if(ril_data.tokens.operator == RIL_TOKEN_DATA_WAITING) { + if (ril_data.tokens.operator == RIL_TOKEN_DATA_WAITING) { LOGD("Got RILJ request for UNSOL data"); /* Send back the data we got UNSOL */ @@ -344,13 +344,13 @@ void ril_request_operator(RIL_Token t) ril_request_complete(t, RIL_E_SUCCESS, response, sizeof(response)); - for(i = 0; i < sizeof(response) / sizeof(char *) ; i++) { - if(response[i] != NULL) + for (i = 0; i < sizeof(response) / sizeof(char *) ; i++) { + if (response[i] != NULL) free(response[i]); } ril_data.tokens.operator = (RIL_Token) 0x00; - } else if(ril_data.tokens.operator == (RIL_Token) 0x00) { + } else if (ril_data.tokens.operator == (RIL_Token) 0x00) { LOGD("Got RILJ request for SOL data"); /* Request data to the modem */ ril_data.tokens.operator = t; @@ -364,8 +364,8 @@ void ril_request_operator(RIL_Token t) ril_request_complete(t, RIL_E_SUCCESS, response, sizeof(response)); - for(i = 0; i < sizeof(response) / sizeof(char *) ; i++) { - if(response[i] != NULL) + for (i = 0; i < sizeof(response) / sizeof(char *) ; i++) { + if (response[i] != NULL) free(response[i]); } } @@ -395,7 +395,7 @@ void ipc_net_current_plmn(struct ipc_message_info *message) LOGD("Got UNSOL Operator message"); // IPC_NET_REGISTRATION_STATE_ROAMING is the biggest valid value - if(ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_NONE || + if (ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_NONE || ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_SEARCHING || ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_UNKNOWN || ril_data.state.netinfo.reg_state > IPC_NET_REGISTRATION_STATE_ROAMING) { @@ -404,7 +404,7 @@ void ipc_net_current_plmn(struct ipc_message_info *message) return; } else { - if(ril_data.tokens.operator != (RIL_Token) 0x00 && ril_data.tokens.operator != RIL_TOKEN_DATA_WAITING) { + if (ril_data.tokens.operator != (RIL_Token) 0x00 && ril_data.tokens.operator != RIL_TOKEN_DATA_WAITING) { LOGE("Another Operator Req is in progress, skipping"); return; } @@ -412,7 +412,7 @@ void ipc_net_current_plmn(struct ipc_message_info *message) memcpy(&(ril_data.state.plmndata), plmndata, sizeof(struct ipc_net_current_plmn_response)); /* we already told RILJ to get the new data but it wasn't done yet */ - if(ril_tokens_net_get_data_waiting() && ril_data.tokens.operator == RIL_TOKEN_DATA_WAITING) { + if (ril_tokens_net_get_data_waiting() && ril_data.tokens.operator == RIL_TOKEN_DATA_WAITING) { LOGD("Updating Operator data in background"); } else { ril_tokens_net_set_data_waiting(); @@ -428,7 +428,7 @@ void ipc_net_current_plmn(struct ipc_message_info *message) LOGD("Got SOL Operator message"); // IPC_NET_REGISTRATION_STATE_ROAMING is the biggest valid value - if(ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_NONE || + if (ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_NONE || ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_SEARCHING || ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_UNKNOWN || ril_data.state.netinfo.reg_state > IPC_NET_REGISTRATION_STATE_ROAMING) { @@ -437,11 +437,11 @@ void ipc_net_current_plmn(struct ipc_message_info *message) ril_request_complete(t, RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW, NULL, 0); - if(ril_data.tokens.operator != RIL_TOKEN_DATA_WAITING) + if (ril_data.tokens.operator != RIL_TOKEN_DATA_WAITING) ril_data.tokens.operator = (RIL_Token) 0x00; return; } else { - if(ril_data.tokens.operator != t) + if (ril_data.tokens.operator != t) LOGE("Operator tokens mismatch"); /* Better keeping it up to date */ @@ -451,12 +451,12 @@ void ipc_net_current_plmn(struct ipc_message_info *message) ril_request_complete(t, RIL_E_SUCCESS, response, sizeof(response)); - for(i = 0; i < sizeof(response) / sizeof(char *) ; i++) { - if(response[i] != NULL) + for (i = 0; i < sizeof(response) / sizeof(char *) ; i++) { + if (response[i] != NULL) free(response[i]); } - if(ril_data.tokens.operator != RIL_TOKEN_DATA_WAITING) + if (ril_data.tokens.operator != RIL_TOKEN_DATA_WAITING) ril_data.tokens.operator = (RIL_Token) 0x00; } break; @@ -486,7 +486,7 @@ void ril_request_registration_state(RIL_Token t) char *response[4]; int i; - if(ril_data.tokens.registration_state == RIL_TOKEN_DATA_WAITING) { + if (ril_data.tokens.registration_state == RIL_TOKEN_DATA_WAITING) { LOGD("Got RILJ request for UNSOL data"); /* Send back the data we got UNSOL */ @@ -494,13 +494,13 @@ void ril_request_registration_state(RIL_Token t) ril_request_complete(t, RIL_E_SUCCESS, response, sizeof(response)); - for(i = 0; i < (int) (sizeof(response) / sizeof(char *)) ; i++) { - if(response[i] != NULL) + for (i = 0; i < (int) (sizeof(response) / sizeof(char *)) ; i++) { + if (response[i] != NULL) free(response[i]); } ril_data.tokens.registration_state = (RIL_Token) 0x00; - } else if(ril_data.tokens.registration_state == (RIL_Token) 0x00) { + } else if (ril_data.tokens.registration_state == (RIL_Token) 0x00) { LOGD("Got RILJ request for SOL data"); /* Request data to the modem */ ril_data.tokens.registration_state = t; @@ -515,8 +515,8 @@ void ril_request_registration_state(RIL_Token t) ril_request_complete(t, RIL_E_SUCCESS, response, sizeof(response)); - for(i = 0; i < (int) (sizeof(response) / sizeof(char *)) ; i++) { - if(response[i] != NULL) + for (i = 0; i < (int) (sizeof(response) / sizeof(char *)) ; i++) { + if (response[i] != NULL) free(response[i]); } } @@ -542,7 +542,7 @@ void ril_request_gprs_registration_state(RIL_Token t) char *response[4]; size_t i; - if(ril_data.tokens.gprs_registration_state == RIL_TOKEN_DATA_WAITING) { + if (ril_data.tokens.gprs_registration_state == RIL_TOKEN_DATA_WAITING) { LOGD("Got RILJ request for UNSOL data"); /* Send back the data we got UNSOL */ @@ -550,13 +550,13 @@ void ril_request_gprs_registration_state(RIL_Token t) ril_request_complete(t, RIL_E_SUCCESS, response, sizeof(response)); - for(i = 0; i < sizeof(response) / sizeof(char *) ; i++) { - if(response[i] != NULL) + for (i = 0; i < sizeof(response) / sizeof(char *) ; i++) { + if (response[i] != NULL) free(response[i]); } ril_data.tokens.gprs_registration_state = (RIL_Token) 0x00; - } else if(ril_data.tokens.gprs_registration_state == (RIL_Token) 0x00) { + } else if (ril_data.tokens.gprs_registration_state == (RIL_Token) 0x00) { LOGD("Got RILJ request for SOL data"); /* Request data to the modem */ @@ -572,8 +572,8 @@ void ril_request_gprs_registration_state(RIL_Token t) ril_request_complete(t, RIL_E_SUCCESS, response, sizeof(response)); - for(i = 0; i < sizeof(response) / sizeof(char *) ; i++) { - if(response[i] != NULL) + for (i = 0; i < sizeof(response) / sizeof(char *) ; i++) { + if (response[i] != NULL) free(response[i]); } } @@ -590,7 +590,7 @@ void ipc_net_regist_unsol(struct ipc_message_info *message) switch(netinfo->domain) { case IPC_NET_SERVICE_DOMAIN_GSM: - if(ril_data.tokens.registration_state != (RIL_Token) 0 && ril_data.tokens.registration_state != RIL_TOKEN_DATA_WAITING) { + if (ril_data.tokens.registration_state != (RIL_Token) 0 && ril_data.tokens.registration_state != RIL_TOKEN_DATA_WAITING) { LOGE("Another NetRegist Req is in progress, skipping"); return; } @@ -598,7 +598,7 @@ void ipc_net_regist_unsol(struct ipc_message_info *message) memcpy(&(ril_data.state.netinfo), netinfo, sizeof(struct ipc_net_regist_response)); /* we already told RILJ to get the new data but it wasn't done yet */ - if(ril_tokens_net_get_data_waiting() && ril_data.tokens.registration_state == RIL_TOKEN_DATA_WAITING) { + if (ril_tokens_net_get_data_waiting() && ril_data.tokens.registration_state == RIL_TOKEN_DATA_WAITING) { LOGD("Updating NetRegist data in background"); } else { ril_tokens_net_set_data_waiting(); @@ -611,7 +611,7 @@ void ipc_net_regist_unsol(struct ipc_message_info *message) break; case IPC_NET_SERVICE_DOMAIN_GPRS: - if(ril_data.tokens.gprs_registration_state != (RIL_Token) 0 && ril_data.tokens.gprs_registration_state != RIL_TOKEN_DATA_WAITING) { + if (ril_data.tokens.gprs_registration_state != (RIL_Token) 0 && ril_data.tokens.gprs_registration_state != RIL_TOKEN_DATA_WAITING) { LOGE("Another GPRS NetRegist Req is in progress, skipping"); return; } @@ -619,7 +619,7 @@ void ipc_net_regist_unsol(struct ipc_message_info *message) memcpy(&(ril_data.state.gprs_netinfo), netinfo, sizeof(struct ipc_net_regist_response)); /* we already told RILJ to get the new data but it wasn't done yet */ - if(ril_tokens_net_get_data_waiting() && ril_data.tokens.gprs_registration_state == RIL_TOKEN_DATA_WAITING) { + if (ril_tokens_net_get_data_waiting() && ril_data.tokens.gprs_registration_state == RIL_TOKEN_DATA_WAITING) { LOGD("Updating GPRSNetRegist data in background"); } else { ril_tokens_net_set_data_waiting(); @@ -650,7 +650,7 @@ void ipc_net_regist_sol(struct ipc_message_info *message) switch(netinfo->domain) { case IPC_NET_SERVICE_DOMAIN_GSM: - if(ril_data.tokens.registration_state != t) + if (ril_data.tokens.registration_state != t) LOGE("Registration state tokens mismatch"); /* Better keeping it up to date */ @@ -660,16 +660,16 @@ void ipc_net_regist_sol(struct ipc_message_info *message) ril_request_complete(t, RIL_E_SUCCESS, response, sizeof(response)); - for(i = 0; i < sizeof(response) / sizeof(char *) ; i++) { - if(response[i] != NULL) + for (i = 0; i < sizeof(response) / sizeof(char *) ; i++) { + if (response[i] != NULL) free(response[i]); } - if(ril_data.tokens.registration_state != RIL_TOKEN_DATA_WAITING) + if (ril_data.tokens.registration_state != RIL_TOKEN_DATA_WAITING) ril_data.tokens.registration_state = (RIL_Token) 0x00; break; case IPC_NET_SERVICE_DOMAIN_GPRS: - if(ril_data.tokens.gprs_registration_state != t) + if (ril_data.tokens.gprs_registration_state != t) LOGE("GPRS registration state tokens mismatch"); /* Better keeping it up to date */ @@ -679,11 +679,11 @@ void ipc_net_regist_sol(struct ipc_message_info *message) ril_request_complete(t, RIL_E_SUCCESS, response, sizeof(response)); - for(i = 0; i < sizeof(response) / sizeof(char *) ; i++) { - if(response[i] != NULL) + for (i = 0; i < sizeof(response) / sizeof(char *) ; i++) { + if (response[i] != NULL) free(response[i]); } - if(ril_data.tokens.registration_state != RIL_TOKEN_DATA_WAITING) + if (ril_data.tokens.registration_state != RIL_TOKEN_DATA_WAITING) ril_data.tokens.gprs_registration_state = (RIL_Token) 0x00; break; default: @@ -701,7 +701,7 @@ void ipc_net_regist_sol(struct ipc_message_info *message) void ipc_net_regist(struct ipc_message_info *message) { /* Don't consider this if modem isn't in normal power mode. */ - if(ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL) + if (ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL) return; switch(message->type) { @@ -749,9 +749,9 @@ void ipc_net_plmn_list(struct ipc_message_info *info) LOGD("Listed %d PLMNs\n", entries_info->num); - for(i = 0; i < entries_info->num; i++) { + for (i = 0; i < entries_info->num; i++) { /* Assumed type for 'emergency only' PLMNs */ - if(entries[i].type == 0x01) + if (entries[i].type == 0x01) continue; ril_plmn_string(entries[i].plmn, resp_ptr); @@ -836,8 +836,8 @@ void ipc_net_plmn_sel_complete(struct ipc_message_info *info) int rc; rc = ipc_gen_phone_res_check(phone_res); - if(rc < 0) { - if((phone_res->code & 0x00ff) == 0x6f) { + if (rc < 0) { + if ((phone_res->code & 0x00ff) == 0x6f) { LOGE("Not authorized to register to this network!"); ril_request_complete(ril_request_get_token(info->aseq), RIL_E_ILLEGAL_SIM_OR_ME, NULL, 0); } else { @@ -55,7 +55,7 @@ void ipc_pwr_phone_state(struct ipc_message_info *info) case IPC_PWR_R(IPC_PWR_PHONE_STATE_LPM): LOGD("Got power to LPM"); - if(ril_data.state.power_state == IPC_PWR_PHONE_STATE_NORMAL && + if (ril_data.state.power_state == IPC_PWR_PHONE_STATE_NORMAL && ril_data.tokens.radio_power != (RIL_Token) 0x00) { ril_request_complete(ril_data.tokens.radio_power, RIL_E_SUCCESS, NULL, 0); ril_data.tokens.radio_power = (RIL_Token) 0x00; @@ -68,7 +68,7 @@ void ipc_pwr_phone_state(struct ipc_message_info *info) case IPC_PWR_R(IPC_PWR_PHONE_STATE_NORMAL): LOGD("Got power to NORMAL"); - if(ril_data.state.power_state == IPC_PWR_PHONE_STATE_LPM && + if (ril_data.state.power_state == IPC_PWR_PHONE_STATE_LPM && ril_data.tokens.radio_power != (RIL_Token) 0x00) { ril_request_complete(ril_data.tokens.radio_power, RIL_E_SUCCESS, NULL, 0); ril_data.tokens.radio_power = (RIL_Token) 0x00; @@ -97,7 +97,7 @@ void ril_request_radio_power(RIL_Token t, void *data, size_t datalen) LOGD("requested power_state is %d", power_state); - if(power_state > 0) { + if (power_state > 0) { LOGD("Request power to NORMAL"); power_data = IPC_PWR_PHONE_STATE_NORMAL; @@ -32,12 +32,12 @@ void ipc_rfs_nv_read_item(struct ipc_message_info *info) void *rfs_data; int rc; - if(ril_data.ipc_rfs_client == NULL) + if (ril_data.ipc_rfs_client == NULL) return; ipc_client = ((struct ipc_client_data *) ril_data.ipc_rfs_client->data)->ipc_client; - if(rfs_io == NULL) { + if (rfs_io == NULL) { LOGE("Error: NULL rfs_io"); return; } @@ -70,12 +70,12 @@ void ipc_rfs_nv_write_item(struct ipc_message_info *info) void *rfs_data; int rc; - if(ril_data.ipc_rfs_client == NULL) + if (ril_data.ipc_rfs_client == NULL) return; ipc_client = ((struct ipc_client_data *) ril_data.ipc_rfs_client->data)->ipc_client; - if(rfs_io == NULL) { + if (rfs_io == NULL) { LOGE("Error: NULL rfs_io"); return; } diff --git a/samsung-ril.c b/samsung-ril.c index f84b9f0..8abb9a0 100644 --- a/samsung-ril.c +++ b/samsung-ril.c @@ -53,7 +53,7 @@ int ril_request_id_set(int id) { id %= 0xff; - while(ril_data.request_id < id) { + while (ril_data.request_id < id) { ril_data.request_id++; ril_data.request_id %= 0xff; } @@ -68,7 +68,7 @@ int ril_request_register(RIL_Token t, int id) struct list_head *list; request = calloc(1, sizeof(struct ril_request_info)); - if(request == NULL) + if (request == NULL) return -1; request->token = t; @@ -76,12 +76,12 @@ int ril_request_register(RIL_Token t, int id) request->canceled = 0; list_end = ril_data.requests; - while(list_end != NULL && list_end->next != NULL) + while (list_end != NULL && list_end->next != NULL) list_end = list_end->next; list = list_head_alloc((void *) request, list_end, NULL); - if(ril_data.requests == NULL) + if (ril_data.requests == NULL) ril_data.requests = list; return 0; @@ -91,16 +91,16 @@ void ril_request_unregister(struct ril_request_info *request) { struct list_head *list; - if(request == NULL) + if (request == NULL) return; list = ril_data.requests; - while(list != NULL) { - if(list->data == (void *) request) { + while (list != NULL) { + if (list->data == (void *) request) { memset(request, 0, sizeof(struct ril_request_info)); free(request); - if(list == ril_data.requests) + if (list == ril_data.requests) ril_data.requests = list->next; list_head_free(list); @@ -118,12 +118,12 @@ struct ril_request_info *ril_request_info_find_id(int id) struct list_head *list; list = ril_data.requests; - while(list != NULL) { + while (list != NULL) { request = (struct ril_request_info *) list->data; - if(request == NULL) + if (request == NULL) goto list_continue; - if(request->id == id) + if (request->id == id) return request; list_continue: @@ -139,12 +139,12 @@ struct ril_request_info *ril_request_info_find_token(RIL_Token t) struct list_head *list; list = ril_data.requests; - while(list != NULL) { + while (list != NULL) { request = (struct ril_request_info *) list->data; - if(request == NULL) + if (request == NULL) goto list_continue; - if(request->token == t) + if (request->token == t) return request; list_continue: @@ -159,7 +159,7 @@ int ril_request_set_canceled(RIL_Token t, int canceled) struct ril_request_info *request; request = ril_request_info_find_token(t); - if(request == NULL) + if (request == NULL) return -1; request->canceled = canceled ? 1 : 0; @@ -172,7 +172,7 @@ int ril_request_get_canceled(RIL_Token t) struct ril_request_info *request; request = ril_request_info_find_token(t); - if(request == NULL) + if (request == NULL) return -1; return request->canceled; @@ -183,7 +183,7 @@ RIL_Token ril_request_get_token(int id) struct ril_request_info *request; request = ril_request_info_find_id(id); - if(request == NULL) + if (request == NULL) return (RIL_Token) 0x00; return request->token; @@ -195,12 +195,12 @@ int ril_request_get_id(RIL_Token t) int id, rc; request = ril_request_info_find_token(t); - if(request != NULL) + if (request != NULL) return request->id; id = ril_request_id_get(); rc = ril_request_register(t, id); - if(rc < 0) + if (rc < 0) return -1; return id; @@ -212,13 +212,13 @@ void ril_request_complete(RIL_Token t, RIL_Errno e, void *data, size_t length) int canceled = 0; request = ril_request_info_find_token(t); - if(request == NULL) + if (request == NULL) goto complete; canceled = ril_request_get_canceled(t); ril_request_unregister(request); - if(canceled) + if (canceled) return; complete: @@ -243,16 +243,16 @@ void ril_tokens_check(void) { RIL_Token t; - if(ril_data.tokens.baseband_version != 0) { - if(ril_data.state.radio_state != RADIO_STATE_OFF) { + if (ril_data.tokens.baseband_version != 0) { + if (ril_data.state.radio_state != RADIO_STATE_OFF) { t = ril_data.tokens.baseband_version; ril_data.tokens.baseband_version = 0; ril_request_baseband_version(t); } } - if(ril_data.tokens.get_imei != 0 && ril_data.tokens.get_imeisv != 0) { - if(ril_data.state.radio_state != RADIO_STATE_OFF) { + if (ril_data.tokens.get_imei != 0 && ril_data.tokens.get_imeisv != 0) { + if (ril_data.state.radio_state != RADIO_STATE_OFF) { t = ril_data.tokens.get_imei; ril_data.tokens.get_imei = 0; ril_request_get_imei(t); @@ -266,7 +266,7 @@ void ril_tokens_check(void) void ipc_fmt_dispatch(struct ipc_message_info *info) { - if(info == NULL) + if (info == NULL) return; RIL_LOCK(); @@ -396,7 +396,7 @@ void ipc_fmt_dispatch(struct ipc_message_info *info) void ipc_rfs_dispatch(struct ipc_message_info *info) { - if(info == NULL) + if (info == NULL) return; RIL_LOCK(); @@ -418,7 +418,7 @@ void ipc_rfs_dispatch(struct ipc_message_info *info) void srs_dispatch(struct srs_message *message) { - if(message == NULL) + if (message == NULL) return; RIL_LOCK(); @@ -674,7 +674,7 @@ const RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env, int argc, char **a struct ril_client *srs_client; int rc; - if(env == NULL) + if (env == NULL) return NULL; ril_data_init(); @@ -687,14 +687,14 @@ const RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env, int argc, char **a ipc_fmt_client = ril_client_new(&ipc_fmt_client_funcs); rc = ril_client_create(ipc_fmt_client); - if(rc < 0) { + if (rc < 0) { LOGE("IPC FMT client creation failed."); goto ipc_rfs; } rc = ril_client_thread_start(ipc_fmt_client); - if(rc < 0) { + if (rc < 0) { LOGE("IPC FMT thread creation failed."); goto ipc_rfs; } @@ -708,14 +708,14 @@ ipc_rfs: ipc_rfs_client = ril_client_new(&ipc_rfs_client_funcs); rc = ril_client_create(ipc_rfs_client); - if(rc < 0) { + if (rc < 0) { LOGE("IPC RFS client creation failed."); goto srs; } rc = ril_client_thread_start(ipc_rfs_client); - if(rc < 0) { + if (rc < 0) { LOGE("IPC RFS thread creation failed."); goto srs; } @@ -729,14 +729,14 @@ srs: srs_client = ril_client_new(&srs_client_funcs); rc = ril_client_create(srs_client); - if(rc < 0) { + if (rc < 0) { LOGE("SRS client creation failed."); goto end; } rc = ril_client_thread_start(srs_client); - if(rc < 0) { + if (rc < 0) { LOGE("SRS thread creation failed."); goto end; } @@ -67,7 +67,7 @@ void ipc_sat_proactive_cmd_sol(struct ipc_message_info *info) sw1 = ((unsigned char*)info->data)[0]; sw2 = ((unsigned char*)info->data)[1]; - if(sw1 == 0x90 && sw2 == 0x00) { + if (sw1 == 0x90 && sw2 == 0x00) { ril_request_unsolicited(RIL_UNSOL_STK_SESSION_END, NULL, 0); } else { LOGE("%s: unhandled response sw1=%02x sw2=%02x", __FUNCTION__, sw1, sw2); @@ -79,9 +79,9 @@ void ipc_sat_proactive_cmd_sol(struct ipc_message_info *info) */ void ipc_sat_proactive_cmd(struct ipc_message_info *info) { - if(info->type == IPC_TYPE_INDI) { + if (info->type == IPC_TYPE_INDI) { ipc_sat_proactive_cmd_unsol(info); - } else if(info->type == IPC_TYPE_RESP) { + } else if (info->type == IPC_TYPE_RESP) { ipc_sat_proactive_cmd_sol(info); } else { LOGE("%s: unhandled proactive command response type %d",__func__, info->type); @@ -100,7 +100,7 @@ void ril_request_stk_send_terminal_response(RIL_Token t, void *data, size_t data unsigned char buf[264]; int len = (strlen(data) / 2); - if(len > 255) { + if (len > 255) { LOGE("%s: data exceeds maximum length", __FUNCTION__); ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); } @@ -127,7 +127,7 @@ void ril_request_stk_send_envelope_command(RIL_Token t, void *data, size_t datal unsigned char buf[264]; int len = (strlen(data) / 2); - if(len > 255) { + if (len > 255) { LOGE("%s: data exceeds maximum length", __FUNCTION__); ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); } @@ -82,7 +82,7 @@ void ril_state_update(ril_sim_state sim_state) RIL_RadioState radio_state; /* If power mode isn't at least normal, don't update RIL state */ - if(ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL) + if (ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL) return; ril_data.state.sim_state = sim_state; @@ -167,13 +167,13 @@ void ipc2ril_card_status(struct ipc_sec_sim_status_response *pin_status, RIL_Car app_status_array_length = sizeof(app_status_array) / sizeof(RIL_AppStatus); - if(app_status_array_length > RIL_CARD_MAX_APPS) + if (app_status_array_length > RIL_CARD_MAX_APPS) app_status_array_length = RIL_CARD_MAX_APPS; sim_state = ipc2ril_sim_state(pin_status); /* Card is assumed to be present if not explicitly absent */ - if(sim_state == SIM_STATE_ABSENT) { + if (sim_state == SIM_STATE_ABSENT) { card_status->card_state = RIL_CARDSTATE_ABSENT; } else { card_status->card_state = RIL_CARDSTATE_PRESENT; @@ -186,7 +186,7 @@ void ipc2ril_card_status(struct ipc_sec_sim_status_response *pin_status, RIL_Car for (i = 0 ; i < app_status_array_length ; i++) { memcpy((void *) &(card_status->applications[i]), (void *) &(app_status_array[i]), sizeof(RIL_AppStatus)); } - for(i = app_status_array_length ; i < RIL_CARD_MAX_APPS ; i++) { + for (i = app_status_array_length ; i < RIL_CARD_MAX_APPS ; i++) { memset((void *) &(card_status->applications[i]), 0, sizeof(RIL_AppStatus)); } @@ -230,12 +230,12 @@ void ipc_sec_sim_status(struct ipc_message_info *info) switch(info->type) { case IPC_TYPE_NOTI: // Don't consider this if modem isn't in normal power mode - if(ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL) + if (ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL) return; LOGD("Got UNSOL PIN status message"); - if(ril_data.tokens.pin_status != (RIL_Token) 0x00 && ril_data.tokens.pin_status != RIL_TOKEN_DATA_WAITING) { + if (ril_data.tokens.pin_status != (RIL_Token) 0x00 && ril_data.tokens.pin_status != RIL_TOKEN_DATA_WAITING) { LOGE("Another PIN status Req is in progress, skipping"); return; } @@ -251,7 +251,7 @@ void ipc_sec_sim_status(struct ipc_message_info *info) case IPC_TYPE_RESP: LOGD("Got SOL PIN status message"); - if(ril_data.tokens.pin_status != t) + if (ril_data.tokens.pin_status != t) LOGE("PIN status tokens mismatch"); sim_state = ipc2ril_sim_state(pin_status); @@ -263,7 +263,7 @@ void ipc_sec_sim_status(struct ipc_message_info *info) ipc2ril_card_status(pin_status, &card_status); ril_request_complete(t, RIL_E_SUCCESS, &card_status, sizeof(card_status)); - if(ril_data.tokens.pin_status != RIL_TOKEN_DATA_WAITING) + if (ril_data.tokens.pin_status != RIL_TOKEN_DATA_WAITING) ril_data.tokens.pin_status = (RIL_Token) 0x00; break; default: @@ -287,7 +287,7 @@ void ril_request_get_sim_status(RIL_Token t) RIL_CardStatus card_status; #endif - if(ril_data.tokens.pin_status == RIL_TOKEN_DATA_WAITING) { + if (ril_data.tokens.pin_status == RIL_TOKEN_DATA_WAITING) { LOGD("Got RILJ request for UNSOL data"); hex_dump(&(ril_data.state.sim_pin_status), sizeof(struct ipc_sec_sim_status_response)); pin_status = &(ril_data.state.sim_pin_status); @@ -297,7 +297,7 @@ void ril_request_get_sim_status(RIL_Token t) ril_request_complete(t, RIL_E_SUCCESS, &card_status, sizeof(card_status)); ril_data.tokens.pin_status = (RIL_Token) 0x00; - } else if(ril_data.tokens.pin_status == (RIL_Token) 0x00) { + } else if (ril_data.tokens.pin_status == (RIL_Token) 0x00) { LOGD("Got RILJ request for SOL data"); /* Request data to the modem */ @@ -338,7 +338,7 @@ void ril_request_sim_io(RIL_Token t, void *data, int length) void *rsim_access_data = NULL; int rsim_access_length = 0; - if(data == NULL || length < sizeof(*sim_io)) + if (data == NULL || length < sizeof(*sim_io)) return; #if RIL_VERSION >= 6 @@ -349,7 +349,7 @@ void ril_request_sim_io(RIL_Token t, void *data, int length) rsim_access_length += sizeof(struct ipc_sec_rsim_access_get); - if(sim_io->data != NULL) { + if (sim_io->data != NULL) { sim_io_data_length = (2 * strlen(sim_io->data)); rsim_access_length += sim_io_data_length; } @@ -363,7 +363,7 @@ void ril_request_sim_io(RIL_Token t, void *data, int length) rsim_access->p2 = sim_io->p2; rsim_access->p3 = sim_io->p3; - if(sim_io->data != NULL && sim_io_data_length > 0) + if (sim_io->data != NULL && sim_io_data_length > 0) hex2bin(sim_io->data, sim_io_data_length, (void *) ((int) rsim_access_data + sizeof(struct ipc_sec_rsim_access_get))); ipc_fmt_send(IPC_SEC_RSIM_ACCESS, IPC_TYPE_GET, rsim_access_data, rsim_access_length, ril_request_get_id(t)); @@ -388,7 +388,7 @@ void ipc_sec_rsim_access(struct ipc_message_info *info) void *rsim_access_data = NULL; char *sim_response = NULL; - if(info == NULL || info->data == NULL || info->length < sizeof(struct ipc_sec_rsim_access_response)) + if (info == NULL || info->data == NULL || info->length < sizeof(struct ipc_sec_rsim_access_response)) return; memset(&sim_io_response, 0, sizeof(sim_io_response)); @@ -399,7 +399,7 @@ void ipc_sec_rsim_access(struct ipc_message_info *info) sim_io_response.sw1 = rsim_access->sw1; sim_io_response.sw2 = rsim_access->sw2; - if(rsim_access->len > 0) { + if (rsim_access->len > 0) { sim_response = (char *) malloc(rsim_access->len * 2 + 1); bin2hex(rsim_access_data, rsim_access->len, sim_response); sim_io_response.simResponse = sim_response; @@ -427,11 +427,11 @@ void ipc_sec_sim_status_complete(struct ipc_message_info *info) int attempts = -1; rc = ipc_gen_phone_res_check(phone_res); - if(rc < 0) { - if((phone_res->code & 0x00ff) == 0x10) { + if (rc < 0) { + if ((phone_res->code & 0x00ff) == 0x10) { LOGE("Wrong password!"); ril_request_complete(ril_request_get_token(info->aseq), RIL_E_PASSWORD_INCORRECT, &attempts, sizeof(attempts)); - } else if((phone_res->code & 0x00ff) == 0x0c) { + } else if ((phone_res->code & 0x00ff) == 0x0c) { LOGE("Wrong password and no attempts left!"); attempts = 0; @@ -461,7 +461,7 @@ void ipc_sec_lock_info(struct ipc_message_info *info) int attempts; struct ipc_sec_lock_info_response *lock_info = (struct ipc_sec_lock_info_response *) info->data; - if(lock_info->type == IPC_SEC_PIN_TYPE_PIN1) { + if (lock_info->type == IPC_SEC_PIN_TYPE_PIN1) { attempts = lock_info->attempts; LOGD("%s: PIN1 %d attempts left", __FUNCTION__, attempts); } else { @@ -486,7 +486,7 @@ void ril_request_enter_sim_pin(RIL_Token t, void *data, size_t datalen) unsigned char buf[9]; /* 1. Send PIN */ - if(strlen(data) > 16) { + if (strlen(data) > 16) { LOGE("%s: pin exceeds maximum length", __FUNCTION__); ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); } @@ -577,17 +577,17 @@ void ril_request_query_facility_lock(RIL_Token t, void *data, size_t datalen) char *facility = ((char **) data)[0]; - if(!strcmp(facility, "SC")) { + if (!strcmp(facility, "SC")) { lock_request.facility = IPC_SEC_FACILITY_TYPE_SC; - } else if(!strcmp(facility, "FD")) { + } else if (!strcmp(facility, "FD")) { lock_request.facility = IPC_SEC_FACILITY_TYPE_FD; - } else if(!strcmp(facility, "PN")) { + } else if (!strcmp(facility, "PN")) { lock_request.facility = IPC_SEC_FACILITY_TYPE_PN; - } else if(!strcmp(facility, "PU")) { + } else if (!strcmp(facility, "PU")) { lock_request.facility = IPC_SEC_FACILITY_TYPE_PU; - } else if(!strcmp(facility, "PP")) { + } else if (!strcmp(facility, "PP")) { lock_request.facility = IPC_SEC_FACILITY_TYPE_PP; - } else if(!strcmp(facility, "PC")) { + } else if (!strcmp(facility, "PC")) { lock_request.facility = IPC_SEC_FACILITY_TYPE_PC; } else { LOGE("%s: unsupported facility: %s", __FUNCTION__, facility); @@ -618,17 +618,17 @@ void ril_request_set_facility_lock(RIL_Token t, void *data, size_t datalen) memset(&lock_request, 0, sizeof(lock_request)); - if(!strcmp(facility, "SC")) { + if (!strcmp(facility, "SC")) { lock_request.type = IPC_SEC_SIM_STATUS_LOCK_SC; - } else if(!strcmp(facility, "FD")) { + } else if (!strcmp(facility, "FD")) { lock_request.type = IPC_SEC_SIM_STATUS_LOCK_FD; - } else if(!strcmp(facility, "PN")) { + } else if (!strcmp(facility, "PN")) { lock_request.type = IPC_SEC_SIM_STATUS_LOCK_PN; - } else if(!strcmp(facility, "PU")) { + } else if (!strcmp(facility, "PU")) { lock_request.type = IPC_SEC_SIM_STATUS_LOCK_PU; - } else if(!strcmp(facility, "PP")) { + } else if (!strcmp(facility, "PP")) { lock_request.type = IPC_SEC_SIM_STATUS_LOCK_PP; - } else if(!strcmp(facility, "PC")) { + } else if (!strcmp(facility, "PC")) { lock_request.type = IPC_SEC_SIM_STATUS_LOCK_PC; } else { LOGE("%s: unsupported facility: %s", __FUNCTION__, facility); @@ -31,7 +31,7 @@ unsigned short ril2ipc_sms_ack_error(int success, int failcause) { - if(success) { + if (success) { return IPC_SMS_ACK_NO_ERROR; } else { switch(failcause) { @@ -69,7 +69,7 @@ int ril_request_send_sms_register(char *pdu, int pdu_length, unsigned char *smsc struct list_head *list; send_sms = calloc(1, sizeof(struct ril_request_send_sms_info)); - if(send_sms == NULL) + if (send_sms == NULL) return -1; send_sms->pdu = pdu; @@ -79,12 +79,12 @@ int ril_request_send_sms_register(char *pdu, int pdu_length, unsigned char *smsc send_sms->token = t; list_end = ril_data.outgoing_sms; - while(list_end != NULL && list_end->next != NULL) + while (list_end != NULL && list_end->next != NULL) list_end = list_end->next; list = list_head_alloc((void *) send_sms, list_end, NULL); - if(ril_data.outgoing_sms == NULL) + if (ril_data.outgoing_sms == NULL) ril_data.outgoing_sms = list; return 0; @@ -94,16 +94,16 @@ void ril_request_send_sms_unregister(struct ril_request_send_sms_info *send_sms) { struct list_head *list; - if(send_sms == NULL) + if (send_sms == NULL) return; list = ril_data.outgoing_sms; - while(list != NULL) { - if(list->data == (void *) send_sms) { + while (list != NULL) { + if (list->data == (void *) send_sms) { memset(send_sms, 0, sizeof(struct ril_request_send_sms_info)); free(send_sms); - if(list == ril_data.outgoing_sms) + if (list == ril_data.outgoing_sms) ril_data.outgoing_sms = list->next; list_head_free(list); @@ -121,9 +121,9 @@ struct ril_request_send_sms_info *ril_request_send_sms_info_find(void) struct list_head *list; list = ril_data.outgoing_sms; - while(list != NULL) { + while (list != NULL) { send_sms = (struct ril_request_send_sms_info *) list->data; - if(send_sms == NULL) + if (send_sms == NULL) goto list_continue; return send_sms; @@ -141,12 +141,12 @@ struct ril_request_send_sms_info *ril_request_send_sms_info_find_token(RIL_Token struct list_head *list; list = ril_data.outgoing_sms; - while(list != NULL) { + while (list != NULL) { send_sms = (struct ril_request_send_sms_info *) list->data; - if(send_sms == NULL) + if (send_sms == NULL) goto list_continue; - if(send_sms->token == t) + if (send_sms->token == t) return send_sms; list_continue: @@ -158,13 +158,13 @@ list_continue: void ril_request_send_sms_info_clear(struct ril_request_send_sms_info *send_sms) { - if(send_sms == NULL) + if (send_sms == NULL) return; - if(send_sms->pdu != NULL) + if (send_sms->pdu != NULL) free(send_sms->pdu); - if(send_sms->smsc != NULL) + if (send_sms->smsc != NULL) free(send_sms->smsc); } @@ -181,7 +181,7 @@ void ril_request_send_sms_next(void) ril_data.tokens.outgoing_sms = (RIL_Token) 0x00; send_sms = ril_request_send_sms_info_find(); - if(send_sms == NULL) + if (send_sms == NULL) return; t = send_sms->token; @@ -192,24 +192,24 @@ void ril_request_send_sms_next(void) ril_request_send_sms_unregister(send_sms); - if(pdu == NULL) { + if (pdu == NULL) { LOGE("SMS send request has no valid PDU"); - if(smsc != NULL) + if (smsc != NULL) free(smsc); return; } ril_data.tokens.outgoing_sms = t; - if(smsc == NULL) { + if (smsc == NULL) { // We first need to get SMS SVC before sending the message LOGD("We have no SMSC, let's ask one"); rc = ril_request_send_sms_register(pdu, pdu_length, NULL, 0, t); - if(rc < 0) { + if (rc < 0) { LOGE("Unable to add the request to the list"); ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); - if(pdu != NULL) + if (pdu != NULL) free(pdu); // Send the next SMS in the list ril_request_send_sms_next(); @@ -218,9 +218,9 @@ void ril_request_send_sms_next(void) ipc_fmt_send_get(IPC_SMS_SVC_CENTER_ADDR, ril_request_get_id(t)); } else { ril_request_send_sms_complete(t, pdu, pdu_length, smsc, smsc_length); - if(pdu != NULL) + if (pdu != NULL) free(pdu); - if(smsc != NULL) + if (smsc != NULL) free(smsc); } } @@ -244,7 +244,7 @@ void ril_request_send_sms_complete(RIL_Token t, char *pdu, int pdu_length, unsig unsigned char *p; - if(pdu == NULL || pdu_length <= 0 || smsc == NULL || smsc_length <= 0) { + if (pdu == NULL || pdu_length <= 0 || smsc == NULL || smsc_length <= 0) { LOGE("Provided PDU or SMSC is invalid! Aborting"); ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); @@ -253,7 +253,7 @@ void ril_request_send_sms_complete(RIL_Token t, char *pdu, int pdu_length, unsig return; } - if((pdu_length / 2 + smsc_length) > 0xfe) { + if ((pdu_length / 2 + smsc_length) > 0xfe) { LOGE("PDU or SMSC too large, aborting"); ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); @@ -279,7 +279,7 @@ void ril_request_send_sms_complete(RIL_Token t, char *pdu, int pdu_length, unsig int pdu_tp_da_index = 2; unsigned char pdu_tp_da_len = pdu_hex[pdu_tp_da_index]; - if(pdu_tp_da_len > 0xff / 2) { + if (pdu_tp_da_len > 0xff / 2) { LOGE("PDU TP-DA Len failed (0x%x)\n", pdu_tp_da_len); goto pdu_end; } @@ -289,7 +289,7 @@ void ril_request_send_sms_complete(RIL_Token t, char *pdu, int pdu_length, unsig int pdu_tp_udh_index = pdu_tp_da_index + pdu_tp_da_len; unsigned char pdu_tp_udh_len = pdu_hex[pdu_tp_udh_index]; - if(pdu_tp_udh_len > 0xff / 2 || pdu_tp_udh_len < 5) { + if (pdu_tp_udh_len > 0xff / 2 || pdu_tp_udh_len < 5) { LOGE("PDU TP-UDH Len failed (0x%x)\n", pdu_tp_udh_len); goto pdu_end; } @@ -299,7 +299,7 @@ void ril_request_send_sms_complete(RIL_Token t, char *pdu, int pdu_length, unsig int pdu_tp_udh_num_index = pdu_tp_udh_index + 4; unsigned char pdu_tp_udh_num = pdu_hex[pdu_tp_udh_num_index]; - if(pdu_tp_udh_num > 0xf) { + if (pdu_tp_udh_num > 0xf) { LOGE("PDU TP-UDH Num failed (0x%x)\n", pdu_tp_udh_num); goto pdu_end; } @@ -307,14 +307,14 @@ void ril_request_send_sms_complete(RIL_Token t, char *pdu, int pdu_length, unsig int pdu_tp_udh_seq_index = pdu_tp_udh_index + 5; unsigned char pdu_tp_udh_seq = pdu_hex[pdu_tp_udh_seq_index]; - if(pdu_tp_udh_seq > 0xf || pdu_tp_udh_seq > pdu_tp_udh_num) { + if (pdu_tp_udh_seq > 0xf || pdu_tp_udh_seq > pdu_tp_udh_num) { LOGE("PDU TP-UDH Seq failed (0x%x)\n", pdu_tp_udh_seq); goto pdu_end; } LOGD("We are sending message %d on %d\n", pdu_tp_udh_seq, pdu_tp_udh_num); - if(pdu_tp_udh_num > 1) { + if (pdu_tp_udh_num > 1) { LOGD("We are sending a multi-part message!"); send_msg_type = IPC_SMS_MSG_MULTIPLE; } @@ -354,7 +354,7 @@ void ril_request_send_sms(RIL_Token t, void *data, size_t length) int smsc_length; int rc; - if(data == NULL || length < 2 * sizeof(char *)) + if (data == NULL || length < 2 * sizeof(char *)) return; pdu = ((char **) data)[1]; @@ -362,26 +362,26 @@ void ril_request_send_sms(RIL_Token t, void *data, size_t length) pdu_length = 0; smsc_length = 0; - if(pdu != NULL) { + if (pdu != NULL) { pdu_length = strlen(pdu) + 1; pdu = strdup(pdu); } - if(smsc != NULL) { + if (smsc != NULL) { smsc_length = strlen((char *) smsc); smsc = (unsigned char *) strdup((char *) smsc); } - if(ril_data.tokens.outgoing_sms != (RIL_Token) 0x00) { + if (ril_data.tokens.outgoing_sms != (RIL_Token) 0x00) { LOGD("Another outgoing SMS is being processed, adding to the list"); rc = ril_request_send_sms_register(pdu, pdu_length, smsc, smsc_length, t); - if(rc < 0) { + if (rc < 0) { LOGE("Unable to add the request to the list"); ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); - if(pdu != NULL) + if (pdu != NULL) free(pdu); - if(smsc != NULL) + if (smsc != NULL) free(smsc); // Send the next SMS in the list ril_request_send_sms_next(); @@ -391,16 +391,16 @@ void ril_request_send_sms(RIL_Token t, void *data, size_t length) } ril_data.tokens.outgoing_sms = t; - if(smsc == NULL) { + if (smsc == NULL) { // We first need to get SMS SVC before sending the message LOGD("We have no SMSC, let's ask one"); rc = ril_request_send_sms_register(pdu, pdu_length, NULL, 0, t); - if(rc < 0) { + if (rc < 0) { LOGE("Unable to add the request to the list"); ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); - if(pdu != NULL) + if (pdu != NULL) free(pdu); // Send the next SMS in the list ril_request_send_sms_next(); @@ -409,9 +409,9 @@ void ril_request_send_sms(RIL_Token t, void *data, size_t length) ipc_fmt_send_get(IPC_SMS_SVC_CENTER_ADDR, ril_request_get_id(t)); } else { ril_request_send_sms_complete(t, pdu, pdu_length, smsc, smsc_length); - if(pdu != NULL) + if (pdu != NULL) free(pdu); - if(smsc != NULL) + if (smsc != NULL) free(smsc); } } @@ -446,11 +446,11 @@ void ipc_sms_svc_center_addr(struct ipc_message_info *info) int smsc_length; int rc; - if(info == NULL || info->data == NULL) + if (info == NULL || info->data == NULL) return; send_sms = ril_request_send_sms_info_find_token(ril_request_get_token(info->aseq)); - if(send_sms == NULL || send_sms->pdu == NULL || send_sms->pdu_length <= 0) { + if (send_sms == NULL || send_sms->pdu == NULL || send_sms->pdu_length <= 0) { LOGE("The request wasn't queued, reporting generic error!"); ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); @@ -471,7 +471,7 @@ void ipc_sms_svc_center_addr(struct ipc_message_info *info) LOGD("Got SMSC, completing the request"); ril_request_send_sms_unregister(send_sms); ril_request_send_sms_complete(t, pdu, pdu_length, smsc, smsc_length); - if(pdu != NULL) + if (pdu != NULL) free(pdu); } @@ -480,11 +480,11 @@ void ipc_sms_send_msg_complete(struct ipc_message_info *info) struct ril_request_send_sms_info *send_sms; struct ipc_gen_phone_res *phone_res; - if(info->data == NULL || info->length < sizeof(struct ipc_gen_phone_res)) + if (info->data == NULL || info->length < sizeof(struct ipc_gen_phone_res)) return; phone_res = (struct ipc_gen_phone_res *) info->data; - if(ipc_gen_phone_res_check(phone_res) < 0) { + if (ipc_gen_phone_res_check(phone_res) < 0) { LOGE("IPC_GEN_PHONE_RES indicates error, abort request to RILJ"); ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); @@ -503,7 +503,7 @@ void ipc_sms_send_msg(struct ipc_message_info *info) RIL_SMS_Response response; RIL_Errno e; - if(info == NULL || info->data == NULL || info->length < sizeof(struct ipc_sms_send_msg_response)) + if (info == NULL || info->data == NULL || info->length < sizeof(struct ipc_sms_send_msg_response)) return; report_msg = (struct ipc_sms_send_msg_response *) info->data; @@ -533,7 +533,7 @@ int ipc_sms_incoming_msg_register(char *pdu, int length, unsigned char type, uns struct list_head *list; incoming_msg = calloc(1, sizeof(struct ipc_sms_incoming_msg_info)); - if(incoming_msg == NULL) + if (incoming_msg == NULL) return -1; incoming_msg->pdu = pdu; @@ -542,12 +542,12 @@ int ipc_sms_incoming_msg_register(char *pdu, int length, unsigned char type, uns incoming_msg->tpid = tpid; list_end = ril_data.incoming_sms; - while(list_end != NULL && list_end->next != NULL) + while (list_end != NULL && list_end->next != NULL) list_end = list_end->next; list = list_head_alloc((void *) incoming_msg, list_end, NULL); - if(ril_data.incoming_sms == NULL) + if (ril_data.incoming_sms == NULL) ril_data.incoming_sms = list; return 0; @@ -557,16 +557,16 @@ void ipc_sms_incoming_msg_unregister(struct ipc_sms_incoming_msg_info *incoming_ { struct list_head *list; - if(incoming_msg == NULL) + if (incoming_msg == NULL) return; list = ril_data.incoming_sms; - while(list != NULL) { - if(list->data == (void *) incoming_msg) { + while (list != NULL) { + if (list->data == (void *) incoming_msg) { memset(incoming_msg, 0, sizeof(struct ipc_sms_incoming_msg_info)); free(incoming_msg); - if(list == ril_data.incoming_sms) + if (list == ril_data.incoming_sms) ril_data.incoming_sms = list->next; list_head_free(list); @@ -584,9 +584,9 @@ struct ipc_sms_incoming_msg_info *ipc_sms_incoming_msg_info_find(void) struct list_head *list; list = ril_data.incoming_sms; - while(list != NULL) { + while (list != NULL) { incoming_msg = (struct ipc_sms_incoming_msg_info *) list->data; - if(incoming_msg == NULL) + if (incoming_msg == NULL) goto list_continue; return incoming_msg; @@ -605,7 +605,7 @@ void ipc_sms_incoming_msg_next(void) ril_data.state.sms_incoming_msg_tpid = 0; incoming_msg = ipc_sms_incoming_msg_info_find(); - if(incoming_msg == NULL) + if (incoming_msg == NULL) return; ipc_sms_incoming_msg_complete(incoming_msg->pdu, incoming_msg->length, incoming_msg->type, incoming_msg->tpid); @@ -621,14 +621,14 @@ void ipc_sms_incoming_msg_next(void) */ void ipc_sms_incoming_msg_complete(char *pdu, int length, unsigned char type, unsigned char tpid) { - if(pdu == NULL || length <= 0) + if (pdu == NULL || length <= 0) return; ril_data.state.sms_incoming_msg_tpid = tpid; - if(type == IPC_SMS_TYPE_POINT_TO_POINT) { + if (type == IPC_SMS_TYPE_POINT_TO_POINT) { ril_request_unsolicited(RIL_UNSOL_RESPONSE_NEW_SMS, pdu, length); - } else if(type == IPC_SMS_TYPE_STATUS_REPORT) { + } else if (type == IPC_SMS_TYPE_STATUS_REPORT) { ril_request_unsolicited(RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT, pdu, length); } else { LOGE("Unhandled message type: %x", type); @@ -645,7 +645,7 @@ void ipc_sms_incoming_msg(struct ipc_message_info *info) int length; int rc; - if(info == NULL || info->data == NULL || info->length < sizeof(struct ipc_sms_incoming_msg)) + if (info == NULL || info->data == NULL || info->length < sizeof(struct ipc_sms_incoming_msg)) return; msg = (struct ipc_sms_incoming_msg *) info->data; @@ -656,10 +656,10 @@ void ipc_sms_incoming_msg(struct ipc_message_info *info) bin2hex(pdu_hex, msg->length, pdu); - if(ril_data.state.sms_incoming_msg_tpid != 0) { + if (ril_data.state.sms_incoming_msg_tpid != 0) { LOGD("Another message is waiting ACK, queuing"); rc = ipc_sms_incoming_msg_register(pdu, length, msg->type, msg->msg_tpid); - if(rc < 0) + if (rc < 0) LOGE("Unable to register incoming msg"); return; @@ -681,13 +681,13 @@ void ril_request_sms_acknowledge(RIL_Token t, void *data, size_t length) struct ipc_sms_deliver_report_request report_msg; int success, fail_cause; - if(data == NULL || length < 2 * sizeof(int)) + if (data == NULL || length < 2 * sizeof(int)) return; success = ((int *) data)[0]; fail_cause = ((int *) data)[1]; - if(ril_data.state.sms_incoming_msg_tpid == 0) { + if (ril_data.state.sms_incoming_msg_tpid == 0) { LOGE("There is no SMS message to ACK!"); ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); ipc_sms_incoming_msg_next(); @@ -716,7 +716,7 @@ void ipc_sms_deliver_report(struct ipc_message_info *info) RIL_Errno e; int error_code; - if(info == NULL || info->data == NULL || info->length < sizeof(struct ipc_sms_deliver_report_response)) + if (info == NULL || info->data == NULL || info->length < sizeof(struct ipc_sms_deliver_report_response)) return; report_msg = (struct ipc_sms_deliver_report_response *) info->data; @@ -732,9 +732,9 @@ void ipc_sms_deliver_report(struct ipc_message_info *info) void ipc_sms_device_ready(struct ipc_message_info *info) { #if RIL_VERSION >= 7 - if(ril_data.state.radio_state == RADIO_STATE_ON) { + if (ril_data.state.radio_state == RADIO_STATE_ON) { #else - if(ril_data.state.radio_state == RADIO_STATE_SIM_READY) { + if (ril_data.state.radio_state == RADIO_STATE_SIM_READY) { #endif ipc_fmt_send(IPC_SMS_DEVICE_READY, IPC_TYPE_SET, NULL, 0, info->aseq); } @@ -41,22 +41,22 @@ int srs_client_register(struct srs_client_data *client_data, int fd) struct list_head *list_end; struct list_head *list; - if(client_data == NULL) + if (client_data == NULL) return -1; client = calloc(1, sizeof(struct srs_client_info)); - if(client == NULL) + if (client == NULL) return -1; client->fd = fd; list_end = client_data->clients; - while(list_end != NULL && list_end->next != NULL) + while (list_end != NULL && list_end->next != NULL) list_end = list_end->next; list = list_head_alloc((void *) client, list_end, NULL); - if(client_data->clients == NULL) + if (client_data->clients == NULL) client_data->clients = list; return 0; @@ -66,16 +66,16 @@ void srs_client_unregister(struct srs_client_data *client_data, struct srs_clien { struct list_head *list; - if(client_data == NULL || client == NULL) + if (client_data == NULL || client == NULL) return; list = client_data->clients; - while(list != NULL) { - if(list->data == (void *) client) { + while (list != NULL) { + if (list->data == (void *) client) { memset(client, 0, sizeof(struct srs_client_info)); free(client); - if(list == client_data->clients) + if (list == client_data->clients) client_data->clients = list->next; list_head_free(list); @@ -93,9 +93,9 @@ struct srs_client_info *srs_client_info_find(struct srs_client_data *client_data struct list_head *list; list = client_data->clients; - while(list != NULL) { + while (list != NULL) { client = (struct srs_client_info *) list->data; - if(client == NULL) + if (client == NULL) goto list_continue; return client; @@ -113,12 +113,12 @@ struct srs_client_info *srs_client_info_find_fd(struct srs_client_data *client_d struct list_head *list; list = client_data->clients; - while(list != NULL) { + while (list != NULL) { client = (struct srs_client_info *) list->data; - if(client == NULL) + if (client == NULL) goto list_continue; - if(client->fd == fd) + if (client->fd == fd) return client; list_continue: @@ -134,18 +134,18 @@ int srs_client_info_fill_fd_set(struct srs_client_data *client_data, fd_set *fds struct list_head *list; int fd_max; - if(client_data == NULL || fds == NULL) + if (client_data == NULL || fds == NULL) return -1; fd_max = -1; list = client_data->clients; - while(list != NULL) { + while (list != NULL) { client = (struct srs_client_info *) list->data; - if(client == NULL) + if (client == NULL) goto list_continue; FD_SET(client->fd, fds); - if(client->fd > fd_max) + if (client->fd > fd_max) fd_max = client->fd; list_continue: @@ -161,16 +161,16 @@ int srs_client_info_get_fd_set(struct srs_client_data *client_data, fd_set *fds) struct list_head *list; int fd; - if(client_data == NULL || fds == NULL) + if (client_data == NULL || fds == NULL) return -1; list = client_data->clients; - while(list != NULL) { + while (list != NULL) { client = (struct srs_client_info *) list->data; - if(client == NULL) + if (client == NULL) goto list_continue; - if(FD_ISSET(client->fd, fds)) { + if (FD_ISSET(client->fd, fds)) { FD_CLR(client->fd, fds); return client->fd; } @@ -191,7 +191,7 @@ int srs_client_send_message(struct srs_client_data *client_data, struct srs_mess fd_set fds; int rc; - if(client_data == NULL || message == NULL) + if (client_data == NULL || message == NULL) return -1; memset(&header, 0, sizeof(header)); @@ -200,7 +200,7 @@ int srs_client_send_message(struct srs_client_data *client_data, struct srs_mess header.index = SRS_INDEX(message->command); data = calloc(1, header.length); - if(data == NULL) + if (data == NULL) return -1; memcpy(data, &header, sizeof(header)); @@ -209,7 +209,7 @@ int srs_client_send_message(struct srs_client_data *client_data, struct srs_mess memset(&timeout, 0, sizeof(timeout)); timeout.tv_usec = 300; - if(client_data->client_fd < 0) + if (client_data->client_fd < 0) goto error; FD_ZERO(&fds); @@ -217,13 +217,13 @@ int srs_client_send_message(struct srs_client_data *client_data, struct srs_mess rc = select(client_data->client_fd + 1, NULL, &fds, NULL, &timeout); - if(!FD_ISSET(client_data->client_fd, &fds)) { + if (!FD_ISSET(client_data->client_fd, &fds)) { LOGE("SRS write select failed on fd %d", client_data->client_fd); goto error; } rc = write(client_data->client_fd, data, header.length); - if(rc < (int) sizeof(struct srs_header)) { + if (rc < (int) sizeof(struct srs_header)) { LOGE("SRS write failed on fd %d with %d bytes", client_data->client_fd, rc); goto error; } @@ -242,7 +242,7 @@ int srs_client_send(struct srs_client_data *client_data, unsigned short command, struct srs_message message; int rc; - if(client_data == NULL) + if (client_data == NULL) return -1; memset(&message, 0, sizeof(message)); @@ -254,11 +254,11 @@ int srs_client_send(struct srs_client_data *client_data, unsigned short command, rc = srs_client_send_message(client_data, &message); RIL_CLIENT_UNLOCK(client_data->client); - if(rc <= 0) { + if (rc <= 0) { LOGD("SRS client with fd %d terminated", client_data->client_fd); client = srs_client_info_find_fd(client_data, client_data->client_fd); - if(client != NULL) + if (client != NULL) srs_client_unregister(client_data, client); close(client_data->client_fd); client_data->client_fd = -1; @@ -272,13 +272,13 @@ int srs_send(unsigned short command, void *data, int length) struct srs_client_data *client_data; int rc; - if(ril_data.srs_client == NULL || ril_data.srs_client->data == NULL) + if (ril_data.srs_client == NULL || ril_data.srs_client->data == NULL) return -1; client_data = (struct srs_client_data *) ril_data.srs_client->data; LOGD("SEND SRS: fd=%d command=%d data_len=%d", client_data->client_fd, command, length); - if(data != NULL && length > 0) { + if (data != NULL && length > 0) { LOGD("==== SRS DATA DUMP ===="); hex_dump(data, length); LOGD("======================="); @@ -296,17 +296,17 @@ int srs_client_recv(struct srs_client_data *client_data, struct srs_message *mes fd_set fds; int rc; - if(client_data == NULL || message == NULL) + if (client_data == NULL || message == NULL) return -1; data = calloc(1, SRS_DATA_MAX_SIZE); - if(data == NULL) + if (data == NULL) return -1; memset(&timeout, 0, sizeof(timeout)); timeout.tv_usec = 300; - if(client_data->client_fd < 0) + if (client_data->client_fd < 0) goto error; FD_ZERO(&fds); @@ -314,13 +314,13 @@ int srs_client_recv(struct srs_client_data *client_data, struct srs_message *mes rc = select(client_data->client_fd + 1, &fds, NULL, NULL, &timeout); - if(!FD_ISSET(client_data->client_fd, &fds)) { + if (!FD_ISSET(client_data->client_fd, &fds)) { LOGE("SRS read select failed on fd %d", client_data->client_fd); goto error; } rc = read(client_data->client_fd, data, SRS_DATA_MAX_SIZE); - if(rc < (int) sizeof(struct srs_header)) { + if (rc < (int) sizeof(struct srs_header)) { LOGE("SRS read failed on fd %d with %d bytes", client_data->client_fd, rc); goto error; } @@ -330,7 +330,7 @@ int srs_client_recv(struct srs_client_data *client_data, struct srs_message *mes memset(message, 0, sizeof(struct srs_message)); message->command = SRS_COMMAND(header); message->data_len = header->length - sizeof(struct srs_header); - if(message->data_len > 0) { + if (message->data_len > 0) { message->data = calloc(1, message->data_len); memcpy(message->data, (void *) ((char *) data + sizeof(struct srs_header)), message->data_len); } else { @@ -349,12 +349,12 @@ void srs_control_ping(struct srs_message *message) { int caffe; - if(message == NULL || message->data == NULL || message->data_len < (int) sizeof(int)) + if (message == NULL || message->data == NULL || message->data_len < (int) sizeof(int)) return; caffe=*((int *) message->data); - if(caffe == SRS_CONTROL_CAFFE) { + if (caffe == SRS_CONTROL_CAFFE) { srs_send(SRS_CONTROL_PING, &caffe, sizeof(caffe)); } } @@ -364,14 +364,14 @@ static int srs_server_open(void) int server_fd; int t; - for(t=0 ; t < 5 ; t++) { + for (t=0 ; t < 5 ; t++) { unlink(SRS_SOCKET_NAME); #if RIL_VERSION >= 6 server_fd = socket_local_server(SRS_SOCKET_NAME, ANDROID_SOCKET_NAMESPACE_ABSTRACT, SOCK_STREAM); #else server_fd = socket_local_server(SRS_SOCKET_NAME, ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM); #endif - if(server_fd >= 0) + if (server_fd >= 0) return server_fd; } @@ -389,19 +389,19 @@ void *srs_client_read_loop(void *data) int fd; int rc; - if(data == NULL) + if (data == NULL) pthread_exit(NULL); client_data = (struct srs_client_data *) data; - while(client_data->running) { + while (client_data->running) { FD_ZERO(&fds); SRS_CLIENT_LOCK(); fd_max = srs_client_info_fill_fd_set(client_data, &fds); SRS_CLIENT_UNLOCK(); - if(fd_max < 0) { + if (fd_max < 0) { usleep(3000); continue; } @@ -412,16 +412,16 @@ void *srs_client_read_loop(void *data) select(fd_max + 1, &fds, NULL, NULL, &timeout); SRS_CLIENT_LOCK(); - while((fd = srs_client_info_get_fd_set(client_data, &fds)) >= 0) { + while ((fd = srs_client_info_get_fd_set(client_data, &fds)) >= 0) { client_data->client_fd = fd; RIL_CLIENT_LOCK(client_data->client); rc = srs_client_recv(client_data, &message); - if(rc <= 0) { + if (rc <= 0) { LOGD("SRS client with fd %d terminated", fd); client = srs_client_info_find_fd(client_data, fd); - if(client != NULL) + if (client != NULL) srs_client_unregister(client_data, client); close(fd); @@ -431,7 +431,7 @@ void *srs_client_read_loop(void *data) RIL_CLIENT_UNLOCK(client_data->client); LOGD("RECV SRS: fd=%d command=%d data_len=%d", fd, message.command, message.data_len); - if(message.data != NULL && message.data_len > 0) { + if (message.data != NULL && message.data_len > 0) { LOGD("==== SRS DATA DUMP ===="); hex_dump(message.data, message.data_len); LOGD("======================="); @@ -439,7 +439,7 @@ void *srs_client_read_loop(void *data) srs_dispatch(&message); - if(message.data != NULL) + if (message.data != NULL) free(message.data); client_data->client_fd = -1; @@ -461,7 +461,7 @@ int srs_read_loop(struct ril_client *client) int fd; int rc; - if(client == NULL || client->data == NULL) + if (client == NULL || client->data == NULL) return -1; client_data = (struct srs_client_data *) client->data; @@ -472,15 +472,15 @@ int srs_read_loop(struct ril_client *client) client_data->running = 1; rc = pthread_create(&client_data->thread, &attr, srs_client_read_loop, (void *) client_data); - if(rc < 0) { + if (rc < 0) { LOGE("Unable to create SRS client read loop thread"); return -1; } - while(client_data->server_fd >= 0) { + while (client_data->server_fd >= 0) { fd = accept(client_data->server_fd, (struct sockaddr *) &client_addr, &client_addr_len); - if(fd < 0) { + if (fd < 0) { LOGE("Unable to accept new SRS client"); break; } @@ -494,7 +494,7 @@ int srs_read_loop(struct ril_client *client) SRS_CLIENT_LOCK(); rc = srs_client_register(client_data, fd); SRS_CLIENT_UNLOCK(); - if(rc < 0) { + if (rc < 0) { LOGE("Unable to register SRS client"); break; } @@ -514,7 +514,7 @@ int srs_create(struct ril_client *client) { struct srs_client_data *client_data = NULL; - if(client == NULL) + if (client == NULL) return -1; LOGD("Creating new SRS client"); @@ -522,13 +522,13 @@ int srs_create(struct ril_client *client) signal(SIGPIPE, SIG_IGN); client_data = (struct srs_client_data *) calloc(1, sizeof(struct srs_client_data)); - if(client_data == NULL) { + if (client_data == NULL) { LOGE("SRS client data creation failed"); return -1; } client_data->server_fd = srs_server_open(); - if(client_data->server_fd < 0) { + if (client_data->server_fd < 0) { LOGE("SRS server creation failed"); goto fail; } @@ -541,7 +541,7 @@ int srs_create(struct ril_client *client) return 0; fail: - if(client_data != NULL) + if (client_data != NULL) free(client_data); return -1; @@ -552,22 +552,22 @@ int srs_destroy(struct ril_client *client) struct srs_client_data *client_data = NULL; struct srs_client_info *client_info; - if(client == NULL) + if (client == NULL) return 0; - if(client->data == NULL) + if (client->data == NULL) return -1; client_data = (struct srs_client_data *) client->data; pthread_mutex_destroy(&client_data->mutex); - while((client_info = srs_client_info_find(client_data)) != NULL) { + while ((client_info = srs_client_info_find(client_data)) != NULL) { close(client_info->fd); srs_client_unregister(client_data, client_info); } - if(client_data->server_fd > 0) + if (client_data->server_fd > 0) close(client_data->server_fd); memset(client_data, 0, sizeof(struct srs_client_data)); @@ -30,7 +30,7 @@ void ipc_ss_ussd_complete(struct ipc_message_info *info) int rc; rc = ipc_gen_phone_res_check(phone_res); - if(rc < 0) { + if (rc < 0) { LOGE("There was an error, aborting USSD request"); ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); @@ -62,7 +62,7 @@ void ril_request_send_ussd(RIL_Token t, void *data, size_t datalen) LOGD("USSD Tx encoding is GSM7"); data_enc_len = ascii2gsm7(data, (unsigned char**)&data_enc, datalen); - if(data_enc_len > message_size) { + if (data_enc_len > message_size) { LOGE("USSD message size is too long, aborting"); ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); @@ -90,7 +90,7 @@ void ril_request_send_ussd(RIL_Token t, void *data, size_t datalen) data_enc_len = asprintf(&data_enc, "%s", (char*)data); - if(data_enc_len > message_size) { + if (data_enc_len > message_size) { LOGE("USSD message size is too long, aborting"); ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); @@ -114,7 +114,7 @@ void ril_request_send_ussd(RIL_Token t, void *data, size_t datalen) break; } - if(message == NULL) { + if (message == NULL) { LOGE("USSD message is empty, aborting"); ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); @@ -184,7 +184,7 @@ void ipc_ss_ussd(struct ipc_message_info *info) ril_data.state.ussd_state = ussd->state; - if(ussd->length > 0 && info->length > 0 && info->data != NULL) { + if (ussd->length > 0 && info->length > 0 && info->data != NULL) { codingScheme = sms_get_coding_scheme(ussd->dcs); switch(codingScheme) { case SMS_CODING_SCHEME_GSM7: @@ -38,16 +38,16 @@ struct list_head *list_head_alloc(void *data, struct list_head *prev, struct lis struct list_head *list; list = calloc(1, sizeof(struct list_head)); - if(list == NULL) + if (list == NULL) return NULL; list->data = data; list->prev = prev; list->next = next; - if(prev != NULL) + if (prev != NULL) prev->next = list; - if(next != NULL) + if (next != NULL) next->prev = list; return list; @@ -55,12 +55,12 @@ struct list_head *list_head_alloc(void *data, struct list_head *prev, struct lis void list_head_free(struct list_head *list) { - if(list == NULL) + if (list == NULL) return; - if(list->next != NULL) + if (list->next != NULL) list->next->prev = list->prev; - if(list->prev != NULL) + if (list->prev != NULL) list->prev->next = list->next; memset(list, 0, sizeof(struct list_head)); @@ -78,24 +78,24 @@ void hex2bin(const char *data, int length, unsigned char *buf) length ^= 0x01; - while(i < length) { + while (i < length) { b = 0; - if(data[i] - '0' < 10) + if (data[i] - '0' < 10) b = data[i] - '0'; - else if(data[i] - 'a' < 7) + else if (data[i] - 'a' < 7) b = data[i] - 'a' + 10; - else if(data[i] - 'A' < 7) + else if (data[i] - 'A' < 7) b = data[i] - 'A' + 10; i++; b = (b << 4); - if(data[i] - '0' < 10) + if (data[i] - '0' < 10) b |= data[i] - '0'; - else if(data[i] - 'a' < 7) + else if (data[i] - 'a' < 7) b |= data[i] - 'a' + 10; - else if(data[i] - 'A' < 7) + else if (data[i] - 'A' < 7) b |= data[i] - 'A' + 10; i++; @@ -112,7 +112,7 @@ void bin2hex(const unsigned char *data, int length, char *buf) char b; char *p = buf; - for(i = 0; i < length; i++) { + for (i = 0; i < length; i++) { b = 0; b = (data[i] >> 4 & 0x0f); @@ -143,10 +143,10 @@ int gsm72ascii(unsigned char *data, char **data_dec, int length) memset(dec, 0, dec_length); - for(i=0 ; i < length ; i++) + for (i=0 ; i < length ; i++) { d = 7 - i % 7; - if(d == 7 && i != 0) + if (d == 7 && i != 0) o++; t = (data[i] - (((data[i] >> d) & 0xff) << d)); @@ -154,7 +154,7 @@ int gsm72ascii(unsigned char *data, char **data_dec, int length) dec[i+o]+=t << (i + o) % 8; - if(u) + if (u) dec[i+1+o]+=u; } @@ -183,7 +183,7 @@ int ascii2gsm7(char *data, unsigned char **data_enc, int length) enc = malloc(enc_length); memset(enc, 0, enc_length); - for(i=0 ; i < length ; i++) + for (i=0 ; i < length ; i++) { // offset from the right of data to keep d_off = i % 8; @@ -228,7 +228,7 @@ void hex_dump(void *data, int size) char addrstr[10] = {0}; char hexstr[ 16*3 + 5] = {0}; char charstr[16*1 + 5] = {0}; - for(n=1;n<=size;n++) { + for (n=1;n<=size;n++) { if (n%16 == 1) { /* store address for this line */ snprintf(addrstr, sizeof(addrstr), "%.4x", @@ -248,12 +248,12 @@ void hex_dump(void *data, int size) snprintf(bytestr, sizeof(bytestr), "%c", c); strncat(charstr, bytestr, sizeof(charstr)-strlen(charstr)-1); - if(n%16 == 0) { + if (n%16 == 0) { /* line completed */ LOGD("[%4.4s] %-50.50s %s", addrstr, hexstr, charstr); hexstr[0] = 0; charstr[0] = 0; - } else if(n%8 == 0) { + } else if (n%8 == 0) { /* half line: add whitespaces */ strncat(hexstr, " ", sizeof(hexstr)-strlen(hexstr)-1); strncat(charstr, " ", sizeof(charstr)-strlen(charstr)-1); |