]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Clean up setting carry flag in VG_(fixup_guest_state_after_syscall_interrupted)
authorPaul Floyd <pjfloyd@wanadoo.fr>
Fri, 27 Feb 2026 20:26:23 +0000 (21:26 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Fri, 27 Feb 2026 20:26:23 +0000 (21:26 +0100)
This wasn't consistent (not at all for Darwin, not checking SfNoWriteResult
on Solaris and a bit long winded on FreeBSD). Simplify the code for all
3 platforms.

coregrind/m_syswrap/syswrap-main.c

index 07f1930469e6dc15e18deba3422cfe489279369c..763833c526519bf25680962834eb035e53b95481 100644 (file)
@@ -3407,40 +3407,24 @@ VG_(fixup_guest_state_after_syscall_interrupted)( ThreadId tid,
          we expect our caller (the signal handler) will have fixed
          this up. */
 /* XXX: needed? */
-#if defined(VGP_x86_freebsd)
-      /* On FreeBSD, the success/fail status is returned to the caller
-        and still has to be fixed up here. */
+#if defined(VGP_x86_freebsd) || defined(VGP_x86_solaris) || defined(VGP_x86_darwin)
+      /* The %eax and %edx values are committed but the carry flag is still
+         uncommitted.  Save it now. */
       if (!(sci->flags & SfNoWriteResult)) {
-        if (sr_isError(sres))
-           LibVEX_GuestX86_put_eflag_c(1, &th_regs->vex);
-        else
-           LibVEX_GuestX86_put_eflag_c(0, &th_regs->vex);
+         LibVEX_GuestX86_put_eflag_c(sr_isError(sres), &th_regs->vex);
       }
-#elif defined(VGP_amd64_freebsd)
+#elif defined(VGP_amd64_freebsd) || defined(VGP_amd64_solaris) || defined(VGP_amd64_darwin)
       if (!(sci->flags & SfNoWriteResult)) {
-        if (sr_isError(sres))
-           LibVEX_GuestAMD64_put_rflag_c(1, &th_regs->vex);
-        else
-           LibVEX_GuestAMD64_put_rflag_c(0, &th_regs->vex);
+         LibVEX_GuestAMD64_put_rflag_c(sr_isError(sres), &th_regs->vex);
       }
 #elif defined(VGP_arm64_freebsd)
       if (!(sci->flags & SfNoWriteResult)) {
-         if (sr_isError(sres))
-            LibVEX_GuestARM64_put_nzcv_c(1, &th_regs->vex);
-         else
-            LibVEX_GuestARM64_put_nzcv_c(0, &th_regs->vex);
+         LibVEX_GuestARM64_put_nzcv_c(sr_isError(sres), &th_regs->vex);
       }
 #endif
       if (VG_(clo_trace_signals))
          VG_(message)( Vg_DebugMsg,
                        "  completed and committed: nothing to do\n");
-#     if defined(VGP_x86_solaris)
-      /* The %eax and %edx values are committed but the carry flag is still
-         uncommitted.  Save it now. */
-      LibVEX_GuestX86_put_eflag_c(sr_isError(sres), &th_regs->vex);
-#     elif defined(VGP_amd64_solaris)
-      LibVEX_GuestAMD64_put_rflag_c(sr_isError(sres), &th_regs->vex);
-#     endif
       getSyscallStatusFromGuestState( &sci->status, &th_regs->vex );
       vg_assert(sci->status.what == SsComplete);
       VG_(post_syscall)(tid);