* [PATCH] linux-user: Fix SO_ERROR return code of getsockopt()
@ 2022-12-16 10:10 Helge Deller
2023-01-26 16:55 ` Laurent Vivier
0 siblings, 1 reply; 8+ messages in thread
From: Helge Deller @ 2022-12-16 10:10 UTC (permalink / raw)
To: Laurent Vivier, Richard Henderson, qemu-devel; +Cc: Helge Deller
Add translation for the host error return code of:
getsockopt(19, SOL_SOCKET, SO_ERROR, [ECONNREFUSED], [4]) = 0
This fixes the testsuite of the cockpit debian package with a
hppa-linux guest on a x86-64 host.
Signed-off-by: Helge Deller <deller@gmx.de>
---
linux-user/syscall.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index e541fbe09a..52693b4239 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2809,8 +2809,9 @@ get_timeout:
ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv));
if (ret < 0)
return ret;
- if (optname == SO_TYPE) {
- val = host_to_target_sock_type(val);
+ switch (optname) {
+ case SO_TYPE: val = host_to_target_sock_type(val); break;
+ case SO_ERROR: val = host_to_target_errno(val); break;
}
if (len > lv)
len = lv;
--
2.38.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] linux-user: Fix SO_ERROR return code of getsockopt()
2022-12-16 10:10 [PATCH] linux-user: Fix SO_ERROR return code of getsockopt() Helge Deller
@ 2023-01-26 16:55 ` Laurent Vivier
2023-01-26 18:27 ` Helge Deller
0 siblings, 1 reply; 8+ messages in thread
From: Laurent Vivier @ 2023-01-26 16:55 UTC (permalink / raw)
To: Helge Deller, Richard Henderson, qemu-devel
Le 16/12/2022 à 11:10, Helge Deller a écrit :
> Add translation for the host error return code of:
> getsockopt(19, SOL_SOCKET, SO_ERROR, [ECONNREFUSED], [4]) = 0
>
> This fixes the testsuite of the cockpit debian package with a
> hppa-linux guest on a x86-64 host.
>
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
> linux-user/syscall.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index e541fbe09a..52693b4239 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -2809,8 +2809,9 @@ get_timeout:
> ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv));
> if (ret < 0)
> return ret;
> - if (optname == SO_TYPE) {
> - val = host_to_target_sock_type(val);
> + switch (optname) {
> + case SO_TYPE: val = host_to_target_sock_type(val); break;
> + case SO_ERROR: val = host_to_target_errno(val); break;
It looks good but I think compiler will complain if you don't have a default case.
perhaps "if (optname == SO_TYPE) { } else if (optname == SO_ERROR) { }" would be better.
Thanks,
Laurent
> }
> if (len > lv)
> len = lv;
> --
> 2.38.1
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] linux-user: Fix SO_ERROR return code of getsockopt()
2023-01-26 16:55 ` Laurent Vivier
@ 2023-01-26 18:27 ` Helge Deller
2023-01-26 19:43 ` Laurent Vivier
0 siblings, 1 reply; 8+ messages in thread
From: Helge Deller @ 2023-01-26 18:27 UTC (permalink / raw)
To: Laurent Vivier, Richard Henderson, qemu-devel
On 1/26/23 17:55, Laurent Vivier wrote:
> Le 16/12/2022 à 11:10, Helge Deller a écrit :
>> Add translation for the host error return code of:
>> getsockopt(19, SOL_SOCKET, SO_ERROR, [ECONNREFUSED], [4]) = 0
>>
>> This fixes the testsuite of the cockpit debian package with a
>> hppa-linux guest on a x86-64 host.
>>
>> Signed-off-by: Helge Deller <deller@gmx.de>
>> ---
>> linux-user/syscall.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
>> index e541fbe09a..52693b4239 100644
>> --- a/linux-user/syscall.c
>> +++ b/linux-user/syscall.c
>> @@ -2809,8 +2809,9 @@ get_timeout:
>> ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv));
>> if (ret < 0)
>> return ret;
>> - if (optname == SO_TYPE) {
>> - val = host_to_target_sock_type(val);
>> + switch (optname) {
>> + case SO_TYPE: val = host_to_target_sock_type(val); break;
>> + case SO_ERROR: val = host_to_target_errno(val); break;
>
> It looks good but I think compiler will complain if you don't have a default case.
It didn't for me, but I'm not sure for others.
> perhaps "if (optname == SO_TYPE) { } else if (optname == SO_ERROR) { }" would be better.
Personally I do prefer this type of switch statement here (which actually avoids such nested
"if" statements). But I'm not religious about it, so if you want it as nested "if"s I can
send a new patch which will be larger and less readable... Please let me know.
Helge
>
> Thanks,
> Laurent
>> }
>> if (len > lv)
>> len = lv;
>> --
>> 2.38.1
>>
>>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] linux-user: Fix SO_ERROR return code of getsockopt()
2023-01-26 18:27 ` Helge Deller
@ 2023-01-26 19:43 ` Laurent Vivier
2023-01-27 20:25 ` [PATCH v2] " Helge Deller
0 siblings, 1 reply; 8+ messages in thread
From: Laurent Vivier @ 2023-01-26 19:43 UTC (permalink / raw)
To: Helge Deller, Richard Henderson, qemu-devel
Le 26/01/2023 à 19:27, Helge Deller a écrit :
> On 1/26/23 17:55, Laurent Vivier wrote:
>> Le 16/12/2022 à 11:10, Helge Deller a écrit :
>>> Add translation for the host error return code of:
>>> getsockopt(19, SOL_SOCKET, SO_ERROR, [ECONNREFUSED], [4]) = 0
>>>
>>> This fixes the testsuite of the cockpit debian package with a
>>> hppa-linux guest on a x86-64 host.
>>>
>>> Signed-off-by: Helge Deller <deller@gmx.de>
>>> ---
>>> linux-user/syscall.c | 5 +++--
>>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
>>> index e541fbe09a..52693b4239 100644
>>> --- a/linux-user/syscall.c
>>> +++ b/linux-user/syscall.c
>>> @@ -2809,8 +2809,9 @@ get_timeout:
>>> ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv));
>>> if (ret < 0)
>>> return ret;
>>> - if (optname == SO_TYPE) {
>>> - val = host_to_target_sock_type(val);
>>> + switch (optname) {
>>> + case SO_TYPE: val = host_to_target_sock_type(val); break;
>>> + case SO_ERROR: val = host_to_target_errno(val); break;
>>
>> It looks good but I think compiler will complain if you don't have a default case.
>
> It didn't for me, but I'm not sure for others.
It's ok. No errors reported by gcc.
however checkscript.sh is not happy:
ERROR: trailing statements should be on next line
#30: FILE: linux-user/syscall.c:2762:
+ case SO_TYPE: val = host_to_target_sock_type(val); break;
ERROR: trailing statements should be on next line
#31: FILE: linux-user/syscall.c:2763:
+ case SO_ERROR: val = host_to_target_errno(val); break;
Thanks,
Laurent
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] linux-user: Fix SO_ERROR return code of getsockopt()
2023-01-26 19:43 ` Laurent Vivier
@ 2023-01-27 20:25 ` Helge Deller
2023-01-27 22:55 ` Richard Henderson
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Helge Deller @ 2023-01-27 20:25 UTC (permalink / raw)
To: Laurent Vivier; +Cc: Helge Deller, Richard Henderson, qemu-devel
Add translation for the host error return code of:
getsockopt(19, SOL_SOCKET, SO_ERROR, [ECONNREFUSED], [4]) = 0
This fixes the testsuite of the cockpit debian package with a
hppa-linux guest on a x86-64 host.
Signed-off-by: Helge Deller <deller@gmx.de>
---
v2: Fix indenting to make checkscript.sh happy
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index dac0cfe6c4..06e8612675 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2809,8 +2809,13 @@ get_timeout:
ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv));
if (ret < 0)
return ret;
- if (optname == SO_TYPE) {
+ switch (optname) {
+ case SO_TYPE:
val = host_to_target_sock_type(val);
+ break;
+ case SO_ERROR:
+ val = host_to_target_errno(val);
+ break;
}
if (len > lv)
len = lv;
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] linux-user: Fix SO_ERROR return code of getsockopt()
2023-01-27 20:25 ` [PATCH v2] " Helge Deller
@ 2023-01-27 22:55 ` Richard Henderson
2023-01-30 8:42 ` Laurent Vivier
2023-01-30 8:45 ` Laurent Vivier
2 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2023-01-27 22:55 UTC (permalink / raw)
To: Helge Deller, Laurent Vivier; +Cc: qemu-devel
On 1/27/23 10:25, Helge Deller wrote:
> Add translation for the host error return code of:
> getsockopt(19, SOL_SOCKET, SO_ERROR, [ECONNREFUSED], [4]) = 0
>
> This fixes the testsuite of the cockpit debian package with a
> hppa-linux guest on a x86-64 host.
>
> Signed-off-by: Helge Deller<deller@gmx.de>
> ---
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] linux-user: Fix SO_ERROR return code of getsockopt()
2023-01-27 20:25 ` [PATCH v2] " Helge Deller
2023-01-27 22:55 ` Richard Henderson
@ 2023-01-30 8:42 ` Laurent Vivier
2023-01-30 8:45 ` Laurent Vivier
2 siblings, 0 replies; 8+ messages in thread
From: Laurent Vivier @ 2023-01-30 8:42 UTC (permalink / raw)
To: Helge Deller; +Cc: Richard Henderson, qemu-devel
Le 27/01/2023 à 21:25, Helge Deller a écrit :
> Add translation for the host error return code of:
> getsockopt(19, SOL_SOCKET, SO_ERROR, [ECONNREFUSED], [4]) = 0
>
> This fixes the testsuite of the cockpit debian package with a
> hppa-linux guest on a x86-64 host.
>
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
> v2: Fix indenting to make checkscript.sh happy
>
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index dac0cfe6c4..06e8612675 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -2809,8 +2809,13 @@ get_timeout:
> ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv));
> if (ret < 0)
> return ret;
> - if (optname == SO_TYPE) {
> + switch (optname) {
> + case SO_TYPE:
> val = host_to_target_sock_type(val);
> + break;
> + case SO_ERROR:
> + val = host_to_target_errno(val);
> + break;
> }
> if (len > lv)
> len = lv;
>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] linux-user: Fix SO_ERROR return code of getsockopt()
2023-01-27 20:25 ` [PATCH v2] " Helge Deller
2023-01-27 22:55 ` Richard Henderson
2023-01-30 8:42 ` Laurent Vivier
@ 2023-01-30 8:45 ` Laurent Vivier
2 siblings, 0 replies; 8+ messages in thread
From: Laurent Vivier @ 2023-01-30 8:45 UTC (permalink / raw)
To: Helge Deller; +Cc: Richard Henderson, qemu-devel
Le 27/01/2023 à 21:25, Helge Deller a écrit :
> Add translation for the host error return code of:
> getsockopt(19, SOL_SOCKET, SO_ERROR, [ECONNREFUSED], [4]) = 0
>
> This fixes the testsuite of the cockpit debian package with a
> hppa-linux guest on a x86-64 host.
>
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
> v2: Fix indenting to make checkscript.sh happy
>
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index dac0cfe6c4..06e8612675 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -2809,8 +2809,13 @@ get_timeout:
> ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv));
> if (ret < 0)
> return ret;
> - if (optname == SO_TYPE) {
> + switch (optname) {
> + case SO_TYPE:
> val = host_to_target_sock_type(val);
> + break;
> + case SO_ERROR:
> + val = host_to_target_errno(val);
> + break;
> }
> if (len > lv)
> len = lv;
>
Applied to my linux-user-for-8.0 branch.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-01-30 8:46 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-16 10:10 [PATCH] linux-user: Fix SO_ERROR return code of getsockopt() Helge Deller
2023-01-26 16:55 ` Laurent Vivier
2023-01-26 18:27 ` Helge Deller
2023-01-26 19:43 ` Laurent Vivier
2023-01-27 20:25 ` [PATCH v2] " Helge Deller
2023-01-27 22:55 ` Richard Henderson
2023-01-30 8:42 ` Laurent Vivier
2023-01-30 8:45 ` Laurent Vivier
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.