riscv64, fix HANDLE_ERROR
authordrahn <drahn@openbsd.org>
Sun, 2 May 2021 20:08:49 +0000 (20:08 +0000)
committerdrahn <drahn@openbsd.org>
Sun, 2 May 2021 20:08:49 +0000 (20:08 +0000)
the CERROR handling code had a gross mistake in that that it didn't
continue processing the code after the macro if no error occurred.
ok kettenis@

lib/libc/arch/riscv64/SYS.h

index c3219d5..21fb457 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: SYS.h,v 1.1 2021/04/29 18:33:36 drahn Exp $   */
+/*     $OpenBSD: SYS.h,v 1.2 2021/05/02 20:08:49 drahn Exp $   */
 /*-
  * Copyright (c) 2020 Brian Bamsch <bbamsch@google.com>
  * Copyright (c) 1990 The Regents of the University of California.
 
 #define        CERROR          _C_LABEL(__cerror)
 #define HANDLE_ERROR()                                                 \
-       bnez    t0, 1f;                                                 \
-       ret;                                                            \
+       beqz    t0, 2f;                                                 \
 1:     auipc   t0, %got_pcrel_hi(CERROR);                              \
        ld      t1, %pcrel_lo(1b)(t0);                                  \
-       jr      t1
-
+       jr      t1;                                                     \
+2:
 #define _SYSCALL_NOERROR(x,y)                                          \
        SYSENTRY(x);                                                    \
        SYSTRAP(y)