[PATCH 3/6] Change the OSTC3 macros to have a ; in the end
Linus Torvalds
torvalds at linux-foundation.org
Mon Oct 27 14:13:54 PDT 2014
On Mon, Oct 27, 2014 at 12:37 PM, Anton Lundin <glance at acc.umu.se> wrote:
>
> -#define READ_SETTING(_OSTC3_SETTING, _DEVICE_DETAIL) \
> +#define READ_SETTING(_OSTC3_SETTING, _DEVICE_DETAIL); \
That extra ';' as the first token in the macro definition seems entirely broken.
> rc = hw_ostc3_device_config_read(m_data->device, _OSTC3_SETTING, uData, sizeof(uData)); \
> if (rc == DC_STATUS_SUCCESS) \
> m_deviceDetails->_DEVICE_DETAIL(uData[0]);
I'd also suggest enclosing it all in a "do { } while (0)" (*without* a
semicolon at the end - the final semicolon should come from the user),
because otherwise
if (x)
READ_SETTING(..)
else
READ_SETTING(..);
ends up parsing cleanly by the compiler, but doing completely bogus
crap (the "else" ends up pairing with the "if" inside the macro,
instead of the "if" in the code).
Linus
More information about the subsurface
mailing list