Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KZ40n-0004oC-Er for mharc-grub-devel@gnu.org; Fri, 29 Aug 2008 09:27:37 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KZ40k-0004lE-Sz for grub-devel@gnu.org; Fri, 29 Aug 2008 09:27:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KZ40i-0004iD-0S for grub-devel@gnu.org; Fri, 29 Aug 2008 09:27:34 -0400 Received: from [199.232.76.173] (port=37139 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KZ40h-0004i0-O6 for grub-devel@gnu.org; Fri, 29 Aug 2008 09:27:31 -0400 Received: from mail.dasr.de ([217.69.77.164]:4883) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KZ40h-0008Qa-MA for grub-devel@gnu.org; Fri, 29 Aug 2008 09:27:31 -0400 Received: from c-24-147-59-43.hsd1.ma.comcast.net ([24.147.59.43] helo=plato.walfield.org.walfield.org) by mail.dasr.de with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1KZ40e-0001yj-50; Fri, 29 Aug 2008 15:27:28 +0200 Date: Fri, 29 Aug 2008 15:27:21 +0200 Message-ID: <87ljygkl3a.wl%neal@walfield.org> From: "Neal H. Walfield" To: The development of GRUB 2 In-Reply-To: <87d4jsgfpz.fsf@xs4all.nl> References: <87d4jsgfpz.fsf@xs4all.nl> User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?ISO-8859-4?Q?Shij=F2?=) APEL/10.6 Emacs/21.4 (i486-pc-linux-gnu) MULE/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) Cc: "Yoshinori K. Okuji" Subject: Re: Handlers X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Aug 2008 13:27:36 -0000 I know know why you call this a handler; it seems to me that it is just a semi-generic list package. Am I missing something? You can find a slighly more flexible and generic implementation here: http://cvs.savannah.gnu.org/viewvc/hurd-l4/viengoos/list.h?root=hurd&view=markup I've been using that for a while and am quite satisfied with it. Perhaps you'll find it useful. Neal Two comments: At Fri, 29 Aug 2008 14:36:56 +0200, Marco Gerards wrote: > +void > +grub_handler_unregister (grub_handler_t *head, grub_handler_t handler) > +{ > + grub_handler_t *p, q; > + > + for (p = head, q = *p; q; p = &(q->next), q = q->next) ^^^^^^ ^^^^^^^^^^^ This is a bit inconsistent. for (p = head, q = *head; q; p = &(q->next), q = q->next) or for (p = head, q = *p; q; p = &(q->next), q = *p) Or, more succinctly: for (p = head; (q = *p); p = &(q->next)) > +int > +grub_handler_iterate (grub_handler_t head, > + int (*hook) (const grub_handler_t handler)) > +{ > + grub_handler_t p; > + > + for (p = head; p; p = p->next) > + if (hook (p)) > + break; > + > + return 0; > +} A suggestion: when HOOK returns a non-zero value, return that from the function: for (p = head; p; p = p->next) { int ret = hook (p); if (ret) return ret; } return 0;