[PATCH] uqmi: fix compilation with GCC12
Hauke Mehrtens
hauke at hauke-m.de
Sun Aug 21 07:54:35 PDT 2022
On 6/11/22 16:47, Bjørn Mork wrote:
> 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.
GCC complains about this code because the pointer is only removed
conditionally
-------------------------------------------
if (req->complete == &complete)
req->complete = NULL;
-------------------------------------------
https://git.openwrt.org/?p=project/uqmi.git;a=blob;f=dev.c;h=bd1020790f844fd364fd753135acd8f53f34d996;hb=HEAD#l229
When you make this part unconditionally it does not complain any more.
Is it possible that something changes the req->complete pointer address
in between?
Hauke
More information about the openwrt-devel
mailing list