diff mbox

linux-user: correct setsockopt() SO_SNDTIMEO and SO_RCVTIMEO take a struct timeval, not an int

Message ID 1356983610-14793-1-git-send-email-laurent@vivier.eu
State New
Headers show

Commit Message

Laurent Vivier Dec. 31, 2012, 7:53 p.m. UTC
From: Laurent Vivier <Laurent@Vivier.EU>

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/syscall.c |   26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

Comments

Peter Maydell Dec. 31, 2012, 9:40 p.m. UTC | #1
On 31 December 2012 19:53, Laurent Vivier <laurent@vivier.eu> wrote:
> From: Laurent Vivier <Laurent@Vivier.EU>

Looks about right (though the goto is a little ugly). You have some
style issues you need to fix, though.

thanks
-- PMM
diff mbox

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index e99adab..1530c8f 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1491,6 +1491,25 @@  static abi_long do_setsockopt(int sockfd, int level, int optname,
         break;
     case TARGET_SOL_SOCKET:
         switch (optname) {
+        case TARGET_SO_RCVTIMEO: {
+                struct timeval tv;
+
+		optname = SO_RCVTIMEO;
+
+set_timeout:
+                if (optlen != sizeof(struct target_timeval))
+                    return -TARGET_EINVAL;
+
+                if (copy_from_user_timeval(&tv, optval_addr))
+                    return -TARGET_EFAULT;
+
+		ret = get_errno(setsockopt(sockfd, SOL_SOCKET, optname,
+                                &tv, sizeof(tv)));
+		return ret;
+        }
+        case TARGET_SO_SNDTIMEO:
+		optname = SO_SNDTIMEO;
+		goto set_timeout;
             /* Options with 'int' argument.  */
         case TARGET_SO_DEBUG:
 		optname = SO_DEBUG;
@@ -1542,13 +1561,6 @@  static abi_long do_setsockopt(int sockfd, int level, int optname,
         case TARGET_SO_RCVLOWAT:
 		optname = SO_RCVLOWAT;
 		break;
-        case TARGET_SO_RCVTIMEO:
-		optname = SO_RCVTIMEO;
-		break;
-        case TARGET_SO_SNDTIMEO:
-		optname = SO_SNDTIMEO;
-		break;
-            break;
         default:
             goto unimplemented;
         }