[PATCH] uqmi: fix compilation with GCC12

Bjørn Mork bjorn at mork.no
Sat Jun 11 07:47:06 PDT 2022


e9hack <e9hack at gmail.com> writes:

> The 'dangling pointer' issue can be fix without using malloc().
>
> --- a/dev.c	2022-05-04 02:18:17.000000000 +0200
> +++ b/dev.c	2022-06-11 08:48:21.185567953 +0200
> @@ -206,6 +206,7 @@ void qmi_request_cancel(struct qmi_dev *
>  int qmi_request_wait(struct qmi_dev *qmi, struct qmi_request *req)
>  {
>  	bool complete = false;
> +	bool *c;
>  	bool cancelled;
>    	if (!req->pending)
> @@ -226,8 +227,10 @@ int qmi_request_wait(struct qmi_dev *qmi
>  		uloop_cancelled = cancelled;
>  	}
>  -	if (req->complete == &complete)
> -		req->complete = NULL;
> +	c = req->complete;
> +	req->complete = NULL;
> +	if (c != &complete)
> +		req->complete = c;
>    	return req->ret;
>  }

How about just fixing GCC instead?  Having all sorts of funny and
pointless code just to avoid bogus compiler warnings is kind of stupid,
isn't it?

If GCC can't do better that this, then it's much better to disable that
warning.


Bjørn



More information about the openwrt-devel mailing list