summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-01-10 23:02:12 +0100
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-02-28 16:58:24 +0100
commit3693e548bc404af9ced722974cd162c1e7da2825 (patch)
treea332ab6927d3f242a91363d21bc385becea683f4
parent2f902f7e9f71a500bcb6dd789670a4ad35d221f7 (diff)
downloadhardware_replicant_libsamsung-ril-3693e548bc404af9ced722974cd162c1e7da2825.tar.gz
hardware_replicant_libsamsung-ril-3693e548bc404af9ced722974cd162c1e7da2825.tar.bz2
hardware_replicant_libsamsung-ril-3693e548bc404af9ced722974cd162c1e7da2825.zip
RIL_Init: Make sure there are prints for each error paths
If libsamsung-ril didn't start (for instance due to issues or because we are porting it to a newer Android version) it is useful to know why. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rw-r--r--client.c36
-rw-r--r--samsung-ril.c30
2 files changed, 57 insertions, 9 deletions
diff --git a/client.c b/client.c
index 2449ee0..3fa313e 100644
--- a/client.c
+++ b/client.c
@@ -92,11 +92,26 @@ int ril_client_open(struct ril_client *client)
{
int rc = 0;
- if (client == NULL)
+ if (client == NULL) {
+ RIL_LOGD("%s: Skipping open due to Invalid client "
+ "(client is NULL)",
+ __func__);
+ return -1;
+ }
+
+ if (client->handlers == NULL) {
+ RIL_LOGD("%s: Skipping open due to Invalid client "
+ "(client->handlers is NULL)",
+ __func__);
return -1;
+ }
- if (client->handlers == NULL || client->handlers->open == NULL)
+ if (client->handlers->open == NULL) {
+ RIL_LOGD("%s: Skipping open due to Invalid client "
+ "(client->handlers->open is NULL)",
+ __func__);
return -1;
+ }
rc = client->handlers->open(client);
if (rc < 0) {
@@ -193,11 +208,24 @@ int ril_client_loop(struct ril_client *client)
pthread_attr_t attr;
int rc;
- if (client == NULL)
+ if (client == NULL) {
+ RIL_LOGD("%s: Skipping loop due to Invalid client "
+ "(client is NULL)", __func__);
+ return -1;
+ }
+
+ if (client->handlers == NULL) {
+ RIL_LOGD("%s: Skipping loop due to Invalid client "
+ "(client->handlers is NULL)", __func__);
return -1;
+ }
- if (client->handlers == NULL || client->handlers->loop == NULL)
+ if (client->handlers->loop == NULL) {
+ RIL_LOGD("%s: Skipping loop due to Invalid client "
+ "(client->handlers->loop is NULL)",
+ __func__);
return -1;
+ }
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
diff --git a/samsung-ril.c b/samsung-ril.c
index faec338..fe7a703 100644
--- a/samsung-ril.c
+++ b/samsung-ril.c
@@ -1545,12 +1545,15 @@ const RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env,
unsigned int i;
int rc;
- if (env == NULL)
+ if (env == NULL) {
+ RIL_LOGE("%s: Aborting: Invalid RIL_Env (RIL_Env is NULL)",
+ __func__);
return NULL;
+ }
rc = ril_data_create();
if (rc < 0) {
- RIL_LOGE("Creating RIL data failed");
+ RIL_LOGE("%s: Creating RIL data failed", __func__);
return NULL;
}
@@ -1559,17 +1562,26 @@ const RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env,
ril_data->env = env;
for (i = 0; i < ril_clients_count; i++) {
- if (ril_clients[i] == NULL)
+ if (ril_clients[i] == NULL) {
+ RIL_LOGD("%s: Skipping ril_client_create "
+ "due to Invalid client (client is NULL)",
+ __func__);
continue;
+ }
rc = ril_client_create(ril_clients[i]);
if (rc < 0)
+ /* ril_client_create already prints an error if it fails */
goto error;
}
for (i = 0; i < ril_clients_count; i++) {
- if (ril_clients[i] == NULL)
+ if (ril_clients[i] == NULL) {
+ RIL_LOGD("%s: Skipping ril_client_open "
+ "due to Invalid client (client is NULL)",
+ __func__);
continue;
+ }
failures = 0;
@@ -1581,11 +1593,19 @@ const RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env,
}
} while (rc < 0 && failures < RIL_CLIENT_RETRY_COUNT);
- if (rc < 0)
+ if (rc < 0) {
+ RIL_LOGD("%s: "
+ "gave up trying to open the %s client "
+ "after %d retries",
+ __func__,
+ (ril_clients[i])->name,
+ RIL_CLIENT_RETRY_COUNT);
goto error;
+ }
rc = ril_client_loop(ril_clients[i]);
if (rc < 0)
+ /* ril_client_loop already prints an error if it fails */
goto error;
}