[PATCH] uqmi: fix compilation with GCC12

Rosen Penev rosenp at gmail.com
Wed Jun 8 18:47:15 PDT 2022


GCC12 doesn't seem to see that the completed member gets nulled. Use
malloc to work around this.

Signed-off-by: Rosen Penev <rosenp at gmail.com>
---
 commands-nas.c | 2 +-
 dev.c          | 9 +++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/commands-nas.c b/commands-nas.c
index 476cd61..9c0a626 100644
--- a/commands-nas.c
+++ b/commands-nas.c
@@ -710,7 +710,7 @@ static void
 cmd_nas_get_cell_location_info_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg)
 {
 	struct qmi_nas_get_cell_location_info_response res;
-	void *c, *t, *cell, *freq;
+	void *c = NULL, *t, *cell, *freq;
 	int i, j;
 
 	qmi_parse_nas_get_cell_location_info_response(msg, &res);
diff --git a/dev.c b/dev.c
index bd10207..b1cf2a3 100644
--- a/dev.c
+++ b/dev.c
@@ -205,7 +205,7 @@ void qmi_request_cancel(struct qmi_dev *qmi, struct qmi_request *req)
 
 int qmi_request_wait(struct qmi_dev *qmi, struct qmi_request *req)
 {
-	bool complete = false;
+	bool *complete = malloc(sizeof(bool));
 	bool cancelled;
 
 	if (!req->pending)
@@ -214,8 +214,8 @@ int qmi_request_wait(struct qmi_dev *qmi, struct qmi_request *req)
 	if (req->complete)
 		*req->complete = true;
 
-	req->complete = &complete;
-	while (!complete) {
+	req->complete = complete;
+	while (!*complete) {
 		cancelled = uloop_cancelled;
 		uloop_cancelled = false;
 		uloop_run();
@@ -226,9 +226,10 @@ int qmi_request_wait(struct qmi_dev *qmi, struct qmi_request *req)
 		uloop_cancelled = cancelled;
 	}
 
-	if (req->complete == &complete)
+	if (req->complete == complete)
 		req->complete = NULL;
 
+	free(complete);
 	return req->ret;
 }
 
-- 
2.36.1




More information about the openwrt-devel mailing list