diff options
author | Denis Kenzior <denkenz@gmail.com> | 2024-04-22 16:33:27 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2024-04-22 17:26:19 -0500 |
commit | 789f68a5fba332fe6d16102c63578eac46a1f0b3 (patch) | |
tree | b1d21303821977da6b6b325a6da3146f62f34535 | |
parent | 231cde4f12a4e05dcb89a17893bee2655ab7cd7b (diff) | |
download | ofono-789f68a5fba332fe6d16102c63578eac46a1f0b3.tar.gz |
qmi: voicecall: Remove redundant initialization to NULL
param was needlessly initialized to NULL in answer() and
release_specific(). Since all error paths free both cbd and param,
declare & initialize these variables at the start of the function.
Handle dial() similarly for consistency.
-rw-r--r-- | drivers/qmimodem/voicecall.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/drivers/qmimodem/voicecall.c b/drivers/qmimodem/voicecall.c index dcb91c642..b66f1ae7d 100644 --- a/drivers/qmimodem/voicecall.c +++ b/drivers/qmimodem/voicecall.c @@ -434,7 +434,8 @@ static void dial(struct ofono_voicecall *vc, { struct voicecall_data *vd = ofono_voicecall_get_data(vc); struct cb_data *cbd = cb_data_new(cb, data); - struct qmi_param *param; + struct qmi_param *param = qmi_param_new(); + const char *calling_number = phone_number_to_string(ph); static const uint8_t PARAM_CALL_NUMBER = 0x01; @@ -446,8 +447,6 @@ static void dial(struct ofono_voicecall *vc, cbd->user = vc; memcpy(&vd->dialed, ph, sizeof(*ph)); - param = qmi_param_new(); - if (!qmi_param_append(param, PARAM_CALL_NUMBER, strlen(calling_number), calling_number)) goto error; @@ -492,27 +491,22 @@ static void answer(struct ofono_voicecall *vc, ofono_voicecall_cb_t cb, void *data) { struct voicecall_data *vd = ofono_voicecall_get_data(vc); - struct cb_data *cbd; + struct cb_data *cbd = cb_data_new(cb, data); + struct qmi_param *param = qmi_param_new(); struct ofono_call *call; - struct qmi_param *param = NULL; - static const uint8_t PARAM_CALL_ID = 0x01; DBG(""); - call = l_queue_find(vd->call_list, - ofono_call_match_by_status, - L_UINT_TO_PTR(CALL_STATUS_INCOMING)); - - param = qmi_param_new(); - cbd = cb_data_new(cb, data); - cbd->user = vc; - - if (call == NULL) { + call = l_queue_find(vd->call_list, ofono_call_match_by_status, + L_UINT_TO_PTR(CALL_STATUS_INCOMING)); + if (!call) { ofono_error("Can not find a call to pick up"); goto error; } + cbd->user = vc; + if (!qmi_param_append_uint8(param, PARAM_CALL_ID, call->id)) goto error; @@ -552,22 +546,20 @@ static void release_specific(struct ofono_voicecall *vc, int id, ofono_voicecall_cb_t cb, void *data) { struct voicecall_data *vd = ofono_voicecall_get_data(vc); - struct cb_data *cbd; - struct qmi_param *param = NULL; + struct cb_data *cbd = cb_data_new(cb, data); + struct qmi_param *param = qmi_param_new(); static const uint8_t PARAM_CALL_ID = 0x01; DBG(""); - param = qmi_param_new(); - cbd = cb_data_new(cb, data); cbd->user = vc; if (!qmi_param_append_uint8(param, PARAM_CALL_ID, id)) goto error; if (qmi_service_send(vd->voice, QMI_VOICE_END_CALL, param, end_call_cb, - cbd, l_free) > 0) + cbd, l_free) > 0) return; error: |