Re: [PATCH v2 03/15] [media] adv7180: Use inline function instead of macro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 02/02/2015 02:36 PM, Mauro Carvalho Chehab wrote:
Em Fri, 23 Jan 2015 16:52:22 +0100
Lars-Peter Clausen <lars@xxxxxxxxxx> escreveu:

Use a inline function instead of a macro for the container_of helper for
getting the driver's state struct from a control. A inline function has the
advantage that it is more typesafe and nicer in general.

I don't see any advantage on this.

See: container_of is already a macro, and it is written in a way that, if
you use it with inconsistent values, the compilation will break.

Yes, container_of is a macro, because it needs to be a macro. Compilation will also not always break if you pass in a incorrect type, it might succeed with even generating a warning. Furthermore if compilation breaks the error message is completely incomprehensible. Using a function instead makes sure that the error message you get is in the style of "passing argument of wrong type to function, expected typeX, got typeY".


Also, there's the risk that, for whatever reason, gcc to decide to not
inline this.

If the compiler does not inline this it probably has a good reason to do so. Not inlining this will not break the functionality, so it is not a problem.

- Lars
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux