Re: [RFC 4/5] mtd: move mtd_oob_mode_t to shared kernel/user space

Brian Norris
2011-08-22T21:43:16Z

On Mon, Aug 22, 2011 at 1:50 AM, Artem Bityutskiy <dedekind1@gmail.com> wrote:
> On Wed, 2011-08-17 at 16:50 -0700, Brian Norris wrote:
>> +typedef enum {
>> +     MTD_OOB_PLACE,
>> +     MTD_OOB_AUTO,
>> +     MTD_OOB_RAW,
>> +} mtd_oob_mode_t;
>
> Could we get rid of this typedef and use anonymous enum instead:
>
> enum {
>        A,
>        B,
> };
>
> Indeed, we do not need it, and we do not want to pollute the user-space
> namespaces unnecessarily.

Well, we do *use* the typedef in a few kernel structs, and we will use
it in user space as well. So we may run into issues with 32-bit vs.
64-bit integers if we just stick with an int-based type, right?

Also, I'm pondering the question: do we need to worry about the
underlying numbering for such an enum? I believe there it is
theoretically possible for different compilers to choose a different
numbering scheme, potentially making user-compiled software
incompatible with the internal kernel binary. Perhaps to be safe we
could just do:

enum {
MTD_OOB_PLACE = 0,
MTD_OOB_AUTO = 1,
MTD_OOB_RAW = 2,
};

Or instead, maybe we should just switch to a __u32 type and some #defines...

Sorry if this is a lot of thinking out loud here :)

Brian