On Friday 2012-07-27 12:34, Sam Ravnborg wrote:
>> +#ifndef _VMCI_COMMONINT_H_
>> +#define _VMCI_COMMONINT_H_
>> +
>> +#include <linux/printk.h>
>> +#include <linux/vmw_vmci_defs.h>
>
>Use inverse chrismas tree here.
>Longer include lines first, and soret alphabetically when
>lines are of the same length.
So that's where unreadable include lists come from.
Depth-first lexicographically-sorted is a lot less hassle,
especially when it comes to merging patches that each
add one different include.
>> +/*
>> + * Utilility function that checks whether two entities are allowed
>> + * to interact. If one of them is restricted, the other one must
>> + * be trusted.
>> + */
>> +static inline bool vmci_deny_interaction(uint32_t partOne,
>> + uint32_t partTwo)
>
>The kernel types are u32 not uint32_t - these types belongs in user-space.
Not really. uint32_t is the C99 type for a 32-bit quantity, and I see
absolutely zero reason not to use standardized things. The only
exception are header files visible to user space where __u32 should
be used for (obscure) reasons of avoiding naming clashes.
(Obscure because uint32_t is always supposed to be 32 bits.)
On Thu, Aug 02, 2012 at 09:50:02PM +0200, Jan Engelhardt wrote:
>
> On Friday 2012-07-27 12:34, Sam Ravnborg wrote:
> >> +#ifndef _VMCI_COMMONINT_H_
> >> +#define _VMCI_COMMONINT_H_
> >> +
> >> +#include <linux/printk.h>
> >> +#include <linux/vmw_vmci_defs.h>
> >
> >Use inverse chrismas tree here.
> >Longer include lines first, and soret alphabetically when
> >lines are of the same length.
>
> So that's where unreadable include lists come from.
> Depth-first lexicographically-sorted is a lot less hassle,
> especially when it comes to merging patches that each
> add one different include.
This is applied in many parts of the kernels and has some benefits:
- easy to spot duplicates
- clash is less likely when two commit adds includes
- easy to do so it looks the same across different files
Obviously <linux/*> comes before include <asm/*> as this is
separate blocks of includes.
net/ and arch/x86/ is two places where this is getting the norm,
and these are trendsetters for the rest of the kernel.
>
> >> +/*
> >> + * Utilility function that checks whether two entities are allowed
> >> + * to interact. If one of them is restricted, the other one must
> >> + * be trusted.
> >> + */
> >> +static inline bool vmci_deny_interaction(uint32_t partOne,
> >> + uint32_t partTwo)
> >
> >The kernel types are u32 not uint32_t - these types belongs in user-space.
>
> Not really. uint32_t is the C99 type for a 32-bit quantity, and I see
> absolutely zero reason not to use standardized things.
Found the following somewhere on the net:
On Mon, 29 Nov 2004, Paul Mackerras wrote:
>
> uint32_t is defined to be exactly 32 bits wide, so where's the problem
> in using it instead of __u32 in the headers that describe the
> user/kernel interface? (Ditto for uint{8,16,64}_t, of course.
Ok, this discussion has gone on for too long anyway, but let's make it
easier for everybody. The kernel uses u8/u16/u32 because:
- the kernel should not depend on, or pollute user-space naming.
YOU MUST NOT USE "uint32_t" when that may not be defined, and
user-space rules for when it is defined are arcane and totally
arbitrary.
...
See http://yarchive.net/comp/linux/kernel_headers.html for additional
rationale. (Second mail listed).
Sam
On Thursday 2012-08-02 22:22, Sam Ravnborg wrote:
>> On Friday 2012-07-27 12:34, Sam Ravnborg wrote:
>> >> +#ifndef _VMCI_COMMONINT_H_
>> >> +#define _VMCI_COMMONINT_H_
>> >> +
>> >> +#include <linux/printk.h>
>> >> +#include <linux/vmw_vmci_defs.h>
>> >
>> >Use inverse chrismas tree here.
>> >Longer include lines first, and soret alphabetically when
>> >lines are of the same length.
>>
>> So that's where unreadable include lists come from.
>> Depth-first lexicographically-sorted is a lot less hassle,
>> especially when it comes to merging patches that each
>> add one different include.
>This is applied in many parts of the kernels and has some benefits:
>- easy to spot duplicates
>- clash is less likely when two commit adds includes
Sorting already addresses the two, the christmas thing (for
files in a single dir) seems like adding no extra value.
>>>The kernel types are u32 not uint32_t - these types belongs in user-space.
>Found the following somewhere on the net:
>
>| - the kernel should not depend on, or pollute user-space naming.
>| YOU MUST NOT USE "uint32_t" when that may not be defined, and
>| user-space rules for when it is defined are arcane and totally
>| arbitrary.
I can see the reasoning for header files, but it seems
irrelevant for code, in particular .c files, that never
practically get exposed to userspace.