Source-Changes-HG archive

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

[src/trunk]: src/sys/uvm Fix programming mistake: 'paddrp' is a pointer given...



details:   https://anonhg.NetBSD.org/src/rev/31e5e92878c8
branches:  trunk
changeset: 454522:31e5e92878c8
user:      maxv <maxv%NetBSD.org@localhost>
date:      Fri Sep 20 11:09:43 2019 +0000

description:
Fix programming mistake: 'paddrp' is a pointer given as argument, setting
it to NULL in the called function does not set it to NULL in the caller.

Actually, the callers of these functions do not do anything with the
special error handling, so drop the unused checks and the NULL assignments
altogether.

Found by the lgtm bot.

diffstat:

 sys/uvm/uvm_page.c    |  14 ++++----------
 sys/uvm/uvm_physseg.c |   6 +-----
 2 files changed, 5 insertions(+), 15 deletions(-)

diffs (83 lines):

diff -r aab2e2aa05d3 -r 31e5e92878c8 sys/uvm/uvm_page.c
--- a/sys/uvm/uvm_page.c        Fri Sep 20 10:54:07 2019 +0000
+++ b/sys/uvm/uvm_page.c        Fri Sep 20 11:09:43 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_page.c,v 1.199 2019/03/14 19:10:04 kre Exp $       */
+/*     $NetBSD: uvm_page.c,v 1.200 2019/09/20 11:09:43 maxv Exp $      */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.199 2019/03/14 19:10:04 kre Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.200 2019/09/20 11:09:43 maxv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_uvm.h"
@@ -629,10 +629,7 @@
                        panic("uvm_page_physget: called _after_ bootstrap");
 
                /* Try to match at front or back on unused segment */
-               if (uvm_page_physunload(lcv, freelist, paddrp) == false) {
-                       if (paddrp == NULL) /* freelist fail, try next */
-                               continue;
-               } else
+               if (uvm_page_physunload(lcv, freelist, paddrp))
                        return true;
        }
 
@@ -644,10 +641,7 @@
 #endif
        {
                /* Try the front regardless. */
-               if (uvm_page_physunload_force(lcv, freelist, paddrp) == false) {
-                       if (paddrp == NULL) /* freelist fail, try next */
-                               continue;
-               } else
+               if (uvm_page_physunload_force(lcv, freelist, paddrp))
                        return true;
        }
        return false;
diff -r aab2e2aa05d3 -r 31e5e92878c8 sys/uvm/uvm_physseg.c
--- a/sys/uvm/uvm_physseg.c     Fri Sep 20 10:54:07 2019 +0000
+++ b/sys/uvm/uvm_physseg.c     Fri Sep 20 11:09:43 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_physseg.c,v 1.9 2018/01/21 17:58:43 christos Exp $ */
+/* $NetBSD: uvm_physseg.c,v 1.10 2019/09/20 11:09:43 maxv Exp $ */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -471,7 +471,6 @@
        seg = HANDLE_TO_PHYSSEG_NODE(upm);
 
        if (seg->free_list != freelist) {
-               paddrp = NULL;
                return false;
        }
 
@@ -516,7 +515,6 @@
                panic("%s: unload attempted after uvm_page_init()\n", __func__);
        /* any room in this bank? */
        if (seg->avail_start >= seg->avail_end) {
-               paddrp = NULL;
                return false; /* nope */
        }
 
@@ -662,7 +660,6 @@
        seg = VM_PHYSMEM_PTR(psi);
 
        if (seg->free_list != freelist) {
-               paddrp = NULL;
                return false;
        }
 
@@ -717,7 +714,6 @@
 
        /* any room in this bank? */
        if (seg->avail_start >= seg->avail_end) {
-               paddrp = NULL;
                return false; /* nope */
        }
 



Home | Main Index | Thread Index | Old Index