Open Source Telephony
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@lists.linux.dev
Cc: Denis Kenzior <denkenz@gmail.com>
Subject: [PATCH 4/4] qmi: voicecall: Remove redundant initialization to NULL
Date: Mon, 22 Apr 2024 16:40:46 -0500	[thread overview]
Message-ID: <20240422214058.3411417-4-denkenz@gmail.com> (raw)
In-Reply-To: <20240422214058.3411417-1-denkenz@gmail.com>

param was needlelly 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.
---
 drivers/qmimodem/voicecall.c | 32 ++++++++++++--------------------
 1 file changed, 12 insertions(+), 20 deletions(-)

diff --git a/drivers/qmimodem/voicecall.c b/drivers/qmimodem/voicecall.c
index dcb91c642c0c..b66f1ae7d56d 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:
-- 
2.44.0


  parent reply	other threads:[~2024-04-22 21:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-22 21:40 [PATCH 1/4] qmi: Remove redundant NULL check in qmi_param_new Denis Kenzior
2024-04-22 21:40 ` [PATCH 2/4] qmi: voicecall: Fix up code style violations Denis Kenzior
2024-04-22 21:40 ` [PATCH 3/4] qmi: voicecall: Remove ternary conditional use Denis Kenzior
2024-04-22 21:40 ` Denis Kenzior [this message]
2024-04-22 22:30 ` [PATCH 1/4] qmi: Remove redundant NULL check in qmi_param_new patchwork-bot+ofono

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240422214058.3411417-4-denkenz@gmail.com \
    --to=denkenz@gmail.com \
    --cc=ofono@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox