[lkml]   [2017]   [Jan]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH 37/50] x86/boot/e820: Use 'enum e820_type' in 'struct e820_entry'
On Sat, Jan 28, 2017 at 2:11 PM, Ingo Molnar <> wrote:
> Use a stricter type for struct e820_entry. Add a build-time check to make
> sure the compiler won't ever pack the enum into a field smaller than
> 'int'.

I'm not sure this is a good idea. In fact, I'm pretty sure it's a horrible idea.

The compiler that *users* use might decide that the "enum" fits in a
8-bit unsigned char, and decide to use that. The kernel build won't
notice and the BUG_ON() won't help, because we use a different

(Or even if it's the same compiler you can have build flags - the size
of an enum very much depends on various compiler options, particularly
"--short-enums" for gcc).

Basically, we should not use "enum"s in types exported to user space.
The size just isn't sufficiently well defined, and it's a maintenance

Use explicitly sized members only, please. No "enum".


 \ /
  Last update: 2017-01-29 00:07    [W:0.171 / U:24.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site