Module Name:    src
Committed By:   riastradh
Date:           Sat Oct 15 20:11:01 UTC 2022

Modified Files:
        src/sys/dev/pci: pci_resource.c

Log Message:
pci_resource(9): vmem_create and vmem_add never fail with VM_SLEEP.

Prune dead error branches.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/pci/pci_resource.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/pci_resource.c
diff -u src/sys/dev/pci/pci_resource.c:1.1 src/sys/dev/pci/pci_resource.c:1.2
--- src/sys/dev/pci/pci_resource.c:1.1	Fri Oct 14 22:10:15 2022
+++ src/sys/dev/pci/pci_resource.c	Sat Oct 15 20:11:00 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_resource.c,v 1.1 2022/10/14 22:10:15 jmcneill Exp $ */
+/* $NetBSD: pci_resource.c,v 1.2 2022/10/15 20:11:00 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2022 Jared McNeill <jmcne...@invisible.ca>
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_resource.c,v 1.1 2022/10/14 22:10:15 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_resource.c,v 1.2 2022/10/15 20:11:00 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -161,17 +161,12 @@ static vmem_t *
 pci_create_vmem(const char *name, bus_addr_t start, bus_addr_t end)
 {
 	vmem_t *arena;
+	int error __diagused;
 
 	arena = vmem_create(name, 0, 0, 1, NULL, NULL, NULL, 0, VM_SLEEP,
 	    IPL_NONE);
-	if (arena == NULL) {
-		return NULL;
-	}
-
-	if (vmem_add(arena, start, end - start + 1, VM_SLEEP) != 0) {
-		vmem_destroy(arena);
-		arena = NULL;
-	}
+	error = vmem_add(arena, start, end - start + 1, VM_SLEEP);
+	KASSERTMSG(error == 0, "error=%d", error);
 
 	return arena;
 }

Reply via email to