mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Phillips <phillips@arcor.de>
To: Thunder from the hill <thunder@lightweight.ods.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Generic list push/pop
Date: Sun, 18 Aug 2002 22:34:12 +0200	[thread overview]
Message-ID: <E17gWkW-00032w-00@starship> (raw)
In-Reply-To: <Pine.LNX.4.44.0208181326160.2499-100000@hawkeye.luckynet.adm>

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


  reply	other threads:[~2002-08-18 20:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-18 19:21 Daniel Phillips
2002-08-18 19:28 ` Thunder from the hill
2002-08-18 20:34   ` Daniel Phillips [this message]
2002-08-19 12:05 ` William Lee Irwin III
2002-08-19 12:32   ` Daniel Phillips
2002-08-20 13:08   ` Thunder from the hill
2002-08-20 15:30     ` Daniel Phillips
2002-08-20 15:45       ` Thunder from the hill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E17gWkW-00032w-00@starship \
    --to=phillips@arcor.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thunder@lightweight.ods.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®