Eus's blog

Why do the function prototypes use extern

Submitted by Eus
on May 18, 2008 - 8:14am

It is a universal truth that with or without the extern keyword a function prototype will just do the same. So, why does almost all function prototypes in Linux kernel source code prefixed with the extern keyword?

Getting the size of a member of a struct or union

Submitted by Eus
on May 18, 2008 - 8:07am

Looking at Getting the offset of a member in a struct, I realized that you can also use the same technique to get the size of a member of a struct or a union without declaring a variable of that struct. Suppose a struct has been defined as follows:

struct person
{
	int id;
	char name [50];
	double salary;
};

Getting the offset of a member in a struct

Submitted by Eus
on May 18, 2008 - 8:02am
struct aligned_struct
{
	char a [5];
	int b;
};

Another way to use the C ternary operator (? :)

Submitted by Eus
on May 12, 2008 - 5:58am

I found in Linux kernel 2.6.21.5 in include/net/netinet_hastables.h in function __inet_lookup this interesting expression:

	return sk ? : __inet_lookup_listener(hashinfo, daddr, hnum, dif);