Now always prints out a message if the searched sem could not be found, and not

only under certain conditions.
Now also accepts decimal numbers as IDs.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13973 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-08-18 15:11:18 +00:00
parent e5c0e4a655
commit f79ba0f9ba
+10 -10
View File
@@ -114,31 +114,29 @@ dump_sem(struct sem_entry *sem)
static int static int
dump_sem_info(int argc, char **argv) dump_sem_info(int argc, char **argv)
{ {
int i; addr_t num;
int32 i;
if (argc < 2) { if (argc < 2) {
kprintf("sem: not enough arguments\n"); kprintf("sem: not enough arguments\n");
return 0; return 0;
} }
// if the argument looks like a hex number, treat it as such num = strtoul(argv[1], NULL, 0);
if (strlen(argv[1]) > 2 && argv[1][0] == '0' && argv[1][1] == 'x') {
unsigned long num = strtoul(argv[1], NULL, 16);
if (num > KERNEL_BASE && num <= (KERNEL_BASE + (KERNEL_SIZE - 1))) { if (!IS_USER_ADDRESS(num)) {
// XXX semi-hack
dump_sem((struct sem_entry *)num); dump_sem((struct sem_entry *)num);
return 0; return 0;
} else { } else if (num > 0) {
unsigned slot = num % sMaxSems; uint32 slot = num % sMaxSems;
if (sSems[slot].id != (int)num) { if (sSems[slot].id != (int)num) {
kprintf("sem 0x%lx doesn't exist!\n", num); kprintf("sem 0x%lx (%ld) doesn't exist!\n", num, num);
return 0; return 0;
} }
dump_sem(&sSems[slot]); dump_sem(&sSems[slot]);
return 0; return 0;
} }
}
// walk through the sem list, trying to match name // walk through the sem list, trying to match name
for (i = 0; i < sMaxSems; i++) { for (i = 0; i < sMaxSems; i++) {
@@ -148,6 +146,8 @@ dump_sem_info(int argc, char **argv)
return 0; return 0;
} }
} }
kprintf("sem \"%s\" doesn't exist!\n", argv[1]);
return 0; return 0;
} }