diff options
author | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2019-06-21 14:39:31 +0200 |
---|---|---|
committer | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2020-08-27 18:12:57 +0200 |
commit | 2a4d669042d3ba0f1cc0b58a9015d2417e0c6b20 (patch) | |
tree | 11bc0d8e7bede6ca8e86cecf6f1b0b4078da54d8 | |
parent | 6706382a59f37ace006018d0fa421906f99e57b9 (diff) | |
download | hardware_replicant_libsamsung-ril-2a4d669042d3ba0f1cc0b58a9015d2417e0c6b20.tar.gz hardware_replicant_libsamsung-ril-2a4d669042d3ba0f1cc0b58a9015d2417e0c6b20.tar.bz2 hardware_replicant_libsamsung-ril-2a4d669042d3ba0f1cc0b58a9015d2417e0c6b20.zip |
ril_has_reached_state: use more meaningful variable names
As the code in this function loops over the radio_states array to match
with RIL_RadioState argument, it is better to have variables names that
indicate if they comes from the function argument or the radio_states
array, instead of using generic names.
This improves clarity by requiring less context for humans to read and
understand that function.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rw-r--r-- | samsung-ril.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/samsung-ril.c b/samsung-ril.c index 64575b3..a9cc224 100644 --- a/samsung-ril.c +++ b/samsung-ril.c @@ -1200,7 +1200,7 @@ int ril_radio_state_update(RIL_RadioState radio_state) * Returns 0 if the RIL has reached the given radio_state * Returns -1 otherwise */ -int ril_has_reached_state(RIL_RadioState radio_state) +int ril_has_reached_state(RIL_RadioState given_state) { RIL_RadioState radio_states[] = { RADIO_STATE_UNAVAILABLE, @@ -1212,26 +1212,31 @@ int ril_has_reached_state(RIL_RadioState radio_state) RADIO_STATE_SIM_LOCKED_OR_ABSENT, RADIO_STATE_SIM_READY, }; - unsigned int index; - unsigned int count; + + RIL_RadioState curr_state; + + unsigned int curr_state_index; + unsigned int given_state_index; + unsigned int radio_states_count; unsigned int i; if (ril_data == NULL) return -1; - count = sizeof(radio_states) / sizeof(RIL_RadioState); + curr_state = ril_data->radio_state; + radio_states_count = sizeof(radio_states) / sizeof(RIL_RadioState); - for (i = 0; i < count; i++) - if (radio_states[i] == radio_state) + for (i = 0; i < radio_states_count; i++) + if (radio_states[i] == given_state) break; + given_state_index = i; - index = i; - - for (i = 0; i < count; i++) - if (radio_states[i] == ril_data->radio_state) + for (i = 0; i < radio_states_count; i++) + if (radio_states[i] == curr_state) break; + curr_state_index = i; - if (i < index) + if (curr_state_index < given_state_index) return -1; return 0; |