From 6453151425085f2f1ef9edd24a6941c9a0b49c67 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 18 Apr 2025 23:02:32 -0400 Subject: share: contrib: Add note about local variables Signed-off-by: Ian Moffett --- share/misc/contrib | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/share/misc/contrib b/share/misc/contrib index 1560f37..a36c127 100644 --- a/share/misc/contrib +++ b/share/misc/contrib @@ -21,6 +21,22 @@ is_power_of_two(uint8_t n) return ((n & 0x01) == 0); } +-- +When defining local variables in functions, they +must be declared at the top: + +static void +foo(void) +{ + uint8_t byte; + uint16_t pair; + uint32_t quad; + uint64_t oct; + + ... +} +-- + When checking if an integer is 0 or not, *be explicit* unless it is a bool! Do not do this: -- cgit v1.2.3