TauLabs/TauLabs — pull request #688 by lilvinz (2013-06-25 21:40:26+00:00)
Title: Short enums

This fixes a very subtle bug of uninitialized memory usage discovered here:

https://github.com/TauLabs/TauLabs/blob/next/flight/Modules/ManualControl/transmitter_control.c#L1016

current_error_code as an enum has a size of 4 bytes but SystemAlarmsManualControlGet() only write the lowest of them. So using current_error_code in a compare without casting it to uint8_t leads to depending on uninitialized memory.
I could very well imagine that the same thing happens elsewhere in the code base without having checked.

Adding -fshort-enums tells the compiler to make enums only as wide as necessary to hold all defined values which fixes this problem as well as probably saving some memory.