Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Sun, 18 Aug 2002 16:31:10 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Sun, 18 Aug 2002 16:31:09 -0400 Received: from dsl-213-023-039-196.arcor-ip.net ([213.23.39.196]:51162 "EHLO starship") by vger.kernel.org with ESMTP id ; Sun, 18 Aug 2002 16:31:09 -0400 Content-Type: text/plain; charset=US-ASCII From: Daniel Phillips To: Thunder from the hill Subject: Re: Generic list push/pop Date: Sun, 18 Aug 2002 22:34:12 +0200 X-Mailer: KMail [version 1.3.2] References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Cc: linux-kernel@vger.kernel.org Message-Id: Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1007 Lines: 33 On Sunday 18 August 2002 21:28, you wrote: > Hi, > > On Sun, 18 Aug 2002, Daniel Phillips wrote: > > #define push_list(_LIST_, _NODE_) \ > > _NODE_->next = _LIST_; \ > > _LIST_ =_NODE_; > > > > #define pop_list(_LIST_) ({ \ > > typeof(_LIST_) _NODE_ = _LIST_; \ > > _LIST_ = _LIST_->next; \ > > _NODE_; }) > > How do we protect against: > > push_list(getFuckingList(), node); > node_t node = pop_list(getFuckingList()); > > ? Couldn't this break the _LIST_ = _LIST_->next; ? Yes, there are various sloppy things there, including missing parens around args and missing wrapper around the statement. It should also be written to evaluate each arg exactly once. With all that done it will be even uglier but at least it will work reliably. -- Daniel - 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/