[PATCH] samples: qmi: Fix decoded_size for the ping response handler

zhangjiao2 posted 1 patch 1 month ago
samples/qmi/qmi_sample_client.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] samples: qmi: Fix decoded_size for the ping response handler
Posted by zhangjiao2 1 month ago
From: zhang jiao <zhangjiao2@cmss.chinamobile.com>

The ping response message handler decodes TEST_PING_REQ_MSG_ID_V01
responses using test_ping_resp_msg_v01_ei and forwards the decoded
message to ping_pong_cb(), which casts the data to
struct test_ping_resp_msg_v01.

However, decoded_size was wrongly set to
sizeof(struct test_ping_req_msg_v01), the request message. Use
sizeof(struct test_ping_resp_msg_v01) instead so the QMI core
allocates a buffer matching the response structure that is being
decoded.

Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>
---
 samples/qmi/qmi_sample_client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/samples/qmi/qmi_sample_client.c b/samples/qmi/qmi_sample_client.c
index 247ec5e54c4f..94173b82ae31 100644
--- a/samples/qmi/qmi_sample_client.c
+++ b/samples/qmi/qmi_sample_client.c
@@ -434,7 +434,7 @@ static const struct qmi_msg_handler qmi_sample_handlers[] = {
 		.type = QMI_RESPONSE,
 		.msg_id = TEST_PING_REQ_MSG_ID_V01,
 		.ei = test_ping_resp_msg_v01_ei,
-		.decoded_size = sizeof(struct test_ping_req_msg_v01),
+		.decoded_size = sizeof(struct test_ping_resp_msg_v01),
 		.fn = ping_pong_cb
 	},
 	{}
-- 
2.33.0