All of lore.kernel.org
 help / color / mirror / Atom feed
* kernel list / container_of aka list_entry question
@ 2005-12-25 16:50 Mateusz Berezecki
  2005-12-25 17:24 ` Fawad Lateef
  0 siblings, 1 reply; 6+ messages in thread
From: Mateusz Berezecki @ 2005-12-25 16:50 UTC (permalink / raw)
  To: Linux Kernel Mailing List, kernel-mentors

Hello list readers,

I have two questions and I'll keep them short

First one is about list_entry definition which is just a wrapper to
container_of with exactly the same arguments (namely, ptr, type, member)
whereas container_of is defined as follows

/**
 * container_of - cast a member of a structure out to the containing structure
 *
 * @ptr:        the pointer to the member.
 * @type:       the type of the container struct this is embedded in.
 * @member:     the name of the member within the struct.
 *
 */
#define container_of(ptr, type, member) ({                      \
        const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
        (type *)( (char *)__mptr - offsetof(type,member) );})


My question is why is there a '0' inside a definition?

The second question is why the following code generates errors
during compilation. list.h header file is included.

        struct atheros_priv *priv = ieee80211_priv(dev); /* line number 141 */
	struct list_head *iterator;
	

	list_for_each(iterator, &priv->rxbuf.list) {
		struct ath_buf *bf = list_entry(iterator, (struct ath_buf), list);

		/* ... some operations on *bf here ... */
	}

and errors are as follows

  CC [M]  /home/mb/atheros/transmit_receive.o
  /home/mb/atheros/transmit_receive.c: In function 'ath_startrecv':
  /home/mb/atheros/transmit_receive.c:141: error: syntax error before ')' token
  /home/mb/atheros/transmit_receive.c:141: error: '__mptr' undeclared
(first use in this function)
  /home/mb/atheros/transmit_receive.c:141: error: (Each undeclared
identifier is reported only once
  /home/mb/atheros/transmit_receive.c:141: error: for each function it
appears in.)
  /home/mb/atheros/transmit_receive.c:141: error: syntax error before ';' token
  /home/mb/atheros/transmit_receive.c:141: error: syntax error before ')' token
  /home/mb/atheros/transmit_receive.c:141: error: syntax error before '(' token
  /home/mb/atheros/transmit_receive.c:141: error: 'list' undeclared
(first use in this function)
  make[2]: *** [/home/mb/atheros/transmit_receive.o] Error 1


I'd appreciate if someone could help me with this problem.

kind regards
Mateusz Berezecki

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-12-25 18:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-25 16:50 kernel list / container_of aka list_entry question Mateusz Berezecki
2005-12-25 17:24 ` Fawad Lateef
2005-12-25 18:10   ` Michael Buesch
2005-12-25 18:28     ` Mateusz Berezecki
2005-12-25 18:55       ` Fawad Lateef
2005-12-25 18:30   ` Mateusz Berezecki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.