LWN.net Logo

sample code buggy?

sample code buggy?

Posted Jan 3, 2008 10:46 UTC (Thu) by johill (subscriber, #25196)
Parent article: What is RCU? Part 2: Usage

The sample code looks a bit odd with

struct profile_buffer {
  long size;
  atomic_t entry[0];
};
static struct profile_buffer *buf = NULL;

[...]

atomic_t *p = buf;
Unless I'm totally misunderstanding something here it looks like the pointer assignment can't possibly be compatible?


(Log in to post comments)

sample code buggy?

Posted Jan 4, 2008 16:50 UTC (Fri) by PaulMcKenney (subscriber, #9624) [Link]

Good catch!  As you no doubt guessed, s/atomic_t/struct profile_buffer/ in the declaration of
"buf".

sample code buggy?

Posted Jan 4, 2008 16:53 UTC (Fri) by PaulMcKenney (subscriber, #9624) [Link]

Hmmm...  Too early in the morning, I guess.  Make that the two declarations of the pointer "p"
rather than "buf".  :-/

Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds