File system query

Valdis.Kletnieks at vt.edu Valdis.Kletnieks at vt.edu
Tue Jun 25 11:19:23 EDT 2013


On Tue, 25 Jun 2013 09:56:43 +0300, Alexandru Juncu said:
> On 23 June 2013 17:18, Dibyayan Chakraborty <dib.coolguy at gmail.com> wrote:
> > Hi,
> > I came by a really weird macro code in linux/jbd.h which is
> >
> > BUFFER_TRACE(bh,info)  do{} while(0).
> >
> > Please explain the necessity of this.
>
> I'm not familiar with that specific code, but it looks like a "no op"
> macro. Maybe the definition is the to ensure backwards or forward
> compatibility for the code that calls the macro , but now it doesn't
> do anything.

Actually, the kernel doesn't use this for forward/backward compatability
that much.  It's mostly used for handling optional code - you'll often
find stuff like this in .h files:

#ifdef CONFIG_FOOBAR_DEBUG
#define MY_TRACE printk(lots-o-oarams-here)
#else
#define MY_TRACE() do{} while(0)
#endif

That way, the main .c file will compile cleanly whether or not the CONFIG
option is selected.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 865 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130625/107ccdb6/attachment.bin 


More information about the Kernelnewbies mailing list