Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Sun, 9 Jun 2002 08:02:56 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Sun, 9 Jun 2002 08:02:56 -0400 Received: from loewe.cosy.sbg.ac.at ([141.201.2.12]:60903 "EHLO loewe.cosy.sbg.ac.at") by vger.kernel.org with ESMTP id ; Sun, 9 Jun 2002 08:02:54 -0400 Date: Sun, 9 Jun 2002 14:02:50 +0200 (MET DST) From: "Thomas 'Dent' Mirlacher" To: OGAWA Hirofumi cc: Lightweight patch manager , Linux Kernel Mailing List , Linus Torvalds Subject: Re: [PATCH][2.5] introduce list_move macros In-Reply-To: <87sn3wy8p2.fsf@devron.myhome.or.jp> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 9 Jun 2002, OGAWA Hirofumi wrote: > Lightweight patch manager writes: > > > This is the only _global_ patch about the list_move macros, which means > > introducing them. Here they are: > > > > --- linus-2.5/include/linux/list.h Sun Jun 9 04:17:14 2002 > > +++ thunder-2.5/include/linux/list.h Sun Jun 9 05:07:02 2002 > > @@ -174,6 +174,24 @@ > > for (pos = (head)->next, n = pos->next; pos != (head); \ > > pos = n, n = pos->next) > > > > +/** > > + * list_move - move a list entry from a right after b > > + * @list the entry to move > > + * @head the entry to move after > > + */ > > +#define list_move(list,head) \ > > + list_del(list); \ > > + list_add(list,head) > > + > > +/** > > + * list_move_tail - move a list entry from a right before b > > + * @list the entry to move > > + * @head the entry that will come after ours > > + */ > > +#define list_move(list,head) \ > ^^^^ > Probably typo. list_move_tail. > > > + list_del(list); \ > > + list_add_tail(list,head) > > + > > #endif /* __KERNEL__ || _LVM_H_INCLUDE */ > > > > #endif > > if (check_something(x)) > list_move(p, head); > > In the above case, these seems unsafe. So, shouldn't these use > `do {} while(0)' or `inline function'? another possible solution would be: static __inline__ void list_move(list_t *list, struct list_t *head) { __list_del(list->prev, list->next); list_add(list, head); } static __inline__ void list_move_tail(list_t *list, struct list_t *head) { __list_del(list->prev, list->next); list_add_tail(list, head); } this gets rid of the problem described above, adds inline advantages removes zeroing of entry->(next|prev) ... which is not needed for move tm -- in some way i do, and in some way i don't. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/