linux-user: change do_semop to return target errno when unsuccessful
authorPetar Jovanovic <petar.jovanovic@imgtec.com>
Thu, 21 Mar 2013 17:57:36 +0000 (18:57 +0100)
committerStefan Hajnoczi <stefanha@redhat.com>
Fri, 19 Apr 2013 09:42:03 +0000 (11:42 +0200)
do_semop() is called from two places, and one of these fails to convert
return error to target errno when semop fails. This patch changes the
function to always return target errno in case of an unsuccessful call.

Signed-off-by: Petar Jovanovic <petar.jovanovic@imgtec.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
linux-user/syscall.c

index 1f07621ffe2d00febfa016f3f9ab475a1f6c663a..d6d20502edf50947fe7f3ec3f93943015b059667 100644 (file)
@@ -2764,7 +2764,7 @@ static inline abi_long do_semop(int semid, abi_long ptr, unsigned nsops)
     if (target_to_host_sembuf(sops, ptr, nsops))
         return -TARGET_EFAULT;
 
-    return semop(semid, sops, nsops);
+    return get_errno(semop(semid, sops, nsops));
 }
 
 struct target_msqid_ds
@@ -6957,7 +6957,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
 #endif
 #ifdef TARGET_NR_semop
     case TARGET_NR_semop:
-        ret = get_errno(do_semop(arg1, arg2, arg3));
+        ret = do_semop(arg1, arg2, arg3);
         break;
 #endif
 #ifdef TARGET_NR_semctl