qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] linux-user: Fix SO_ERROR return code of getsockopt()


From: Laurent Vivier
Subject: Re: [PATCH] linux-user: Fix SO_ERROR return code of getsockopt()
Date: Thu, 26 Jan 2023 20:43:11 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]