diff --git a/src/tapi_call.c b/src/tapi_call.c index 759a92d..8bb444e 100644 --- a/src/tapi_call.c +++ b/src/tapi_call.c @@ -76,7 +76,18 @@ static int tapi_call_property_change(DBusMessage* message, tapi_async_handler* h static int call_strcpy(char* dst, const char* src, int dst_size) { - if (dst == NULL || src == NULL || strlen(src) > dst_size) { + if (dst == NULL) { + tapi_log_error("dst in %s is null", __func__); + return -EINVAL; + } + + if (src == NULL) { + tapi_log_error("src in %s is null", __func__); + return -EINVAL; + } + + if (strlen(src) > dst_size) { + tapi_log_error("src length is too long"); return -EINVAL; } @@ -100,8 +111,18 @@ static void call_param_append(DBusMessageIter* iter, void* user_data) call_param* param; char* number; - if (handler == NULL || handler->result == NULL || handler->result->data == NULL) { - tapi_log_error("invalid dial request argument !!"); + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); + return; + } + + if (handler->result == NULL) { + tapi_log_error("result in %s is null", __func__); + return; + } + + if (handler->result->data == NULL) { + tapi_log_error("data in %s is null", __func__); return; } @@ -131,7 +152,7 @@ static void answer_hangup_param_append(DBusMessageIter* iter, void* user_data) char* path = user_data; if (path == NULL) { - tapi_log_error("invalid answer_hangup request argument !!"); + tapi_log_error("invalid answer_hangup request argument in %s!!", __func__); return; } @@ -145,8 +166,18 @@ static void dtmf_param_append(DBusMessageIter* iter, void* user_data) unsigned char digit; int flag; - if (handler == NULL || handler->result == NULL || handler->result->data == NULL) { - tapi_log_error("invalid dtmf request argument !!"); + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); + return; + } + + if (handler->result == NULL) { + tapi_log_error("result in %s is null", __func__); + return; + } + + if (handler->result->data == NULL) { + tapi_log_error("data in %s is null", __func__); return; } @@ -167,7 +198,7 @@ static void deflect_param_append_0(DBusMessageIter* iter, void* user_data) char *path, *number; if (param == NULL) { - tapi_log_error("invalid deflect request argument !!"); + tapi_log_error("param in %s is null", __func__); return; } @@ -203,7 +234,7 @@ static void conference_param_append(DBusMessageIter* iter, void* user_data) ims_conference_participants = user_data; if (ims_conference_participants == NULL) { - tapi_log_error("invalid conference request argument !!"); + tapi_log_error("ims_conference_participants in %s is null", __func__); return; } @@ -244,7 +275,7 @@ static int tapi_call_default_voicecall_slot_change(DBusMessage* message, tapi_as } if (!dbus_message_iter_init(message, &iter)) { - tapi_log_error("dbus message iter init failed"); + tapi_log_error("dbus message iter init failed in %s", __func__); return false; } @@ -287,7 +318,6 @@ static int ring_back_tone_change(DBusMessage* message, tapi_async_handler* handl if (is_call_signal_message(message, &iter, DBUS_TYPE_INT32)) { dbus_message_iter_get_basic(&iter, &ar->arg2); - ar->status = OK; cb(ar); } @@ -356,7 +386,7 @@ static int call_state_changed(DBusConnection* connection, DBusMessage* message, } if (!dbus_message_iter_init(message, &iter)) { - tapi_log_error("dbus message iter init failed"); + tapi_log_error("dbus message iter init failed in %s", __func__); return 0; } @@ -398,14 +428,14 @@ static void dial_call_callback(DBusMessage* message, void* user_data) dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { - tapi_log_error("dbus message iter init failed"); + tapi_log_error("dbus message iter init failed in %s", __func__); ar->status = ERROR; goto done; } @@ -447,7 +477,7 @@ static void play_dtmf_callback(DBusMessage* message, void* user_data) ar->status = OK; dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; } @@ -484,20 +514,20 @@ static void merge_call_complete(DBusMessage* message, void* user_data) dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_has_signature(message, "ao") == false) { - tapi_log_error("dbus message has wrong signature"); + tapi_log_error("dbus message has wrong signature in %s", __func__); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { - tapi_log_error("dbus message iter init failed"); + tapi_log_error("dbus message iter init failed in %s", __func__); ar->status = ERROR; goto done; } @@ -550,18 +580,18 @@ static void call_list_query_complete(DBusMessage* message, void* user_data) // start to handle response message. dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); goto done; } if (dbus_message_has_signature(message, "a(oa{sv})") == false) { - tapi_log_error("dbus message has wrong signature"); + tapi_log_error("dbus message has wrong signature in %s", __func__); goto done; } if (dbus_message_iter_init(message, &args) == false) { - tapi_log_error("dbus message iter init failed"); + tapi_log_error("dbus message iter init failed in %s", __func__); goto done; } @@ -758,13 +788,13 @@ static int tapi_register_manager_call_signal(tapi_context context, int slot_id, member = get_call_signal_member(msg); if (member == NULL) { - tapi_log_error("no signal member found ...\n"); + tapi_log_error("member in %s is null", __func__); return -EINVAL; } modem_path = tapi_utils_get_modem_path(slot_id); if (modem_path == NULL) { - tapi_log_error("no available modem ...\n"); + tapi_log_error("modem_path in %s is null", __func__); return -EIO; } @@ -866,11 +896,12 @@ static int manage_call_proxy_method(tapi_context context, int slot_id, const cha proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } if (!g_dbus_proxy_method_call(proxy, member, NULL, no_operate_callback, NULL, NULL)) { + tapi_log_error("dbus method call fail in %s", __func__); report_data_logging_for_call_if(!strcmp("HangupAll", member), ctx, OFONO_CALL_TYPE_UNKNOW, OFONO_DIRECTION_UNKNOW, OFONO_VOICE, OFONO_HANGUP_FAIL, "dbus method call fail"); report_data_logging_for_call_if(!strcmp("ReleaseAndAnswer", member) @@ -911,7 +942,7 @@ static int manager_conference(tapi_context context, int slot_id, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -953,7 +984,7 @@ static int call_play_dtmf(tapi_context context, int slot_id, unsigned char digit proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1025,7 +1056,7 @@ int tapi_call_dial(tapi_context context, int slot_id, char* number, int hide_cal proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1169,7 +1200,7 @@ int tapi_call_get_all_calls(tapi_context context, int slot_id, int event_id, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1224,7 +1255,7 @@ int tapi_call_merge_call(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1283,7 +1314,7 @@ int tapi_call_separate_call(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1337,7 +1368,7 @@ int tapi_call_send_tones(void* context, int slot_id, char* tones) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1374,7 +1405,7 @@ int tapi_call_get_ecc_list(tapi_context context, int slot_id, ecc_info* out) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1382,7 +1413,7 @@ int tapi_call_get_ecc_list(tapi_context context, int slot_id, ecc_info* out) syslog(LOG_DEBUG, "no EmergencyNumbers in CALL,use default"); proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } if (!g_dbus_proxy_get_property(proxy, "EmergencyNumbers", &list)) { @@ -1567,7 +1598,7 @@ int tapi_call_register_call_state_change(tapi_context context, int slot_id, modem_path = tapi_utils_get_modem_path(slot_id); if (modem_path == NULL) { - tapi_log_error("no available modem ...\n"); + tapi_log_error("no available modem in %s", __func__); return -EIO; } @@ -1626,7 +1657,7 @@ int tapi_call_answer_by_id(tapi_context context, int slot_id, char* call_id) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1663,7 +1694,7 @@ int tapi_call_hangup_by_id(tapi_context context, int slot_id, char* call_id) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1706,7 +1737,7 @@ int tapi_call_deflect_by_id(tapi_context context, int slot_id, char* call_id, ch proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1749,7 +1780,7 @@ int tapi_call_set_default_slot(tapi_context context, int slot_id) proxy = ctx->dbus_proxy_manager; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1783,7 +1814,7 @@ int tapi_call_get_default_slot(tapi_context context, int* out) proxy = ctx->dbus_proxy_manager; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } diff --git a/src/tapi_cbs.c b/src/tapi_cbs.c index 8310218..c85d2aa 100644 --- a/src/tapi_cbs.c +++ b/src/tapi_cbs.c @@ -173,7 +173,7 @@ int tapi_sms_set_cell_broadcast_power_on(tapi_context context, int slot_id, bool proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CBS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -203,7 +203,7 @@ int tapi_sms_get_cell_broadcast_power_on(tapi_context context, int slot_id, bool proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CBS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EISCONN; } @@ -238,7 +238,7 @@ int tapi_sms_set_cell_broadcast_topics(tapi_context context, int slot_id, char* proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CBS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -268,7 +268,7 @@ int tapi_sms_get_cell_broadcast_topics(tapi_context context, int slot_id, char** proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CBS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EISCONN; } @@ -302,7 +302,7 @@ int tapi_cbs_register(tapi_context context, int slot_id, tapi_indication_msg msg path = tapi_utils_get_modem_path(slot_id); if (path == NULL) { - tapi_log_error("no available modem ...\n"); + tapi_log_error("no available modem in %s", __func__); return -EIO; } diff --git a/src/tapi_data.c b/src/tapi_data.c index d7e6304..bb59dc6 100644 --- a/src/tapi_data.c +++ b/src/tapi_data.c @@ -478,7 +478,7 @@ static void apn_list_loaded(DBusMessage* message, void* user_data) dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; @@ -558,7 +558,7 @@ static void apn_list_changed(DBusMessage* message, void* user_data) dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; } @@ -587,7 +587,7 @@ static void apn_context_append(DBusMessageIter* iter, void* user_data) dc = ar->data; if (dc == NULL) { - tapi_log_error("invalid apn settings ... \n"); + tapi_log_error("dc in %s is null", __func__); return; } @@ -668,7 +668,7 @@ static void apn_context_edit(DBusMessageIter* iter, void* user_data) dc = ar->data; if (dc == NULL) { - tapi_log_error("invalid apn settings ... \n"); + tapi_log_error("dc in %s is null", __func__); return; } @@ -734,7 +734,7 @@ static void data_connection_list_query_done(DBusMessage* message, void* user_dat dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; @@ -837,7 +837,7 @@ int tapi_data_load_apn_contexts(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -893,13 +893,13 @@ int tapi_data_add_apn_context(tapi_context context, } if (tapi_utils_apn_type_to_string(apn->type) == NULL) { - tapi_log_error("invalid apn argument ...\n"); + tapi_log_error("invalid apn argument in %s", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -957,7 +957,7 @@ int tapi_data_remove_apn_context(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1014,13 +1014,13 @@ int tapi_data_edit_apn_context(tapi_context context, } if (tapi_utils_apn_type_to_string(apn->type) == NULL) { - tapi_log_error("invalid apn argument ...\n"); + tapi_log_error("invalid apn argument in %s", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1073,7 +1073,7 @@ int tapi_data_reset_apn_contexts(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1129,7 +1129,7 @@ int tapi_data_is_registered(tapi_context context, int slot_id, bool* out) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1169,7 +1169,7 @@ int tapi_data_is_data_emergency_only(tapi_context context, int slot_id, bool* ou proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1212,7 +1212,7 @@ int tapi_data_get_network_type(tapi_context context, int slot_id, tapi_network_t proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1251,7 +1251,7 @@ int tapi_data_is_data_roaming(tapi_context context, int slot_id, bool* out) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1288,7 +1288,7 @@ int tapi_data_request_network(tapi_context context, int slot_id, const char* typ proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1323,7 +1323,7 @@ int tapi_data_release_network(tapi_context context, int slot_id, const char* typ proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1356,7 +1356,7 @@ int tapi_data_get_data_connection_list(tapi_context context, int slot_id, int ev proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1416,7 +1416,7 @@ int tapi_data_set_preferred_apn(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1453,7 +1453,7 @@ int tapi_data_get_preferred_apn(tapi_context context, int slot_id, char** out) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1487,7 +1487,7 @@ int tapi_data_enable_data(tapi_context context, bool enabled) for (int i = 0; i < CONFIG_MODEM_ACTIVE_COUNT; i++) { proxy = ctx->dbus_proxy[i][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1520,7 +1520,7 @@ int tapi_data_get_enabled(tapi_context context, bool* out) proxy = ctx->dbus_proxy[DEFAULT_SLOT_ID][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1556,7 +1556,7 @@ int tapi_data_enable_roaming(tapi_context context, bool enabled) for (int i = 0; i < CONFIG_MODEM_ACTIVE_COUNT; i++) { proxy = ctx->dbus_proxy[i][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1589,7 +1589,7 @@ int tapi_data_get_roaming_enabled(tapi_context context, bool* out) proxy = ctx->dbus_proxy[DEFAULT_SLOT_ID][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1612,7 +1612,7 @@ int tapi_data_set_default_slot(tapi_context context, int slot_id) proxy = ctx->dbus_proxy_manager; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1645,7 +1645,7 @@ int tapi_data_get_default_slot(tapi_context context, int* out) proxy = ctx->dbus_proxy_manager; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1690,7 +1690,7 @@ int tapi_data_set_data_allow(tapi_context context, int slot_id, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_DATA]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1747,7 +1747,7 @@ int tapi_data_register(tapi_context context, modem_path = tapi_utils_get_modem_path(slot_id); if (modem_path == NULL) { - tapi_log_error("no available modem ...\n"); + tapi_log_error("no available modem in %s", __func__); return -EIO; } diff --git a/src/tapi_ims.c b/src/tapi_ims.c index 7def7bc..d0434f2 100644 --- a/src/tapi_ims.c +++ b/src/tapi_ims.c @@ -67,7 +67,7 @@ static int tapi_ims_enable(tapi_context context, int slot_id, int state) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_IMS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -184,7 +184,7 @@ int tapi_ims_set_service_status(tapi_context context, int slot_id, int capabilit proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_IMS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -218,7 +218,7 @@ int tapi_ims_register_registration_change(tapi_context context, int slot_id, voi path = tapi_utils_get_modem_path(slot_id); if (path == NULL) { - tapi_log_error("no available modem ...\n"); + tapi_log_error("no available modem in %s", __func__); return -EIO; } @@ -287,7 +287,7 @@ int tapi_ims_get_registration(tapi_context context, int slot_id, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_IMS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -338,7 +338,7 @@ int tapi_ims_is_registered(tapi_context context, int slot_id, bool* out) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_IMS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -377,7 +377,7 @@ int tapi_ims_is_volte_available(tapi_context context, int slot_id, bool* out) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_IMS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -422,7 +422,7 @@ int tapi_ims_get_subscriber_uri_number(tapi_context context, int slot_id, char** proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_IMS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -459,7 +459,7 @@ int tapi_ims_get_enabled(tapi_context context, int slot_id, bool* out) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_IMS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } diff --git a/src/tapi_manager.c b/src/tapi_manager.c index d308115..6114756 100644 --- a/src/tapi_manager.c +++ b/src/tapi_manager.c @@ -1065,7 +1065,7 @@ static int tapi_modem_register(tapi_context context, } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -1360,18 +1360,18 @@ int tapi_set_pref_net_mode(tapi_context context, } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_RADIO]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1419,18 +1419,18 @@ int tapi_get_pref_net_mode(tapi_context context, int slot_id, tapi_pref_net_mode } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_RADIO]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1457,18 +1457,18 @@ int tapi_send_modem_power(tapi_context context, int slot_id, bool state) } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1493,18 +1493,18 @@ int tapi_get_imei(tapi_context context, int slot_id, char** out) } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1529,18 +1529,18 @@ int tapi_get_imeisv(tapi_context context, int slot_id, char** out) } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1565,18 +1565,18 @@ int tapi_get_modem_manufacturer(tapi_context context, int slot_id, char** out) } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1601,18 +1601,18 @@ int tapi_get_modem_model(tapi_context context, int slot_id, char** out) } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1637,18 +1637,18 @@ int tapi_get_modem_revision(tapi_context context, int slot_id, char** out) } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1674,18 +1674,18 @@ int tapi_get_phone_state(tapi_context context, int slot_id, tapi_phone_state* st } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1714,18 +1714,18 @@ int tapi_set_radio_power(tapi_context context, } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1770,18 +1770,18 @@ int tapi_get_radio_power(tapi_context context, int slot_id, bool* out) } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1809,18 +1809,18 @@ int tapi_get_radio_state(tapi_context context, int slot_id, tapi_radio_state* ou } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1846,18 +1846,18 @@ int tapi_get_msisdn_number(tapi_context context, int slot_id, char** out) } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } if (!ctx->client_ready) { - tapi_log_error("dbus client is not ready"); + tapi_log_error("dbus client is not ready in %s", __func__); return -EAGAIN; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1896,13 +1896,13 @@ int tapi_get_modem_activity_info(tapi_context context, int slot_id, } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1950,7 +1950,7 @@ int tapi_invoke_oem_ril_request_raw(tapi_context context, int slot_id, int event } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -1966,7 +1966,7 @@ int tapi_invoke_oem_ril_request_raw(tapi_context context, int slot_id, int event proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -2025,7 +2025,7 @@ int tapi_invoke_oem_ril_request_strings(tapi_context context, int slot_id, int e } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -2041,7 +2041,7 @@ int tapi_invoke_oem_ril_request_strings(tapi_context context, int slot_id, int e proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -2099,13 +2099,13 @@ int tapi_enable_modem(tapi_context context, int slot_id, } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -2152,13 +2152,13 @@ int tapi_enable_modem_abnormal_event(tapi_context context, int slot_id, bool ena } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -2219,13 +2219,13 @@ int tapi_get_modem_status(tapi_context context, int slot_id, } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -2270,7 +2270,7 @@ int tapi_get_modem_status_sync(tapi_context context, int slot_id, tapi_modem_sta } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -2281,7 +2281,7 @@ int tapi_get_modem_status_sync(tapi_context context, int slot_id, tapi_modem_sta proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -2351,7 +2351,7 @@ static int tapi_manager_register_data_loging(tapi_context context, } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -2397,7 +2397,7 @@ static int trigger_modem_load_ecc_list(tapi_context context, int slot_id) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -2512,13 +2512,13 @@ int tapi_handle_command(tapi_context context, int slot_id, int atom, int command } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -2564,7 +2564,7 @@ int tapi_set_fast_dormancy(tapi_context context, } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -2575,7 +2575,7 @@ int tapi_set_fast_dormancy(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_RADIO]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -2641,7 +2641,7 @@ int tapi_get_carrier_config_bool(tapi_context context, int slot_id, char* key, b } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -2657,7 +2657,7 @@ int tapi_get_carrier_config_bool(tapi_context context, int slot_id, char* key, b proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -2711,7 +2711,7 @@ int tapi_get_carrier_config_int(tapi_context context, int slot_id, char* key, in } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -2727,7 +2727,7 @@ int tapi_get_carrier_config_int(tapi_context context, int slot_id, char* key, in proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -2780,7 +2780,7 @@ int tapi_get_carrier_config_string(tapi_context context, int slot_id, char* key, } if (!tapi_is_valid_slotid(slot_id)) { - tapi_log_error("invalid slot id %d", slot_id); + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -2796,7 +2796,7 @@ int tapi_get_carrier_config_string(tapi_context context, int slot_id, char* key, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_MODEM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } diff --git a/src/tapi_network.c b/src/tapi_network.c index 3c1a682..9b65d81 100644 --- a/src/tapi_network.c +++ b/src/tapi_network.c @@ -35,8 +35,15 @@ static void parse_nitz(const char* str, tapi_network_time* info) char* pch; char* orig; - if (str == NULL || info == NULL) + if (str == NULL) { + tapi_log_error("str in %s is null", __func__); return; + } + + if (info == NULL) { + tapi_log_error("info in %s is null", __func__); + return; + } p = &info->sec; orig = strdup(str); @@ -60,8 +67,13 @@ static void register_param_append(DBusMessageIter* iter, void* user_data) tapi_operator_info* network_info; char *mcc, *mnc, *tech; - if (handler == NULL || handler->result == NULL) { - tapi_log_error("invalid network register argument !!"); + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); + return; + } + + if (handler->result == NULL) { + tapi_log_error("async result in %s is null", __func__); return; } @@ -569,7 +581,7 @@ static void network_register_cb(DBusMessage* message, void* user_data) dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; } @@ -615,7 +627,7 @@ static void cell_list_request_complete(DBusMessage* message, void* user_data) dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; @@ -710,7 +722,7 @@ static void registration_info_query_done(DBusMessage* message, void* user_data) dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; @@ -815,7 +827,7 @@ static void operator_scan_complete(DBusMessage* message, void* user_data) dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; @@ -922,7 +934,7 @@ int tapi_network_select_auto(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETREG]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -979,7 +991,7 @@ int tapi_network_select_manual(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETREG]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1038,7 +1050,7 @@ int tapi_network_scan(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETREG]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1090,7 +1102,7 @@ int tapi_network_get_serving_cellinfos(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETMON]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1142,7 +1154,7 @@ int tapi_network_get_neighbouring_cellinfos(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETMON]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1242,7 +1254,7 @@ int tapi_network_is_voice_emergency_only(tapi_context context, int slot_id, bool proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETREG]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1286,7 +1298,7 @@ int tapi_network_get_voice_network_type(tapi_context context, int slot_id, tapi_ proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETREG]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1326,7 +1338,7 @@ int tapi_network_is_voice_roaming(tapi_context context, int slot_id, bool* out) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETREG]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1365,7 +1377,7 @@ int tapi_network_get_mcc(tapi_context context, int slot_id, char** mcc) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETREG]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1401,7 +1413,7 @@ int tapi_network_get_mnc(tapi_context context, int slot_id, char** mnc) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETREG]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1437,7 +1449,7 @@ int tapi_network_get_display_name(tapi_context context, int slot_id, char** out) proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETREG]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1473,7 +1485,7 @@ int tapi_network_get_signalstrength(tapi_context context, int slot_id, tapi_sign proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETREG]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1540,7 +1552,7 @@ int tapi_network_get_registration_info(tapi_context context, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETREG]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1593,7 +1605,7 @@ int tapi_network_set_cell_info_list_rate(tapi_context context, int slot_id, proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_NETMON]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1653,7 +1665,7 @@ int tapi_network_register(tapi_context context, modem_path = tapi_utils_get_modem_path(slot_id); if (modem_path == NULL) { - tapi_log_error("no available modem ...\n"); + tapi_log_error("no available modem in %s", __func__); return -EIO; } diff --git a/src/tapi_ss.c b/src/tapi_ss.c index 12dc298..c94a0ee 100644 --- a/src/tapi_ss.c +++ b/src/tapi_ss.c @@ -55,8 +55,13 @@ static void set_clir_append(DBusMessageIter* iter, void* user_data) tapi_clir_status status; const char* clir_status; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid clir value !!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("invalid clir value in %s !!", __func__); return; } @@ -70,8 +75,13 @@ static void set_call_waiting_append(DBusMessageIter* iter, void* user_data) tapi_async_handler* param = user_data; int enable; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid call waiting value!!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("invalid call waiting value in %s!!", __func__); return; } @@ -85,8 +95,13 @@ static void query_call_forwarding_option_append(DBusMessageIter* iter, void* use int option; int cls; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid call forwarding option !!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("invalid call forwarding option in %s!!", __func__); return; } @@ -104,8 +119,13 @@ static void set_call_forwarding_option_append(DBusMessageIter* iter, void* user_ int cls; char* number; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid call forwarding option !!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("invalid call forwarding option in %s!!", __func__); return; } @@ -125,8 +145,15 @@ static void cb_request_param_append(DBusMessageIter* iter, void* user_data) DBusMessageIter value; param = user_data; - if (param == NULL || param->result == NULL) + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("param result in %s is null", __func__); return; + } set_property_param = param->result->data; dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &set_property_param->key); @@ -146,8 +173,15 @@ static void cb_change_passwd_append(DBusMessageIter* iter, void* user_data) char* new_passwd; param = user_data; - if (param == NULL || param->result == NULL) + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); return; + } + + if (param->result == NULL) { + tapi_log_error("param result in %s is null", __func__); + return; + } change_passwd_param = param->result->data; old_passwd = change_passwd_param->old_passwd; @@ -163,8 +197,15 @@ static void disable_all_cb_param_append(DBusMessageIter* iter, void* user_data) tapi_async_handler* param; param = user_data; - if (param == NULL || param->result == NULL) + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("param result in %s is null", __func__); return; + } disable_all_cb_param = param->result->data; dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &disable_all_cb_param); @@ -176,8 +217,15 @@ static void disable_all_incoming_param_append(DBusMessageIter* iter, void* user_ tapi_async_handler* param; param = user_data; - if (param == NULL || param->result == NULL) + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("param result in %s is null", __func__); return; + } disable_all_incoming_param = param->result->data; dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &disable_all_incoming_param); @@ -189,8 +237,15 @@ static void disable_all_outgoing_param_append(DBusMessageIter* iter, void* user_ tapi_async_handler* param; param = user_data; - if (param == NULL || param->result == NULL) + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); return; + } + + if (param->result == NULL) { + tapi_log_error("param result in %s is null", __func__); + return; + } disable_all_outgoing_param = param->result->data; dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &disable_all_outgoing_param); @@ -202,8 +257,15 @@ static void ss_initiate_param_append(DBusMessageIter* iter, void* user_data) char* ss_initiate_param; param = user_data; - if (param == NULL || param->result == NULL) + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("param result in %s is null", __func__); return; + } ss_initiate_param = param->result->data; dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &ss_initiate_param); @@ -215,8 +277,15 @@ static void send_ussd_param_append(DBusMessageIter* iter, void* user_data) char* send_ussd_param; param = user_data; - if (param == NULL || param->result == NULL) + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("param result in %s is null", __func__); return; + } send_ussd_param = param->result->data; dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &send_ussd_param); @@ -228,8 +297,15 @@ static void enable_fdn_param_append(DBusMessageIter* iter, void* user_data) char* passwd; param = user_data; - if (param == NULL || param->result == NULL) + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); return; + } + + if (param->result == NULL) { + tapi_log_error("param result in %s is null", __func__); + return; + } passwd = param->result->data; dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &passwd); @@ -333,20 +409,26 @@ static void method_call_complete(DBusMessage* message, void* user_data) tapi_async_function cb; DBusError err; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s error %s: %s \n", __func__, err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; @@ -386,30 +468,39 @@ static void call_forwarding_query_complete(DBusMessage* message, void* user_data DBusError err; tapi_call_forward_info* cf_condition; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return; + } cf_condition = malloc(sizeof(tapi_call_forward_info)); - if (cf_condition == NULL) + if (cf_condition == NULL) { + tapi_log_error("cf_condition in %s is null", __func__); return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s error %s: %s \n", __func__, err.name, err.message); + tapi_log_error("error from mesage in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &args) == false) { + tapi_log_error("dbus message iter init fail in %s", __func__); ar->status = ERROR; goto done; } @@ -447,33 +538,40 @@ static void ss_initiate_complete(DBusMessage* message, void* user_data) DBusError err; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { + tapi_log_error("message iter init failed in %s", __func__); ar->status = ERROR; goto done; } info = malloc(sizeof(tapi_ss_initiate_info)); if (info == NULL) { - tapi_log_error("no memory ... \n"); + tapi_log_error("info in %s is null", __func__); ar->status = ERROR; goto done; } @@ -516,26 +614,33 @@ static void ss_send_ussd_cb(DBusMessage* message, void* user_data) char* response; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { + tapi_log_error("message iter init failed in %s", __func__); ar->status = ERROR; goto done; } @@ -559,21 +664,31 @@ static void query_fdn_cb(DBusMessage* message, void* user_data) DBusError err; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); + return; + } + + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { + tapi_log_error("message iter init failed in %s", __func__); ar->status = ERROR; goto done; } @@ -595,21 +710,31 @@ static void query_call_waiting_cb(DBusMessage* message, void* user_data) DBusError err; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); + return; + } + + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { + tapi_log_error("message iter init failed in %s", __func__); ar->status = ERROR; goto done; } @@ -631,21 +756,31 @@ static void query_clir_cb(DBusMessage* message, void* user_data) DBusError err; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return; + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { + tapi_log_error("message iter init failed in %s", __func__); ar->status = ERROR; goto done; } @@ -687,30 +822,38 @@ static int call_barring_property_changed(DBusConnection* connection, DBusError err; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return false; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return false; + } cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return false; + } if (ar->msg_id != MSG_CALL_BARRING_PROPERTY_CHANGE_IND) { + tapi_log_error("msg id in %s is invalid", __func__); return false; } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { + tapi_log_error("message iter init failed in %s", __func__); ar->status = ERROR; goto done; } @@ -719,7 +862,7 @@ static int call_barring_property_changed(DBusConnection* connection, cb_value = malloc(sizeof(tapi_call_barring_info)); if (cb_value == NULL) { - tapi_log_error("no memory ... \n"); + tapi_log_error("cb_value in %s is null", __func__); ar->status = ERROR; goto done; } @@ -766,30 +909,38 @@ static int ussd_state_changed(DBusConnection* connection, char* ussd_state; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return false; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return false; + } cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return false; + } if (ar->msg_id != MSG_USSD_PROPERTY_CHANGE_IND) { + tapi_log_error("msg id in %s is invalid", __func__); return false; } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; } if (dbus_message_iter_init(message, &iter) == false) { + tapi_log_error("message iter init failed in %s", __func__); ar->status = ERROR; goto done; } @@ -815,12 +966,12 @@ static bool is_ussd_signal_message(DBusMessage* message, DBusMessageIter* iter, int msg_type) { if (!dbus_message_iter_init(message, iter)) { - tapi_log_error("ussd_signal message has no param"); + tapi_log_error("message iter init failed in %s", __func__); return false; } if (dbus_message_iter_get_arg_type(iter) != msg_type) { - tapi_log_error("ussd_signal param is not right"); + tapi_log_error("arg type in %s is invalid", __func__); return false; } @@ -836,16 +987,22 @@ static int ussd_notification_received(DBusConnection* connection, DBusMessageIter iter; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return false; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return false; + } cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return false; + } if (is_ussd_signal_message(message, &iter, DBUS_TYPE_STRING)) { char* notification_message; @@ -869,16 +1026,22 @@ static int ussd_request_received(DBusConnection* connection, DBusMessageIter iter; handler = user_data; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return false; + } ar = handler->result; - if (ar == NULL) + if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); return false; + } cb = handler->cb_function; - if (cb == NULL) + if (cb == NULL) { + tapi_log_error("callback in %s is null", __func__); return false; + } if (is_ussd_signal_message(message, &iter, DBUS_TYPE_STRING)) { char* request_message; @@ -932,22 +1095,36 @@ int tapi_ss_initiate_service(tapi_context context, int slot_id, int event_id, report_data_logging_for_ss(ctx, "ss:ussd:request", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) || command == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (command == NULL) { + tapi_log_error("command in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -961,7 +1138,7 @@ int tapi_ss_initiate_service(tapi_context context, int slot_id, int event_id, if (!g_dbus_proxy_method_call(proxy, "Initiate", ss_initiate_param_append, ss_initiate_complete, handler, handler_free)) { report_data_logging_for_ss(ctx, "ss:ussd:request", "dbus method fail"); - tapi_log_error("failed to initiate service \n"); + tapi_log_error("method call fail in %s", __func__); handler_free(handler); return -EINVAL; } @@ -980,22 +1157,31 @@ int tapi_ss_request_call_barring(tapi_context context, int slot_id, int event_id report_data_logging_for_ss(ctx, "ss:request callbarring", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_BARRING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1008,7 +1194,7 @@ int tapi_ss_request_call_barring(tapi_context context, int slot_id, int event_id if (!g_dbus_proxy_method_call(proxy, "GetProperties", NULL, method_call_complete, handler, handler_free)) { report_data_logging_for_ss(ctx, "ss:request callbarring", "dbus method fail"); - tapi_log_error("failed to request callbarring \n"); + tapi_log_error("method call fail in %s", __func__); handler_free(handler); return -EINVAL; } @@ -1030,23 +1216,41 @@ int tapi_ss_set_call_barring_option(tapi_context context, int slot_id, int event report_data_logging_for_ss(ctx, "ss:set callbarring", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || facility == NULL || pin2 == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (facility == NULL) { + tapi_log_error("facility in %s is null", __func__); + return -EINVAL; + } + + if (pin2 == NULL) { + tapi_log_error("pin2 in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_BARRING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1054,6 +1258,7 @@ int tapi_ss_set_call_barring_option(tapi_context context, int slot_id, int event param = malloc(sizeof(cb_request_param)); if (param == NULL) { + tapi_log_error("param in %s is null", __func__); free(handler); free(ar); return -ENOMEM; @@ -1092,7 +1297,7 @@ int tapi_ss_set_call_barring_option(tapi_context context, int slot_id, int event if (!g_dbus_proxy_method_call(proxy, "SetProperty", cb_request_param_append, method_call_complete, handler, ss_event_data_free)) { report_data_logging_for_ss(ctx, "ss:set callbarring", "dbus method fail"); - tapi_log_error("failed to set callbarring \n"); + tapi_log_error("method call fail in %s", __func__); ss_event_data_free(handler); return -EINVAL; } @@ -1106,16 +1311,29 @@ int tapi_ss_get_call_barring_option(tapi_context context, int slot_id, const cha DBusMessageIter iter; GDBusProxy* proxy; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) || service_type == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (service_type == NULL) { + tapi_log_error("service_type in %s is null", __func__); + return -EINVAL; + } + + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_BARRING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1124,6 +1342,7 @@ int tapi_ss_get_call_barring_option(tapi_context context, int slot_id, const cha return OK; } + tapi_log_error("get property failed in %s", __func__); return -EINVAL; } @@ -1138,23 +1357,41 @@ int tapi_ss_change_call_barring_password(tapi_context context, int slot_id, int report_data_logging_for_ss(ctx, "ss:set callbarring:change password", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || old_passwd == NULL || new_passwd == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (old_passwd == NULL) { + tapi_log_error("old_passwd in %s is null", __func__); + return -EINVAL; + } + + if (new_passwd == NULL) { + tapi_log_error("new_passwd in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_BARRING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1162,6 +1399,7 @@ int tapi_ss_change_call_barring_password(tapi_context context, int slot_id, int param = malloc(sizeof(cb_change_passwd_param)); if (param == NULL) { + tapi_log_error("param in %s is null", __func__); free(handler); free(ar); return -ENOMEM; @@ -1178,7 +1416,7 @@ int tapi_ss_change_call_barring_password(tapi_context context, int slot_id, int if (!g_dbus_proxy_method_call(proxy, "ChangePassword", cb_change_passwd_append, method_call_complete, handler, ss_event_data_free)) { report_data_logging_for_ss(ctx, "ss:set callbarring:change password", "dbus method fail"); - tapi_log_error("failed to change callbarring passward \n"); + tapi_log_error("method call fail in %s", __func__); ss_event_data_free(handler); return -EINVAL; } @@ -1196,22 +1434,36 @@ int tapi_ss_disable_all_call_barrings(tapi_context context, int slot_id, int eve report_data_logging_for_ss(ctx, "ss:set callbarring:disable all", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) || passwd == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (passwd == NULL) { + tapi_log_error("passwd in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_BARRING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1225,7 +1477,7 @@ int tapi_ss_disable_all_call_barrings(tapi_context context, int slot_id, int eve if (!g_dbus_proxy_method_call(proxy, "DisableAll", disable_all_cb_param_append, method_call_complete, handler, handler_free)) { report_data_logging_for_ss(ctx, "ss:set callbarring:disable all", "dbus method fail"); - tapi_log_error("failed to disable all callbarring \n"); + tapi_log_error("method call fail in %s", __func__); handler_free(handler); return -EINVAL; } @@ -1243,22 +1495,36 @@ int tapi_ss_disable_all_incoming(tapi_context context, int slot_id, report_data_logging_for_ss(ctx, "ss:set callbarring:disable all incoming", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) || passwd == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (passwd == NULL) { + tapi_log_error("passwd in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_BARRING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1272,7 +1538,7 @@ int tapi_ss_disable_all_incoming(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "DisableAllIncoming", disable_all_incoming_param_append, method_call_complete, handler, handler_free)) { report_data_logging_for_ss(ctx, "ss:set callbarring:disable all incoming", "dbus method fail"); - tapi_log_error("failed to disable all incoming \n"); + tapi_log_error("method call fail in %s", __func__); handler_free(handler); return -EINVAL; } @@ -1290,22 +1556,36 @@ int tapi_ss_disable_all_outgoing(tapi_context context, int slot_id, report_data_logging_for_ss(ctx, "ss:set callbarring:disable all outgoing", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) || passwd == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (passwd == NULL) { + tapi_log_error("passwd in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_BARRING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1319,7 +1599,7 @@ int tapi_ss_disable_all_outgoing(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "DisableAllOutgoing", disable_all_outgoing_param_append, method_call_complete, handler, handler_free)) { report_data_logging_for_ss(ctx, "ss:set callbarring:disable all outgoing", "dbus method fail"); - tapi_log_error("failed to disable all outgoing \n"); + tapi_log_error("method call fail in %s", __func__); handler_free(handler); return -EINVAL; } @@ -1338,26 +1618,36 @@ int tapi_ss_query_call_forwarding_option(tapi_context context, int slot_id, int report_data_logging_for_ss(ctx, "ss:query call forwarding", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); return -EINVAL; } if (option < CF_REASON_UNCONDITIONAL || option > CF_REASON_NOT_REACHABLE) { + tapi_log_error("option %d in %s is invalid", option, __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_FORWARDING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1372,7 +1662,7 @@ int tapi_ss_query_call_forwarding_option(tapi_context context, int slot_id, int query_call_forwarding_option_append, call_forwarding_query_complete, handler, handler_free)) { report_data_logging_for_ss(ctx, "ss:query call forwarding", "dbus method fail"); - tapi_log_error("failed to request callforwarding \n"); + tapi_log_error("method call fail in %s", __func__); handler_free(handler); return -EINVAL; } @@ -1391,29 +1681,46 @@ int tapi_ss_set_call_forwarding_option(tapi_context context, int slot_id, int ev report_data_logging_for_ss(ctx, "ss:set call forwarding", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) || number == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (number == NULL) { + tapi_log_error("number in %s is null", __func__); return -EINVAL; } if (option < CF_REASON_UNCONDITIONAL || option > CF_REASON_NOT_REACHABLE) { + tapi_log_error("option %d in %s is invalid", option, __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_FORWARDING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1427,6 +1734,7 @@ int tapi_ss_set_call_forwarding_option(tapi_context context, int slot_id, int ev if (!g_dbus_proxy_method_call(proxy, "SetCallForwarding", set_call_forwarding_option_append, method_call_complete, handler, handler_free)) { + tapi_log_error("method call fail in %s", __func__); report_data_logging_for_ss(ctx, "ss:set call forwarding", "dbus method fail"); handler_free(handler); return -EINVAL; @@ -1444,16 +1752,24 @@ int tapi_get_ussd_state(tapi_context context, int slot_id, char** out) report_data_logging_for_ss(ctx, "ss:ussd:get state", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1462,6 +1778,7 @@ int tapi_get_ussd_state(tapi_context context, int slot_id, char** out) return OK; } + tapi_log_error("get property fail in %s", __func__); report_data_logging_for_ss(ctx, "ss:ussd:get state", "dbus method fail"); return -EINVAL; } @@ -1476,22 +1793,36 @@ int tapi_ss_send_ussd(tapi_context context, int slot_id, int event_id, char* rep report_data_logging_for_ss(ctx, "ss:ussd:response", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) || reply == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (reply == NULL) { + tapi_log_error("reply in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1505,7 +1836,7 @@ int tapi_ss_send_ussd(tapi_context context, int slot_id, int event_id, char* rep if (!g_dbus_proxy_method_call(proxy, "Respond", send_ussd_param_append, ss_send_ussd_cb, handler, handler_free)) { report_data_logging_for_ss(ctx, "ss:ussd:response", "dbus method fail"); - tapi_log_error("failed to send ussd \n"); + tapi_log_error("method call fail in %s", __func__); handler_free(handler); return -EINVAL; } @@ -1523,22 +1854,31 @@ int tapi_ss_cancel_ussd(tapi_context context, int slot_id, int event_id, report_data_logging_for_ss(ctx, "ss:ussd:cancel", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SS]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1551,7 +1891,7 @@ int tapi_ss_cancel_ussd(tapi_context context, int slot_id, int event_id, if (!g_dbus_proxy_method_call(proxy, "Cancel", NULL, method_call_complete, handler, handler_free)) { report_data_logging_for_ss(ctx, "ss:ussd:cancel", "dbus method fail"); - tapi_log_error("failed to cancel ussd \n"); + tapi_log_error("method call fail in %s", __func__); handler_free(handler); return -EINVAL; } @@ -1570,25 +1910,36 @@ int tapi_ss_set_call_waiting(tapi_context context, int slot_id, int event_id, bo report_data_logging_for_ss(ctx, "ss:set call waiting", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_SETTING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1601,6 +1952,7 @@ int tapi_ss_set_call_waiting(tapi_context context, int slot_id, int event_id, bo if (!g_dbus_proxy_method_call(proxy, "SetCallWaiting", set_call_waiting_append, method_call_complete, handler, handler_free)) { + tapi_log_error("method call fail in %s", __func__); report_data_logging_for_ss(ctx, "ss:set call waiting", "dbus method fail"); handler_free(handler); return -EINVAL; @@ -1619,25 +1971,36 @@ int tapi_ss_get_call_waiting(tapi_context context, int slot_id, int event_id, report_data_logging_for_ss(ctx, "ss:get call waiting", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_SETTING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1649,6 +2012,7 @@ int tapi_ss_get_call_waiting(tapi_context context, int slot_id, int event_id, if (!g_dbus_proxy_method_call(proxy, "GetCallWaiting", NULL, query_call_waiting_cb, handler, handler_free)) { + tapi_log_error("method call fail in %s", __func__); report_data_logging_for_ss(ctx, "ss:get call waiting", "dbus method fail"); handler_free(handler); return -EINVAL; @@ -1667,16 +2031,24 @@ int tapi_ss_get_calling_line_presentation_info(tapi_context context, int slot_id report_data_logging_for_ss(ctx, "ss:get clip", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_SETTING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1686,6 +2058,7 @@ int tapi_ss_get_calling_line_presentation_info(tapi_context context, int slot_id return OK; } + tapi_log_error("get property failed in %s", __func__); return -EINVAL; } @@ -1700,25 +2073,36 @@ int tapi_ss_set_calling_line_restriction(tapi_context context, int slot_id, int report_data_logging_for_ss(ctx, "ss:set clir", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_SETTING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1731,6 +2115,7 @@ int tapi_ss_set_calling_line_restriction(tapi_context context, int slot_id, int if (!g_dbus_proxy_method_call(proxy, "SetClir", set_clir_append, method_call_complete, handler, handler_free)) { + tapi_log_error("method call fail in %s", __func__); report_data_logging_for_ss(ctx, "ss:set clir", "dbus method fail"); handler_free(handler); return -EINVAL; @@ -1749,25 +2134,36 @@ int tapi_ss_get_calling_line_restriction_info(tapi_context context, int slot_id, report_data_logging_for_ss(ctx, "ss:get clir", "NA"); - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_CALL_SETTING]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1779,6 +2175,7 @@ int tapi_ss_get_calling_line_restriction_info(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "GetClir", NULL, query_clir_cb, handler, handler_free)) { + tapi_log_error("method call fail in %s", __func__); report_data_logging_for_ss(ctx, "ss:get clir", "dbus method fail"); handler_free(handler); return -EINVAL; @@ -1795,22 +2192,36 @@ int tapi_ss_enable_fdn(tapi_context context, int slot_id, int event_id, tapi_async_result* ar; GDBusProxy* proxy; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) || passwd == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (passwd == NULL) { + tapi_log_error("passwd in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1823,7 +2234,7 @@ int tapi_ss_enable_fdn(tapi_context context, int slot_id, int event_id, if (!g_dbus_proxy_method_call(proxy, enable ? "EnableFdn" : "DisableFdn", enable_fdn_param_append, method_call_complete, handler, handler_free)) { - tapi_log_error("failed to enable fdn \n"); + tapi_log_error("method call fail in %s", __func__); handler_free(handler); return -EINVAL; } @@ -1839,22 +2250,31 @@ int tapi_ss_query_fdn(tapi_context context, int slot_id, int event_id, tapi_async_result* ar; GDBusProxy* proxy; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_SIM]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1866,7 +2286,7 @@ int tapi_ss_query_fdn(tapi_context context, int slot_id, int event_id, if (!g_dbus_proxy_method_call(proxy, "QueryFdn", NULL, query_fdn_cb, handler, handler_free)) { - tapi_log_error("failed to query fdn \n"); + tapi_log_error("method call fail in %s", __func__); handler_free(handler); return -EINVAL; } @@ -1883,25 +2303,38 @@ int tapi_ss_register(tapi_context context, const char* modem_path; int watch_id = 0; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || msg < MSG_CALL_BARRING_PROPERTY_CHANGE_IND || msg > MSG_USSD_PROPERTY_CHANGE_IND) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("slot id %d in %s is invalid", slot_id, __func__); + return -EINVAL; + } + + if (msg < MSG_CALL_BARRING_PROPERTY_CHANGE_IND || msg > MSG_USSD_PROPERTY_CHANGE_IND) { + tapi_log_error("msg %d in %s is invalid", msg, __func__); return -EINVAL; } modem_path = tapi_utils_get_modem_path(slot_id); if (modem_path == NULL) { - tapi_log_error("no available modem ...\n"); + tapi_log_error("no available modem in %s", __func__); return -EIO; } handler = malloc(sizeof(tapi_async_handler)); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return -ENOMEM; + } handler->cb_function = p_handle; ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(handler); return -ENOMEM; } @@ -1937,6 +2370,7 @@ int tapi_ss_register(tapi_context context, } if (watch_id == 0) { + tapi_log_error("add signal watch fail in %s, msg_id: %d", __func__, (int)msg); handler_free(handler); return -EINVAL; } @@ -1947,11 +2381,20 @@ int tapi_ss_register(tapi_context context, int tapi_ss_unregister(tapi_context context, int watch_id) { dbus_context* ctx = context; - if (ctx == NULL || watch_id <= 0) + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; + } - if (!g_dbus_remove_watch(ctx->connection, watch_id)) + if (watch_id <= 0) { + tapi_log_error("watch id %d in %s is invalid", watch_id, __func__); return -EINVAL; + } + + if (!g_dbus_remove_watch(ctx->connection, watch_id)) { + tapi_log_error("remove signal watch fail in %s, watch_id: %d", __func__, watch_id); + return -EINVAL; + } return OK; } diff --git a/src/tapi_stk.c b/src/tapi_stk.c index a38dd39..ad22665 100644 --- a/src/tapi_stk.c +++ b/src/tapi_stk.c @@ -182,15 +182,25 @@ static void method_call_complete(DBusMessage* message, void* user_data) tapi_async_function cb; DBusError err; - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return; + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return; + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return; + } dbus_error_init(&err); if (dbus_set_error_from_message(&err, message) == true) { - tapi_log_error("%s error %s: %s \n", __func__, err.name, err.message); + tapi_log_error("error from message in %s, error %s: %s", + __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; goto done; @@ -205,9 +215,18 @@ static void method_call_complete(DBusMessage* message, void* user_data) static bool stk_agent_dbus_pending_reply(DBusConnection* conn, DBusMessage** msg, DBusMessage* reply) { + if (conn == NULL) { + tapi_log_error("conn in %s is null", __func__); + return false; + } - if (conn == NULL || msg == NULL || reply == NULL) { - tapi_log_error("failed to send message ...\n"); + if (msg == NULL) { + tapi_log_error("msg in %s is null", __func__); + return false; + } + + if (reply == NULL) { + tapi_log_error("reply in %s is null", __func__); return false; } @@ -224,8 +243,13 @@ static void stk_agent_register_param_append(DBusMessageIter* iter, void* user_da tapi_async_handler* param = user_data; char* agent_id; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid pin argument!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("param result in %s is null", __func__); return; } @@ -240,8 +264,13 @@ static void stk_select_item_param_append(DBusMessageIter* iter, void* user_data) unsigned char item; char* agent_id; - if (param == NULL || param->result == NULL) { - tapi_log_error("invalid stk input argument!"); + if (param == NULL) { + tapi_log_error("param in %s is null", __func__); + return; + } + + if (param->result == NULL) { + tapi_log_error("param result in %s is null", __func__); return; } @@ -300,15 +329,25 @@ static DBusMessage* stk_agent_release(DBusConnection* conn, tapi_log_info("stk agent release method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } reply = dbus_message_new_method_return(msg); ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; @@ -340,21 +379,32 @@ static DBusMessage* stk_agent_cancel(DBusConnection* conn, tapi_log_info("stk agent cancel method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); dbus_message_unref(ctx->pending); ctx->pending = NULL; } @@ -381,11 +431,20 @@ static DBusMessage* stk_agent_show_information(DBusConnection* conn, tapi_log_info("stk agent display text method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_DISPLAY_TEXT_IND; @@ -393,12 +452,14 @@ static DBusMessage* stk_agent_show_information(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -406,6 +467,7 @@ static DBusMessage* stk_agent_show_information(DBusConnection* conn, params = malloc(sizeof(tapi_stk_display_info_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -415,6 +477,7 @@ static DBusMessage* stk_agent_show_information(DBusConnection* conn, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_BOOLEAN, ¶ms->urgent, DBUS_TYPE_INVALID)) { + tapi_log_error("failed to get args in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -445,11 +508,20 @@ static DBusMessage* stk_agent_handle_request_digit(DBusConnection* conn, tapi_log_info("stk agent request digit method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_REQUEST_DIGIT_IND; @@ -457,12 +529,14 @@ static DBusMessage* stk_agent_handle_request_digit(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -470,6 +544,7 @@ static DBusMessage* stk_agent_handle_request_digit(DBusConnection* conn, params = malloc(sizeof(tapi_stk_request_key_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -478,6 +553,7 @@ static DBusMessage* stk_agent_handle_request_digit(DBusConnection* conn, if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->alpha, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_INVALID)) { + tapi_log_error("failed to get args in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -508,11 +584,20 @@ static DBusMessage* stk_agent_handle_request_key(DBusConnection* conn, tapi_log_info("stk agent request key method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_REQUEST_KEY_IND; @@ -520,12 +605,14 @@ static DBusMessage* stk_agent_handle_request_key(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -533,6 +620,7 @@ static DBusMessage* stk_agent_handle_request_key(DBusConnection* conn, params = malloc(sizeof(tapi_stk_request_key_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -541,6 +629,7 @@ static DBusMessage* stk_agent_handle_request_key(DBusConnection* conn, if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->alpha, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_INVALID)) { + tapi_log_error("failed to get args in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -571,11 +660,20 @@ static DBusMessage* stk_agent_handle_request_confirmation(DBusConnection* conn, tapi_log_info("stk agent request confirmation is method\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_REQUEST_CONFIRMATION_IND; @@ -583,12 +681,14 @@ static DBusMessage* stk_agent_handle_request_confirmation(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -596,6 +696,7 @@ static DBusMessage* stk_agent_handle_request_confirmation(DBusConnection* conn, params = malloc(sizeof(tapi_stk_request_key_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -604,6 +705,7 @@ static DBusMessage* stk_agent_handle_request_confirmation(DBusConnection* conn, if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->alpha, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_INVALID)) { + tapi_log_error("failed to get args in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -634,11 +736,20 @@ static DBusMessage* stk_agent_handle_request_input(DBusConnection* conn, tapi_log_info("stk agent request input method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_REQUEST_INPUT_IND; @@ -646,12 +757,14 @@ static DBusMessage* stk_agent_handle_request_input(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -659,6 +772,7 @@ static DBusMessage* stk_agent_handle_request_input(DBusConnection* conn, params = malloc(sizeof(tapi_stk_request_input_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -671,6 +785,7 @@ static DBusMessage* stk_agent_handle_request_input(DBusConnection* conn, DBUS_TYPE_BYTE, ¶ms->max_len, DBUS_TYPE_BOOLEAN, ¶ms->hide_typing, DBUS_TYPE_INVALID)) { + tapi_log_error("failed to get args in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -701,11 +816,20 @@ static DBusMessage* stk_agent_handle_request_digits(DBusConnection* conn, tapi_log_info("stk agent request input digits is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_REQUEST_DIGITS_IND; @@ -713,12 +837,14 @@ static DBusMessage* stk_agent_handle_request_digits(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -726,6 +852,7 @@ static DBusMessage* stk_agent_handle_request_digits(DBusConnection* conn, params = malloc(sizeof(tapi_stk_request_input_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -738,6 +865,7 @@ static DBusMessage* stk_agent_handle_request_digits(DBusConnection* conn, DBUS_TYPE_BYTE, ¶ms->max_len, DBUS_TYPE_BOOLEAN, ¶ms->hide_typing, DBUS_TYPE_INVALID)) { + tapi_log_error("failed to get args in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -768,11 +896,20 @@ static DBusMessage* stk_agent_handle_play_tone(DBusConnection* conn, tapi_log_info("stk agent play tone method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_PLAY_TONE_IND; @@ -780,12 +917,14 @@ static DBusMessage* stk_agent_handle_play_tone(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -793,6 +932,7 @@ static DBusMessage* stk_agent_handle_play_tone(DBusConnection* conn, params = malloc(sizeof(tapi_stk_play_tone_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -802,6 +942,7 @@ static DBusMessage* stk_agent_handle_play_tone(DBusConnection* conn, DBUS_TYPE_STRING, ¶ms->info, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_INVALID)) { + tapi_log_error("failed to get args in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -832,11 +973,20 @@ static DBusMessage* stk_agent_handle_loop_tone(DBusConnection* conn, tapi_log_info("stk agent loop tone method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } + + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_LOOP_TONE_IND; @@ -844,12 +994,14 @@ static DBusMessage* stk_agent_handle_loop_tone(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -857,6 +1009,7 @@ static DBusMessage* stk_agent_handle_loop_tone(DBusConnection* conn, params = malloc(sizeof(tapi_stk_play_tone_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -866,6 +1019,7 @@ static DBusMessage* stk_agent_handle_loop_tone(DBusConnection* conn, DBUS_TYPE_STRING, ¶ms->info, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_INVALID)) { + tapi_log_error("failed to get args in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -901,11 +1055,20 @@ static DBusMessage* stk_agent_handle_request_selection(DBusConnection* conn, tapi_log_info("stk agent request selection method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_REQUEST_SELECTION_IND; @@ -913,7 +1076,7 @@ static DBusMessage* stk_agent_handle_request_selection(DBusConnection* conn, reply = NULL; dbus_error_init(&err); if (dbus_set_error_from_message(&err, msg) == true) { - tapi_log_error("%s: %s\n", err.name, err.message); + tapi_log_error("error from message in %s, %s: %s", __func__, err.name, err.message); dbus_error_free(&err); ar->status = ERROR; reply = stk_agent_error_failed(msg); @@ -921,6 +1084,7 @@ static DBusMessage* stk_agent_handle_request_selection(DBusConnection* conn, } if (dbus_message_iter_init(msg, &iter) == false) { + tapi_log_error("dbus message iter init failed in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -928,12 +1092,14 @@ static DBusMessage* stk_agent_handle_request_selection(DBusConnection* conn, ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -941,6 +1107,7 @@ static DBusMessage* stk_agent_handle_request_selection(DBusConnection* conn, params = malloc(sizeof(tapi_stk_request_selection_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -1007,11 +1174,20 @@ static DBusMessage* stk_agent_handle_request_quick_digit(DBusConnection* conn, tapi_log_info("stk agent request quick digit method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_REQUEST_QUICK_DIGIT_IND; @@ -1019,12 +1195,14 @@ static DBusMessage* stk_agent_handle_request_quick_digit(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -1032,6 +1210,7 @@ static DBusMessage* stk_agent_handle_request_quick_digit(DBusConnection* conn, params = malloc(sizeof(tapi_stk_request_key_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -1040,6 +1219,7 @@ static DBusMessage* stk_agent_handle_request_quick_digit(DBusConnection* conn, if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->alpha, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_INVALID)) { + tapi_log_error("dbus message get args failed in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -1070,11 +1250,20 @@ static DBusMessage* stk_agent_confirm_call_setup(DBusConnection* conn, tapi_log_info("stk agent confirm call setup method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_CONFIRM_CALL_SETUP_IND; @@ -1082,12 +1271,14 @@ static DBusMessage* stk_agent_confirm_call_setup(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -1095,6 +1286,7 @@ static DBusMessage* stk_agent_confirm_call_setup(DBusConnection* conn, params = malloc(sizeof(tapi_stk_request_key_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -1103,6 +1295,7 @@ static DBusMessage* stk_agent_confirm_call_setup(DBusConnection* conn, if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->alpha, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_INVALID)) { + tapi_log_error("dbus message get args failed in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -1133,11 +1326,20 @@ static DBusMessage* stk_agent_display_action_information(DBusConnection* conn, tapi_log_info("stk agent display action information method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } + + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_DISPLAY_ACTION_INFORMATION_IND; @@ -1145,12 +1347,14 @@ static DBusMessage* stk_agent_display_action_information(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -1158,6 +1362,7 @@ static DBusMessage* stk_agent_display_action_information(DBusConnection* conn, params = malloc(sizeof(tapi_stk_display_info_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -1166,6 +1371,7 @@ static DBusMessage* stk_agent_display_action_information(DBusConnection* conn, if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->info, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_INVALID)) { + tapi_log_error("dbus message get args failed in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -1196,11 +1402,20 @@ static DBusMessage* stk_agent_confirm_launch_browser(DBusConnection* conn, tapi_log_info("stk agent confirm launch browser method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } + + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_CONFIRM_LAUNCH_BROWSER_IND; @@ -1208,12 +1423,14 @@ static DBusMessage* stk_agent_confirm_launch_browser(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -1221,6 +1438,7 @@ static DBusMessage* stk_agent_confirm_launch_browser(DBusConnection* conn, params = malloc(sizeof(tapi_stk_confirm_launch_browser_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -1230,6 +1448,7 @@ static DBusMessage* stk_agent_confirm_launch_browser(DBusConnection* conn, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_STRING, ¶ms->url, DBUS_TYPE_INVALID)) { + tapi_log_error("dbus message get args failed in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -1260,11 +1479,20 @@ static DBusMessage* stk_agent_display_action(DBusConnection* conn, tapi_log_info("stk agent display action method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_DISPLAY_ACTION_IND; @@ -1272,12 +1500,14 @@ static DBusMessage* stk_agent_display_action(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -1285,6 +1515,7 @@ static DBusMessage* stk_agent_display_action(DBusConnection* conn, params = malloc(sizeof(tapi_stk_display_info_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -1293,6 +1524,7 @@ static DBusMessage* stk_agent_display_action(DBusConnection* conn, if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->info, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_INVALID)) { + tapi_log_error("dbus message get args failed in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -1323,11 +1555,20 @@ static DBusMessage* stk_agent_confirm_open_channel(DBusConnection* conn, tapi_log_info("stk agent confirm open channel method is called\n"); - if (handler == NULL) + if (handler == NULL) { + tapi_log_error("handler in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } - if ((ar = handler->result) == NULL || (cb = handler->cb_function) == NULL) + if ((ar = handler->result) == NULL) { + tapi_log_error("async result in %s is null", __func__); return stk_agent_error_not_implemented(msg); + } + + if ((cb = handler->cb_function) == NULL) { + tapi_log_error("callback in %s is null", __func__); + return stk_agent_error_not_implemented(msg); + } ar->msg_id = MSG_STK_AGENT_CONFIRM_OPEN_CHANNEL_IND; @@ -1335,12 +1576,14 @@ static DBusMessage* stk_agent_confirm_open_channel(DBusConnection* conn, reply = NULL; ctx = ar->data; if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_failed(msg); goto done; } if (ctx->pending) { + tapi_log_error("context in %s is busy", __func__); ar->status = ERROR; reply = stk_agent_error_busy(msg); goto done; @@ -1348,6 +1591,7 @@ static DBusMessage* stk_agent_confirm_open_channel(DBusConnection* conn, params = malloc(sizeof(tapi_stk_request_key_params)); if (params == NULL) { + tapi_log_error("params in %s is null", __func__); ar->status = ERROR; reply = stk_agent_error_not_implemented(msg); goto done; @@ -1356,6 +1600,7 @@ static DBusMessage* stk_agent_confirm_open_channel(DBusConnection* conn, if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, ¶ms->alpha, DBUS_TYPE_BYTE, ¶ms->icon_id, DBUS_TYPE_INVALID)) { + tapi_log_error("dbus message get args failed in %s", __func__); ar->status = ERROR; reply = stk_agent_error_invalid_args(msg); goto done; @@ -1385,16 +1630,25 @@ int tapi_stk_agent_interface_register(tapi_context context, int slot_id, dbus_context* ctx = context; tapi_async_result* ar; - if (ctx == NULL || agent_id == NULL) + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; + } + + if (agent_id == NULL) { + tapi_log_error("agent_id in %s is null", __func__); + return -EINVAL; + } user_data = malloc(sizeof(tapi_async_handler)); if (user_data == NULL) { + tapi_log_error("user_data in %s is null", __func__); return -ENOMEM; } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(user_data); return -ENOMEM; } @@ -1403,7 +1657,8 @@ int tapi_stk_agent_interface_register(tapi_context context, int slot_id, user_data->result = ar; user_data->cb_function = p_handle; - tapi_log_debug("starting stk agent interface slot : %d, agent id : %s\n", slot_id, agent_id); + tapi_log_debug("starting stk agent interface in %s, slot : %d, agent id : %s", + __func__, slot_id, agent_id); if (!g_dbus_register_interface(ctx->connection, agent_id, OFONO_SIM_APP_INTERFACE, agent_methods, NULL, NULL, user_data, handler_free)) { tapi_log_error("Unable to register stk agent %s\n", agent_id); @@ -1417,13 +1672,20 @@ int tapi_stk_agent_interface_unregister(tapi_context context, char* agent_id) { dbus_context* ctx = context; - if (ctx == NULL || agent_id == NULL) + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (agent_id == NULL) { + tapi_log_error("agent_id in %s is null", __func__); return -EINVAL; + } - tapi_log_debug("stopping stk agent interface agent id : %s\n", agent_id); + tapi_log_debug("stopping stk agent interface in %s, agent id : %s", __func__, agent_id); if (!g_dbus_unregister_interface(ctx->connection, agent_id, OFONO_SIM_APP_INTERFACE)) { - tapi_log_error("Unable to unregister stk agent %s\n", agent_id); + tapi_log_error("Unable to unregister stk agent %s in %s", agent_id, __func__); return -EINVAL; } @@ -1436,7 +1698,13 @@ int tapi_stk_default_agent_interface_register(tapi_context context, int slot_id, dbus_context* ctx = context; char* agent_path; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -1455,7 +1723,13 @@ int tapi_stk_default_agent_interface_unregister(tapi_context context, int slot_i dbus_context* ctx = context; char* agent_path; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -1477,24 +1751,36 @@ int tapi_stk_agent_register(tapi_context context, int slot_id, GDBusProxy* proxy; tapi_async_result* ar; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || agent_id == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); + return -EINVAL; + } + + if (agent_id == NULL) { + tapi_log_error("agent_id in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_STK]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("proxy in %s is null", __func__); return -EIO; } user_data = malloc(sizeof(tapi_async_handler)); if (user_data == NULL) { + tapi_log_error("user_data in %s is null", __func__); return -ENOMEM; } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(user_data); return -ENOMEM; } @@ -1507,7 +1793,7 @@ int tapi_stk_agent_register(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "RegisterAgent", stk_agent_register_param_append, method_call_complete, user_data, handler_free)) { - tapi_log_error("failed to register agent\n"); + tapi_log_error("dbus method call fail in %s", __func__); handler_free(user_data); return -EINVAL; } @@ -1523,24 +1809,36 @@ int tapi_stk_agent_unregister(tapi_context context, int slot_id, GDBusProxy* proxy; tapi_async_result* ar; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || agent_id == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); + return -EINVAL; + } + + if (agent_id == NULL) { + tapi_log_error("agent_id in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_STK]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } user_data = malloc(sizeof(tapi_async_handler)); if (user_data == NULL) { + tapi_log_error("user_data in %s is null", __func__); return -ENOMEM; } ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(user_data); return -ENOMEM; } @@ -1553,7 +1851,7 @@ int tapi_stk_agent_unregister(tapi_context context, int slot_id, if (!g_dbus_proxy_method_call(proxy, "UnregisterAgent", stk_agent_register_param_append, method_call_complete, user_data, handler_free)) { - tapi_log_error("failed to unregister agent\n"); + tapi_log_error("dbus method call fail in %s", __func__); handler_free(user_data); return -EINVAL; } @@ -1567,7 +1865,13 @@ int tapi_stk_default_agent_register(tapi_context context, int slot_id, dbus_context* ctx = context; char* agent_path; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -1587,7 +1891,13 @@ int tapi_stk_default_agent_unregister(tapi_context context, int slot_id, dbus_context* ctx = context; char* agent_path; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } @@ -1610,18 +1920,30 @@ int tapi_stk_select_item(tapi_context context, int slot_id, GDBusProxy* proxy; tapi_async_result* ar; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) || agent_id == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); + return -EINVAL; + } + + if (agent_id == NULL) { + tapi_log_error("agent_id in %s is null", __func__); return -EINVAL; } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_STK]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } select_item_param = malloc(sizeof(stk_select_item_param)); if (select_item_param == NULL) { + tapi_log_error("select_item_param in %s is null", __func__); return -ENOMEM; } select_item_param->item = item; @@ -1629,6 +1951,7 @@ int tapi_stk_select_item(tapi_context context, int slot_id, ar = malloc(sizeof(tapi_async_result)); if (ar == NULL) { + tapi_log_error("async result in %s is null", __func__); free(select_item_param); return -ENOMEM; } @@ -1638,6 +1961,7 @@ int tapi_stk_select_item(tapi_context context, int slot_id, user_data = malloc(sizeof(tapi_async_handler)); if (user_data == NULL) { + tapi_log_error("user_data in %s is null", __func__); free(select_item_param); free(ar); return -ENOMEM; @@ -1648,7 +1972,7 @@ int tapi_stk_select_item(tapi_context context, int slot_id, tapi_log_info("tapi_stk_select_item item : %d, path : %s\n", item, agent_id); if (!g_dbus_proxy_method_call(proxy, "SelectItem", stk_select_item_param_append, method_call_complete, user_data, stk_event_data_free)) { - tapi_log_error("failed to select item\n"); + tapi_log_error("dbus method call fail in %s", __func__); stk_event_data_free(user_data); return -EINVAL; } @@ -1662,16 +1986,24 @@ int tapi_stk_get_idle_mode_text(tapi_context context, int slot_id, char** text) GDBusProxy* proxy; DBusMessageIter iter; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); + return -EINVAL; + } + + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_STK]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1680,6 +2012,7 @@ int tapi_stk_get_idle_mode_text(tapi_context context, int slot_id, char** text) return OK; } + tapi_log_error("dbus get property fail in %s", __func__); return ERROR; } @@ -1689,16 +2022,24 @@ int tapi_stk_get_idle_mode_icon(tapi_context context, int slot_id, char** icon) GDBusProxy* proxy; DBusMessageIter iter; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); + return -EINVAL; + } + + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_STK]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1707,6 +2048,7 @@ int tapi_stk_get_idle_mode_icon(tapi_context context, int slot_id, char** icon) return OK; } + tapi_log_error("dbus get property fail in %s", __func__); return ERROR; } @@ -1719,21 +2061,34 @@ int tapi_stk_get_main_menu(tapi_context context, int slot_id, int length, tapi_s char* text; int index; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id) - || length <= 0) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } - if (!ctx->client_ready) + if (length <= 0) { + tapi_log_error("invalid length %d in %s", length, __func__); + return -EINVAL; + } + + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_STK]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } if (!g_dbus_proxy_get_property(proxy, "MainMenu", &array)) { + tapi_log_error("dbus get property fail in %s", __func__); return -EIO; } @@ -1772,16 +2127,24 @@ int tapi_stk_get_main_menu_title(tapi_context context, int slot_id, char** title GDBusProxy* proxy; DBusMessageIter iter; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); + return -EINVAL; + } + + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_STK]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1790,6 +2153,7 @@ int tapi_stk_get_main_menu_title(tapi_context context, int slot_id, char** title return OK; } + tapi_log_error("dbus get property fail in %s", __func__); return ERROR; } @@ -1799,16 +2163,24 @@ int tapi_stk_get_main_menu_icon(tapi_context context, int slot_id, char** icon) GDBusProxy* proxy; DBusMessageIter iter; - if (ctx == NULL || !tapi_is_valid_slotid(slot_id)) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (!tapi_is_valid_slotid(slot_id)) { + tapi_log_error("invalid slot id %d in %s", slot_id, __func__); return -EINVAL; } - if (!ctx->client_ready) + if (!ctx->client_ready) { + tapi_log_error("client is not ready in %s", __func__); return -EAGAIN; + } proxy = ctx->dbus_proxy[slot_id][DBUS_PROXY_STK]; if (proxy == NULL) { - tapi_log_error("no available proxy ...\n"); + tapi_log_error("no available proxy in %s", __func__); return -EIO; } @@ -1817,6 +2189,7 @@ int tapi_stk_get_main_menu_icon(tapi_context context, int slot_id, char** icon) return OK; } + tapi_log_error("dbus get property fail in %s", __func__); return ERROR; } @@ -1825,7 +2198,18 @@ int tapi_stk_handle_agent_display_text(tapi_context context, tapi_stk_agent_oper dbus_context* ctx = context; DBusMessage* reply; - if (ctx == NULL || ctx->connection == NULL || ctx->pending == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (ctx->connection == NULL) { + tapi_log_error("connection in %s is null", __func__); + return -EINVAL; + } + + if (ctx->pending == NULL) { + tapi_log_error("pending in %s is null", __func__); return -EINVAL; } @@ -1859,7 +2243,18 @@ int tapi_stk_handle_agent_request_key(tapi_context context, dbus_context* ctx = context; DBusMessage* reply; - if (ctx == NULL || ctx->connection == NULL || ctx->pending == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (ctx->connection == NULL) { + tapi_log_error("connection in %s is null", __func__); + return -EINVAL; + } + + if (ctx->pending == NULL) { + tapi_log_error("pending in %s is null", __func__); return -EINVAL; } @@ -1895,7 +2290,18 @@ int tapi_stk_handle_agent_request_confirmation(tapi_context context, int confirm; bool flag = false; - if (ctx == NULL || ctx->connection == NULL || ctx->pending == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (ctx->connection == NULL) { + tapi_log_error("connection in %s is null", __func__); + return -EINVAL; + } + + if (ctx->pending == NULL) { + tapi_log_error("pending in %s is null", __func__); return -EINVAL; } @@ -1930,7 +2336,18 @@ int tapi_stk_handle_agent_request_input(tapi_context context, dbus_context* ctx = context; DBusMessage* reply; - if (ctx == NULL || ctx->connection == NULL || ctx->pending == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (ctx->connection == NULL) { + tapi_log_error("connection in %s is null", __func__); + return -EINVAL; + } + + if (ctx->pending == NULL) { + tapi_log_error("pending in %s is null", __func__); return -EINVAL; } @@ -1969,7 +2386,18 @@ int tapi_stk_handle_agent_play_tone(tapi_context context, tapi_stk_agent_operato dbus_context* ctx = context; DBusMessage* reply; - if (ctx == NULL || ctx->connection == NULL || ctx->pending == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (ctx->connection == NULL) { + tapi_log_error("connection in %s is null", __func__); + return -EINVAL; + } + + if (ctx->pending == NULL) { + tapi_log_error("pending in %s is null", __func__); return -EINVAL; } @@ -2003,7 +2431,18 @@ int tapi_stk_handle_agent_request_selection(tapi_context context, dbus_context* ctx = context; DBusMessage* reply; - if (ctx == NULL || ctx->connection == NULL || ctx->pending == NULL) { + if (ctx == NULL) { + tapi_log_error("context in %s is null", __func__); + return -EINVAL; + } + + if (ctx->connection == NULL) { + tapi_log_error("connection in %s is null", __func__); + return -EINVAL; + } + + if (ctx->pending == NULL) { + tapi_log_error("pending in %s is null", __func__); return -EINVAL; }