Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc64/sparc64 As christos put it: "Tidy up error ...



details:   https://anonhg.NetBSD.org/src/rev/e83a80d8d42a
branches:  trunk
changeset: 336419:e83a80d8d42a
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Feb 28 21:44:33 2015 +0000

description:
As christos put it: "Tidy up error handling, and return SIGBUS for mmap
past the end of file as required by the spec."

diffstat:

 sys/arch/sparc64/sparc64/trap.c |  30 +++++++++++++++++++-----------
 1 files changed, 19 insertions(+), 11 deletions(-)

diffs (53 lines):

diff -r 7950930e0c46 -r e83a80d8d42a sys/arch/sparc64/sparc64/trap.c
--- a/sys/arch/sparc64/sparc64/trap.c   Sat Feb 28 21:42:01 2015 +0000
+++ b/sys/arch/sparc64/sparc64/trap.c   Sat Feb 28 21:44:33 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.180 2014/02/20 01:40:42 joerg Exp $ */
+/*     $NetBSD: trap.c,v 1.181 2015/02/28 21:44:33 martin Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.180 2014/02/20 01:40:42 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.181 2015/02/28 21:44:33 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -1198,17 +1198,25 @@
                }
 #endif
                KSI_INIT_TRAP(&ksi);
-               if (rv == ENOMEM) {
-                       printf("UVM: pid %d (%s), uid %d killed: out of swap\n",
-                              p->p_pid, p->p_comm,
-                              l->l_cred ?
-                              kauth_cred_geteuid(l->l_cred) : -1);
+               switch (rv) {
+               case EINVAL:
+                       ksi.ksi_signo = SIGBUS;
+                       ksi.ksi_code = BUS_ADRERR;
+                       break;
+               case EACCES:
+                       ksi.ksi_signo = SIGSEGV;
+                       ksi.ksi_code = SEGV_ACCERR;
+                       break;
+               case ENOMEM:
                        ksi.ksi_signo = SIGKILL;
-                       ksi.ksi_code = SI_NOINFO;
-               } else {
+                       printf("UVM: pid %d (%s), uid %d killed: out of swap\n",
+                           p->p_pid, p->p_comm,
+                           l->l_cred ? kauth_cred_geteuid(l->l_cred) : -1);
+                       break;
+               default:
                        ksi.ksi_signo = SIGSEGV;
-                       ksi.ksi_code = (rv == EACCES
-                               ? SEGV_ACCERR : SEGV_MAPERR);
+                       ksi.ksi_code = SEGV_MAPERR;
+                       break;
                }
                ksi.ksi_trap = type;
                ksi.ksi_addr = (void *)sfva;



Home | Main Index | Thread Index | Old Index