Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Improve error handling, doesn't matter a lot, but s...



details:   https://anonhg.NetBSD.org/src/rev/6b9be51cde80
branches:  trunk
changeset: 446545:6b9be51cde80
user:      maxv <maxv%NetBSD.org@localhost>
date:      Mon Dec 10 07:24:49 2018 +0000

description:
Improve error handling, doesn't matter a lot, but still.

diffstat:

 sys/kern/subr_kleak.c |  20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diffs (47 lines):

diff -r 10ad34cdd131 -r 6b9be51cde80 sys/kern/subr_kleak.c
--- a/sys/kern/subr_kleak.c     Mon Dec 10 06:23:54 2018 +0000
+++ b/sys/kern/subr_kleak.c     Mon Dec 10 07:24:49 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_kleak.c,v 1.1 2018/12/02 21:00:13 maxv Exp $      */
+/*     $NetBSD: subr_kleak.c,v 1.2 2018/12/10 07:24:49 maxv Exp $      */
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_kleak.c,v 1.1 2018/12/02 21:00:13 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_kleak.c,v 1.2 2018/12/10 07:24:49 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -244,17 +244,23 @@
 static int
 kleak_rotate(void)
 {
+       int error = 0;
+
        mutex_enter(&kleak_mtx);
-       kleak_index++;
+       if (kleak_index + 1 >= kleak_nrounds) {
+               error = ENOENT;
+       } else {
+               kleak_index++;
+       }
        mutex_exit(&kleak_mtx);
 
+       if (error) {
+               return error;
+       }
+
        /* XXX: Should be atomic. */
        kleak_pattern_byte = kleak_pattern_list[kleak_index];
 
-       if (kleak_index >= kleak_nrounds) {
-               return ENOENT;
-       }
-
        return 0;
 }
 



Home | Main Index | Thread Index | Old Index