[asterisk-dev] Update coding guidelines
SF Markus Elfring
elfring at users.sourceforge.net
Sun Dec 31 00:50:19 MST 2006
> How does it demonstrate bad habits? It does not change the string in
> any way, it doesn't cause any compiler or system problems.
The const specifier is omitted. The address for a string literal is
assigned to the variable "name" that points to a mutable character.
The value of the pointer must be changed if an instruction will try to
update this character array. Otherwise, the code builds on undefined
behavior.
Two other variables show a programming style that may be a matter of
taste. How do you think about the following wording?
char const prefix[] = "pre";
char const postfix[] = "post";
> It's just a choice in how it was coded.
I expect from a coding guideline that examples are shown that are
completely correct and are not dangerous.
> Although the author was probably not aware of the distinction, it does
> not violate any sorts of rules that would make it buggy.
Such examples are often used to copy and paste something into own
software. Would you like to risk access violations in real applications?
Regards,
Markus
More information about the asterisk-dev
mailing list