Skip to contentSkip to conversation

Coding style questions

DISCUSSION Radu Voicilas 2 participants 2 messages Dec 5, 2009 – Dec 14, 2009 Kernel janitors

lore
Share & tools
lore
#0 lore raw

1. When you have a function prototype with a comment following it (which obviously it's a bad thing), like this one

u32 eprom_read(struct net_device *dev,u32 addr); //reads a 16 bits word

and want to fix it, how would one do it:

/* Read a 16 bits word. */
u32 eprom_read(struct net_device *dev, u32 addr);

or the comment should go into the implementation file ?

2. What's the kernel code style about header guards ? As far as I've seen, it's usual to do:

#ifndef HEADER_H
#define HEADER_H

and not:

#infdef _HEADER_H
#define _HEADER_H

or other variations. Does it even matter?

Thanks,
Radu.

#1 lore raw
Quoted 10 lines · Radu Voicilas

1. When you have a function prototype with a comment following it (which obviously it's a bad thing), like this one

u32 eprom_read(struct net_device *dev,u32 addr); //reads a 16 bits word

and want to fix it, how would one do it:

/* Read a 16 bits word. */
u32 eprom_read(struct net_device *dev, u32 addr);

or the comment should go into the implementation file ?

It should go in the implementation file, but common sense is always best. Be sure to read Documentation/CodingStyle.

Davidlohr