Define and use RIL_TOKEN_NULL
authorPaul Kocialkowski <contact@paulk.fr>
Sun, 31 Mar 2013 20:37:27 +0000 (22:37 +0200)
committerPaul Kocialkowski <contact@paulk.fr>
Sun, 31 Mar 2013 20:48:09 +0000 (22:48 +0200)
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
gprs.c
net.c
pwr.c
samsung-ril.c
samsung-ril.h
sec.c
sms.c

diff --git a/gprs.c b/gprs.c
index 9f5c41e..560ce04 100644 (file)
--- a/gprs.c
+++ b/gprs.c
@@ -262,7 +262,7 @@ void ipc_gprs_pdp_context_enable_complete(struct ipc_message_info *info)
                LOGE("There was an error, aborting PDP context complete");
 
                gprs_connection->fail_cause = PDP_FAIL_ERROR_UNSPECIFIED;
-               gprs_connection->token = (RIL_Token) 0x00;
+               gprs_connection->token = RIL_TOKEN_NULL;
                ril_data.state.gprs_last_failed_cid = gprs_connection->cid;
 
                ril_request_complete(ril_request_get_token(info->aseq),
@@ -297,7 +297,7 @@ void ipc_gprs_define_pdp_context_complete(struct ipc_message_info *info)
                LOGE("There was an error, aborting define PDP context complete");
 
                gprs_connection->fail_cause = PDP_FAIL_ERROR_UNSPECIFIED;
-               gprs_connection->token = (RIL_Token) 0x00;
+               gprs_connection->token = RIL_TOKEN_NULL;
                ril_data.state.gprs_last_failed_cid = gprs_connection->cid;
 
                ril_request_complete(ril_request_get_token(info->aseq),
@@ -343,7 +343,7 @@ void ipc_gprs_port_list_complete(struct ipc_message_info *info)
                LOGE("There was an error, aborting port list complete");
 
                gprs_connection->fail_cause = PDP_FAIL_ERROR_UNSPECIFIED;
-               gprs_connection->token = (RIL_Token) 0x00;
+               gprs_connection->token = RIL_TOKEN_NULL;
                ril_data.state.gprs_last_failed_cid = gprs_connection->cid;
 
                ril_request_complete(ril_request_get_token(info->aseq),
@@ -806,7 +806,7 @@ void ipc_gprs_call_status(struct ipc_message_info *info)
        if (call_status->fail_cause == 0) {
                if (!gprs_connection->enabled &&
                        call_status->state == IPC_GPRS_STATE_ENABLED &&
-                       gprs_connection->token != (RIL_Token) 0x00) {
+                       gprs_connection->token != RIL_TOKEN_NULL) {
                        LOGD("GPRS connection is now enabled");
 
                        rc = ipc_gprs_connection_enable(gprs_connection,
@@ -828,7 +828,7 @@ void ipc_gprs_call_status(struct ipc_message_info *info)
                                ril_request_complete(gprs_connection->token,
                                        RIL_E_SUCCESS, &setup_data_call_response,
                                        sizeof(setup_data_call_response));
-                               gprs_connection->token = (RIL_Token) 0x00;
+                               gprs_connection->token = RIL_TOKEN_NULL;
                        }
 #if RIL_VERSION >= 6
                        ril_data_call_response_free(&setup_data_call_response);
@@ -842,7 +842,7 @@ void ipc_gprs_call_status(struct ipc_message_info *info)
 #endif
                } else if (gprs_connection->enabled &&
                        call_status->state == IPC_GPRS_STATE_DISABLED &&
-                       gprs_connection->token != (RIL_Token) 0x00) {
+                       gprs_connection->token != RIL_TOKEN_NULL) {
                        LOGD("GPRS connection is now disabled");
 
                        rc = ipc_gprs_connection_disable(gprs_connection);
@@ -875,7 +875,7 @@ void ipc_gprs_call_status(struct ipc_message_info *info)
                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) {
+                       gprs_connection->token != RIL_TOKEN_NULL) {
                        LOGE("Failed to enable GPRS connection");
 
                        gprs_connection->enabled = 0;
@@ -885,7 +885,7 @@ void ipc_gprs_call_status(struct ipc_message_info *info)
 
                        ril_request_complete(gprs_connection->token,
                                RIL_E_GENERIC_FAILURE, NULL, 0);
-                       gprs_connection->token = (RIL_Token) 0x00;
+                       gprs_connection->token = RIL_TOKEN_NULL;
 
                        ril_unsol_data_call_list_changed();
                } else if (gprs_connection->enabled &&
diff --git a/net.c b/net.c
index 65796fb..8312adc 100644 (file)
--- a/net.c
+++ b/net.c
@@ -306,7 +306,7 @@ void ril_request_operator(RIL_Token t)
        ril_data.state.netinfo.reg_state > IPC_NET_REGISTRATION_STATE_ROAMING) {
                ril_request_complete(t, RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW, NULL, 0);
 
-               ril_data.tokens.operator = (RIL_Token) 0x00;
+               ril_data.tokens.operator = RIL_TOKEN_NULL;
                return;
        }
 
@@ -323,8 +323,8 @@ void ril_request_operator(RIL_Token t)
                                free(response[i]);
                }
 
-               ril_data.tokens.operator = (RIL_Token) 0x00;
-       } else if (ril_data.tokens.operator == (RIL_Token) 0x00) {
+               ril_data.tokens.operator = RIL_TOKEN_NULL;
+       } else if (ril_data.tokens.operator == RIL_TOKEN_NULL) {
                LOGD("Got RILJ request for SOL data");
                /* Request data to the modem */
                ril_data.tokens.operator = t;
@@ -375,7 +375,7 @@ void ipc_net_current_plmn(struct ipc_message_info *info)
 
                                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_NULL && ril_data.tokens.operator != RIL_TOKEN_DATA_WAITING) {
                                        LOGE("Another Operator Req is in progress, skipping");
                                        return;
                                }
@@ -409,7 +409,7 @@ void ipc_net_current_plmn(struct ipc_message_info *info)
                                ril_request_complete(t, RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW, NULL, 0);
 
                                if (ril_data.tokens.operator != RIL_TOKEN_DATA_WAITING)
-                                       ril_data.tokens.operator = (RIL_Token) 0x00;
+                                       ril_data.tokens.operator = RIL_TOKEN_NULL;
                                return;
                        } else {
                                if (ril_data.tokens.operator != t)
@@ -428,7 +428,7 @@ void ipc_net_current_plmn(struct ipc_message_info *info)
                                }
 
                                if (ril_data.tokens.operator != RIL_TOKEN_DATA_WAITING)
-                                       ril_data.tokens.operator = (RIL_Token) 0x00;
+                                       ril_data.tokens.operator = RIL_TOKEN_NULL;
                        }
                        break;
                default:
@@ -468,8 +468,8 @@ void ril_request_registration_state(RIL_Token t)
                                free(response[i]);
                }
 
-               ril_data.tokens.registration_state = (RIL_Token) 0x00;
-       } else if (ril_data.tokens.registration_state == (RIL_Token) 0x00) {
+               ril_data.tokens.registration_state = RIL_TOKEN_NULL;
+       } else if (ril_data.tokens.registration_state == RIL_TOKEN_NULL) {
                LOGD("Got RILJ request for SOL data");
                /* Request data to the modem */
                ril_data.tokens.registration_state = t;
@@ -516,8 +516,8 @@ void ril_request_gprs_registration_state(RIL_Token t)
                                free(response[i]);
                }
 
-               ril_data.tokens.gprs_registration_state = (RIL_Token) 0x00;
-       } else if (ril_data.tokens.gprs_registration_state == (RIL_Token) 0x00) {
+               ril_data.tokens.gprs_registration_state = RIL_TOKEN_NULL;
+       } else if (ril_data.tokens.gprs_registration_state == RIL_TOKEN_NULL) {
                LOGD("Got RILJ request for SOL data");
 
                /* Request data to the modem */
@@ -555,7 +555,7 @@ void ipc_net_regist_unsol(struct ipc_message_info *info)
 
        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_NULL && ril_data.tokens.registration_state != RIL_TOKEN_DATA_WAITING) {
                                LOGE("Another NetRegist Req is in progress, skipping");
                                return;
                        }
@@ -576,7 +576,7 @@ void ipc_net_regist_unsol(struct ipc_message_info *info)
                        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_NULL && ril_data.tokens.gprs_registration_state != RIL_TOKEN_DATA_WAITING) {
                                LOGE("Another GPRS NetRegist Req is in progress, skipping");
                                return;
                        }
@@ -643,7 +643,7 @@ void ipc_net_regist_sol(struct ipc_message_info *info)
                        }
 
                        if (ril_data.tokens.registration_state != RIL_TOKEN_DATA_WAITING)
-                               ril_data.tokens.registration_state = (RIL_Token) 0x00;
+                               ril_data.tokens.registration_state = RIL_TOKEN_NULL;
                        break;
                case IPC_NET_SERVICE_DOMAIN_GPRS:
                        if (ril_data.tokens.gprs_registration_state != t)
@@ -661,7 +661,7 @@ void ipc_net_regist_sol(struct ipc_message_info *info)
                                        free(response[i]);
                        }
                        if (ril_data.tokens.registration_state != RIL_TOKEN_DATA_WAITING)
-                               ril_data.tokens.gprs_registration_state = (RIL_Token) 0x00;
+                               ril_data.tokens.gprs_registration_state = RIL_TOKEN_NULL;
                        break;
                default:
                        LOGE("%s: unhandled service domain: %d", __func__, netinfo->domain);
diff --git a/pwr.c b/pwr.c
index 6efc4d8..d2f0f1c 100644 (file)
--- a/pwr.c
+++ b/pwr.c
@@ -58,9 +58,9 @@ 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.tokens.radio_power != (RIL_Token) 0x00) {
+                       if (ril_data.tokens.radio_power != RIL_TOKEN_NULL) {
                                ril_request_complete(ril_data.tokens.radio_power, RIL_E_SUCCESS, NULL, 0);
-                               ril_data.tokens.radio_power = (RIL_Token) 0x00;
+                               ril_data.tokens.radio_power = RIL_TOKEN_NULL;
                        }
 
                        ril_data.state.radio_state = RADIO_STATE_OFF;
@@ -70,9 +70,9 @@ 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.tokens.radio_power != (RIL_Token) 0x00) {
+                       if (ril_data.tokens.radio_power != RIL_TOKEN_NULL) {
                                ril_request_complete(ril_data.tokens.radio_power, RIL_E_SUCCESS, NULL, 0);
-                               ril_data.tokens.radio_power = (RIL_Token) 0x00;
+                               ril_data.tokens.radio_power = RIL_TOKEN_NULL;
                        }
 
                        ril_data.state.radio_state = RADIO_STATE_SIM_NOT_READY;
index 9bfa335..25dc077 100644 (file)
@@ -184,7 +184,7 @@ RIL_Token ril_request_get_token(int id)
 
        request = ril_request_info_find_id(id);
        if (request == NULL)
-               return (RIL_Token) 0x00;
+               return RIL_TOKEN_NULL;
 
        return request->token;
 }
index 6559ad5..ca6fcb0 100644 (file)
@@ -60,6 +60,7 @@
 #define RIL_CLIENT_UNLOCK(client) pthread_mutex_unlock(&(client->mutex))
 
 #define RIL_TOKEN_DATA_WAITING (RIL_Token) 0xff
+#define RIL_TOKEN_NULL         (RIL_Token) 0x00
 
 #define RIL_CLIENT_MAX_TRIES   7
 
diff --git a/sec.c b/sec.c
index 4ed0984..e645ba1 100644 (file)
--- a/sec.c
+++ b/sec.c
@@ -228,7 +228,7 @@ void ipc_sec_sim_status(struct ipc_message_info *info)
 
                        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_NULL && ril_data.tokens.pin_status != RIL_TOKEN_DATA_WAITING) {
                                LOGE("Another PIN status Req is in progress, skipping");
                                return;
                        }
@@ -257,7 +257,7 @@ void ipc_sec_sim_status(struct ipc_message_info *info)
                        ril_request_complete(t, RIL_E_SUCCESS, &card_status, sizeof(card_status));
 
                        if (ril_data.tokens.pin_status != RIL_TOKEN_DATA_WAITING)
-                               ril_data.tokens.pin_status = (RIL_Token) 0x00;
+                               ril_data.tokens.pin_status = RIL_TOKEN_NULL;
                        break;
                default:
                        LOGE("%s: unhandled ipc method: %d", __func__, info->type);
@@ -291,8 +291,8 @@ 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) {
+               ril_data.tokens.pin_status = RIL_TOKEN_NULL;
+       } else if (ril_data.tokens.pin_status == RIL_TOKEN_NULL) {
                LOGD("Got RILJ request for SOL data");
 
                /* Request data to the modem */
@@ -450,7 +450,7 @@ void ril_request_sim_io_next(void)
        struct ril_request_sim_io_info *sim_io;
        int rc;
 
-       ril_data.tokens.sim_io = (RIL_Token) 0x00;
+       ril_data.tokens.sim_io = RIL_TOKEN_NULL;
 
        sim_io = ril_request_sim_io_info_find();
        if (sim_io == NULL)
@@ -541,7 +541,7 @@ void ril_request_sim_io(RIL_Token t, void *data, int length)
                ril_request_sim_io_next();
        }
 
-       if (ril_data.tokens.sim_io != (RIL_Token) 0x00) {
+       if (ril_data.tokens.sim_io != RIL_TOKEN_NULL) {
                LOGD("Another SIM I/O is being processed, adding to the list");
                return;
        }
diff --git a/sms.c b/sms.c
index bcc208a..d13edcb 100644 (file)
--- a/sms.c
+++ b/sms.c
@@ -177,7 +177,7 @@ void ril_request_send_sms_next(void)
        int smsc_length;
        int rc;
 
-       ril_data.tokens.outgoing_sms = (RIL_Token) 0x00;
+       ril_data.tokens.outgoing_sms = RIL_TOKEN_NULL;
 
        send_sms = ril_request_send_sms_info_find();
        if (send_sms == NULL)
@@ -360,7 +360,7 @@ void ril_request_send_sms(RIL_Token t, void *data, size_t length)
                smsc = (unsigned char *) strdup((char *) smsc);
        }
 
-       if (ril_data.tokens.outgoing_sms != (RIL_Token) 0x00) {
+       if (ril_data.tokens.outgoing_sms != RIL_TOKEN_NULL) {
                LOGD("Another outgoing SMS is being processed, adding to the list");
 
                rc = ril_request_send_sms_register(pdu, pdu_length, smsc, smsc_length, t);