* [PATCH] tests: test-qga: close socket on failure to connect
@ 2022-09-05 11:01 Paolo Bonzini
2022-09-05 11:36 ` Marc-André Lureau
0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2022-09-05 11:01 UTC (permalink / raw)
To: qemu-devel
Reported by Coverity as CID 1432543.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
tests/unit/test-qga.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c
index a05a4628ed..d27ff94d13 100644
--- a/tests/unit/test-qga.c
+++ b/tests/unit/test-qga.c
@@ -32,6 +32,7 @@ static int connect_qga(char *path)
g_usleep(G_USEC_PER_SEC);
}
if (i++ == 10) {
+ close(s);
return -1;
}
} while (ret == -1);
--
2.37.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] tests: test-qga: close socket on failure to connect
2022-09-05 11:01 [PATCH] tests: test-qga: close socket on failure to connect Paolo Bonzini
@ 2022-09-05 11:36 ` Marc-André Lureau
2022-09-05 12:29 ` Paolo Bonzini
0 siblings, 1 reply; 4+ messages in thread
From: Marc-André Lureau @ 2022-09-05 11:36 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 866 bytes --]
Hi
On Mon, Sep 5, 2022 at 3:27 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
> Reported by Coverity as CID 1432543.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> tests/unit/test-qga.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c
> index a05a4628ed..d27ff94d13 100644
> --- a/tests/unit/test-qga.c
> +++ b/tests/unit/test-qga.c
> @@ -32,6 +32,7 @@ static int connect_qga(char *path)
> g_usleep(G_USEC_PER_SEC);
> }
> if (i++ == 10) {
> + close(s);
>
We may want to be a bit safer and use g_close(), which handles EINTR too.
Anyway
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> return -1;
> }
> } while (ret == -1);
> --
> 2.37.2
>
>
>
--
Marc-André Lureau
[-- Attachment #2: Type: text/html, Size: 1630 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tests: test-qga: close socket on failure to connect
2022-09-05 11:36 ` Marc-André Lureau
@ 2022-09-05 12:29 ` Paolo Bonzini
2022-09-05 12:36 ` Marc-André Lureau
0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2022-09-05 12:29 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1139 bytes --]
There is no portable way to handle EINTR on close() as far as I know. You
can't really do anything but cross your fingers.
Paolo
Il lun 5 set 2022, 13:36 Marc-André Lureau <marcandre.lureau@gmail.com> ha
scritto:
> Hi
>
> On Mon, Sep 5, 2022 at 3:27 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
>> Reported by Coverity as CID 1432543.
>>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>> tests/unit/test-qga.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c
>> index a05a4628ed..d27ff94d13 100644
>> --- a/tests/unit/test-qga.c
>> +++ b/tests/unit/test-qga.c
>> @@ -32,6 +32,7 @@ static int connect_qga(char *path)
>> g_usleep(G_USEC_PER_SEC);
>> }
>> if (i++ == 10) {
>> + close(s);
>>
>
> We may want to be a bit safer and use g_close(), which handles EINTR too.
> Anyway
>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>
>
>> return -1;
>> }
>> } while (ret == -1);
>> --
>> 2.37.2
>>
>>
>>
>
> --
> Marc-André Lureau
>
[-- Attachment #2: Type: text/html, Size: 2292 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tests: test-qga: close socket on failure to connect
2022-09-05 12:29 ` Paolo Bonzini
@ 2022-09-05 12:36 ` Marc-André Lureau
0 siblings, 0 replies; 4+ messages in thread
From: Marc-André Lureau @ 2022-09-05 12:36 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1451 bytes --]
Hi
On Mon, Sep 5, 2022 at 4:29 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
> There is no portable way to handle EINTR on close() as far as I know. You
> can't really do anything but cross your fingers.
>
>
Right, it actually ignores EINTR at this point. See:
https://gitlab.gnome.org/GNOME/glib/-/commit/f398bec5bcc0d924e2401c76a6b94133e9490835
Paolo
>
> Il lun 5 set 2022, 13:36 Marc-André Lureau <marcandre.lureau@gmail.com>
> ha scritto:
>
>> Hi
>>
>> On Mon, Sep 5, 2022 at 3:27 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
>>
>>> Reported by Coverity as CID 1432543.
>>>
>>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>>> ---
>>> tests/unit/test-qga.c | 1 +
>>> 1 file changed, 1 insertion(+)
>>>
>>> diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c
>>> index a05a4628ed..d27ff94d13 100644
>>> --- a/tests/unit/test-qga.c
>>> +++ b/tests/unit/test-qga.c
>>> @@ -32,6 +32,7 @@ static int connect_qga(char *path)
>>> g_usleep(G_USEC_PER_SEC);
>>> }
>>> if (i++ == 10) {
>>> + close(s);
>>>
>>
>> We may want to be a bit safer and use g_close(), which handles EINTR too.
>> Anyway
>>
>> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>>
>>
>>> return -1;
>>> }
>>> } while (ret == -1);
>>> --
>>> 2.37.2
>>>
>>>
>>>
>>
>> --
>> Marc-André Lureau
>>
>
--
Marc-André Lureau
[-- Attachment #2: Type: text/html, Size: 3260 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-05 13:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-05 11:01 [PATCH] tests: test-qga: close socket on failure to connect Paolo Bonzini
2022-09-05 11:36 ` Marc-André Lureau
2022-09-05 12:29 ` Paolo Bonzini
2022-09-05 12:36 ` Marc-André Lureau
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).