Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/amd64/amd64 Use KASSERT, and panic by default inste...



details:   https://anonhg.NetBSD.org/src/rev/7443441fd524
branches:  trunk
changeset: 347331:7443441fd524
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun Aug 21 10:20:21 2016 +0000

description:
Use KASSERT, and panic by default instead of allowing the area to overflow.

diffstat:

 sys/arch/amd64/amd64/gdt.c |  15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)

diffs (44 lines):

diff -r 7f17076808ef -r 7443441fd524 sys/arch/amd64/amd64/gdt.c
--- a/sys/arch/amd64/amd64/gdt.c        Sun Aug 21 10:07:15 2016 +0000
+++ b/sys/arch/amd64/amd64/gdt.c        Sun Aug 21 10:20:21 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gdt.c,v 1.32 2016/08/21 10:07:15 maxv Exp $    */
+/*     $NetBSD: gdt.c,v 1.33 2016/08/21 10:20:21 maxv Exp $    */
 
 /*-
  * Copyright (c) 1996, 1997, 2009 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.32 2016/08/21 10:07:15 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.33 2016/08/21 10:20:21 maxv Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_xen.h"
@@ -278,22 +278,17 @@
                slot = gdt_free;
                gdt_free = gdt[slot].sd_xx3;    /* XXXfvdl res. field abuse */
        } else {
-#ifdef DIAGNOSTIC
-               if (gdt_next != gdt_dyncount)
-                       panic("gdt_get_slot botch 1");
-#endif
+               KASSERT(gdt_next == gdt_dyncount);
                if (gdt_next >= gdt_dynavail) {
-#ifdef DIAGNOSTIC
                        if (gdt_size >= MAXGDTSIZ)
-                               panic("gdt_get_slot botch 2");
-#endif
+                               panic("gdt_get_slot: out of memory");
                        gdt_grow();
                }
                slot = gdt_next++;
        }
 
        gdt_dyncount++;
-       return (slot);
+       return slot;
 }
 
 /*



Home | Main Index | Thread Index | Old Index