code consistency, usage of typedef and struct
While analyzing the code I encountered some strange usage of "struct in6_addr" and "in6_addr_t".
A good example can be found in the function at http://
At the first glance it looks like these 2 sizeof macros should return different values, but they don't, since in6_addr_t is just a typedef of "struct in6_addr". Technically this is equivalent code, but it makes reading the code a little bit awkward.
I looked into the usage of typedefs and there are few reasons why typedefs should be used, the main 2 ones are: make code more readable or make it more portable.
The readability between "struct in6_addr" and "in6_addr_t" doesn't differ too much, since the struct definition is rather small. Furthermore, one of the linux kernel hackers, Greg Kroah-Hartman, strongly recommends to use typedef only for function prototype declarations. I analyzed the usage of both in the hipl code basis and there are about 3400 occurrences of "struct in6_addr" and just 300 of the typedef keyword.
Now from the *portability point of view*: I have looked up the linux kernel code, and there is not even one typedef in the network stack for internet address structures. This means that using just "struct in6_addr" should be portable, since the linux kernel can be ported on various machines.
All in all, I strongly recommend to avoid the in6_addr_t typedef and actually get rid of it as soon as possible.
So, my actual question to you guys is, should there be a convention to avoid unnecessary typedef usage in the code and switch to a more consistent usage, _especially_ in the same codeblock (take a look at the link provided at the beginning)?
Can you help with this problem?
Provide an answer of your own, or ask Andrius Bentkus for more information if necessary.