lkml.org 
[lkml]   [2012]   [Feb]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v3] Input: Add EVIOC mechanism for MT slots
> > This is resolved on the preprocessor level, so C99 or not does not
> > enter the problem. Compile-time constant, as you can see in the code
> > example in the patch summary.
>
> You're right, I didn't catch that. It will be compatible with all C
> compilers if you use a static number of slots.

Yes, but this statement is merely repeating something that has been
true since the sixties.

> However, it will break if you use a non-C99 C compiler and the code
> wants to do dynamic number of slots calculations.

Of course, which is why C99 cannot be used for portable code. And it
still has nothing to do with this patch.

> I imagine most callers would do:
>
> EVIOCGABS call on ABS_MT_SLOT;
> int num_slots = ABS_MT_SLOT.max - ABS_MT_SLOT.min
> struct INPUT_MT_REQUEST(num_slots) req;

Besides leaving a possible giant stack crash in your code, it assumes
memory is somehow magically allocated. Not good practise in low-level
programming. You wouldn't use a template this way, would you?

> This will break on non-C99 C compilers and other language compilers.

Of course, since you use the C99 dynamic stack construct, which,
again, is not portable.

> It also will lead to head-scratcher bugs when someone compiles it
> just fine in their C99 project, copies the code to another project
> with a different compiler, and is confronted with the issue.

No, since people how know C do not do things like that.

> I think this issue should be enough to rethink the interface.

No, since your issues with C99 has nothing to do with this patch.

Henrik


\
 
 \ /
  Last update: 2012-02-05 09:01    [W:0.074 / U:0.816 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site