Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/arch/xen/xenbus/xenbus_xs.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/arch/xen/xenbus/xenbus_xs.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.3 retrieving revision 1.3.2.2 diff -u -p -r1.3 -r1.3.2.2 --- src/sys/arch/xen/xenbus/xenbus_xs.c 2006/03/15 22:20:06 1.3 +++ src/sys/arch/xen/xenbus/xenbus_xs.c 2006/05/24 15:48:26 1.3.2.2 @@ -1,4 +1,4 @@ -/* $NetBSD: xenbus_xs.c,v 1.3 2006/03/15 22:20:06 bouyer Exp $ */ +/* $NetBSD: xenbus_xs.c,v 1.3.2.2 2006/05/24 15:48:26 tron Exp $ */ /****************************************************************************** * xenbus_xs.c * @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xenbus_xs.c,v 1.3 2006/03/15 22:20:06 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xenbus_xs.c,v 1.3.2.2 2006/05/24 15:48:26 tron Exp $"); #if 0 #define DPRINTK(fmt, args...) \ @@ -387,6 +387,26 @@ xenbus_read(struct xenbus_transaction *t return err; } +/* Read a node and convert it to unsigned long. */ +int +xenbus_read_ul(struct xenbus_transaction *t, + const char *dir, const char *node, unsigned long *val) +{ + char *string, *ep; + int err; + + err = xenbus_read(t, dir, node, NULL, &string); + if (err) + return err; + *val = strtoul(string, &ep, 10); + if (*ep != '\0') { + free(string, M_DEVBUF); + return EFTYPE; + } + free(string, M_DEVBUF); + return 0; +} + /* Write the value of a single file. * Returns -err on failure. */ @@ -638,7 +658,7 @@ register_xenbus_watch(struct xenbus_watc void unregister_xenbus_watch(struct xenbus_watch *watch) { - struct xs_stored_msg *msg; + struct xs_stored_msg *msg, *next_msg; char token[sizeof(watch) * 2 + 1]; int err, s; @@ -661,11 +681,11 @@ unregister_xenbus_watch(struct xenbus_wa /* Cancel pending watch events. */ simple_lock(&watch_events_lock); - while (!SIMPLEQ_EMPTY(&watch_events)) { - msg = SIMPLEQ_FIRST(&watch_events); + for (msg = SIMPLEQ_FIRST(&watch_events); msg != NULL; msg = next_msg) { + next_msg = SIMPLEQ_NEXT(msg, msg_next); if (msg->u.watch.handle != watch) continue; - SIMPLEQ_REMOVE_HEAD(&watch_events, msg_next); + SIMPLEQ_REMOVE(&watch_events, msg, xs_stored_msg, msg_next); free(msg->u.watch.vec, M_DEVBUF); free(msg, M_DEVBUF); }