-
-
Notifications
You must be signed in to change notification settings - Fork 54
drill.c -- Avoid floating control statements #216
Copy link
Copy link
Closed
Description
Braces after control statements (if/else/do/while) should be mandatory.
Admittedly, when considered by itself, it would seem that omitting braces seems OK. However, this increases risk of bugs, especially with macros. In fact, the old dprintf() macro exposed exactly this type of risk:
// Ensure number format is set to FMT_USER (and warn if not true).
if (state->number_format == FMT_USER)
dprintf("Some debugging information here.")
else
state->number_format = FMT_USER;The above code has a bug ... it doesn't actually ever set the number format to FMT_USER.
See SEI CERT C Coding Standard EXP19-C.
Fixed with #210.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels