From 267cf83fb39ce7a9aab1a063147fd6378e823819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 5 Aug 2002 05:25:26 +0000 Subject: [PATCH] Added a missing return value in port_init(). Cleaned up the code a bit. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@588 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/core/port.c | 49 +++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/src/kernel/core/port.c b/src/kernel/core/port.c index e1e6df6022..c23b855b8a 100644 --- a/src/kernel/core/port.c +++ b/src/kernel/core/port.c @@ -61,7 +61,9 @@ static int port_spinlock = 0; #define GRAB_PORT_LOCK(s) acquire_spinlock(&(s).lock) #define RELEASE_PORT_LOCK(s) release_spinlock(&(s).lock) -int port_init(kernel_args *ka) + +int +port_init(kernel_args *ka) { int i; int sz; @@ -71,12 +73,12 @@ int port_init(kernel_args *ka) // create and initialize semaphore table port_region = vm_create_anonymous_region(vm_get_kernel_aspace_id(), "port_table", (void **)&ports, REGION_ADDR_ANY_ADDRESS, sz, REGION_WIRING_WIRED, LOCK_RW|LOCK_KERNEL); - if(port_region < 0) { + if (port_region < 0) { panic("unable to allocate kernel port table!\n"); } memset(ports, 0, sz); - for(i=0; i= 0) { + for (i = 0; i < MAX_PORTS; i++) { + if (ports[i].id >= 0) dprintf("%p\tid: 0x%x\t\tname: '%s'\n", &ports[i], ports[i].id, ports[i].name); - } } return 0; } -static void _dump_port_info(struct port_entry *port) + +static void +_dump_port_info(struct port_entry *port) { int cnt; dprintf("PORT: %p\n", port); @@ -115,20 +120,22 @@ static void _dump_port_info(struct port_entry *port) dprintf("write_sem: %d\n", cnt); } -static int dump_port_info(int argc, char **argv) + +static int +dump_port_info(int argc, char **argv) { int i; - if(argc < 2) { + if (argc < 2) { dprintf("port: not enough arguments\n"); return 0; } // if the argument looks like a hex number, treat it as such - if(strlen(argv[1]) > 2 && argv[1][0] == '0' && argv[1][1] == 'x') { + if (strlen(argv[1]) > 2 && argv[1][0] == '0' && argv[1][1] == 'x') { unsigned long num = atoul(argv[1]); - if(num > KERNEL_BASE && num <= (KERNEL_BASE + (KERNEL_SIZE - 1))) { + if (num > KERNEL_BASE && num <= (KERNEL_BASE + (KERNEL_SIZE - 1))) { // XXX semi-hack // one can use either address or a port_id, since KERNEL_BASE > MAX_PORTS assumed _dump_port_info((struct port_entry *)num); @@ -145,15 +152,17 @@ static int dump_port_info(int argc, char **argv) } // walk through the ports list, trying to match name - for(i=0; i