Re: Doubt in linux/list.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Libin Varghese wrote:

>>> #define INIT_LIST_HEAD(ptr) do { \
>>>       (ptr)->next = (ptr); (ptr)->prev = (ptr); \
>>> } while (0)

> I understand that it is neccessary for a block of statments, but we are
> they using it for a single statement

(ptr)->next = (ptr); <= First statement.
(ptr)->prev = (ptr); <= Second one.

So, here, there are two statements.

Of course, if there's a single statement, no need to use the do {}
while(0) trick:

#define foo(a) bar(42,a+42)

Sincerly,

Thomas
-- 
Thomas Petazzoni
thomas.petazzoni@xxxxxxxx

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux