Iscriviti a:
Commenti sul post (Atom)
Il Simpatico è un'area libera di discussione, di scambio di idee e di aperto confronto sui temi che più ci appassionano: dal rinnovamento dell'Italia all'ultima novità del "gadgettismo", dalla filosofia alla musica, dal mondo dell'informatica e del web al global warming ... senza scordare frizzi, lazzi e curiosità da ogni angolo del globo !!!
http://www.netrino.com/Embedded-Systems/How-To/More-Bug-Killing-Standards-for-Embedded-C
RispondiEliminaThe number and severity of bugs introduced by the original programmer can be reduced through disciplined conformance with certain coding practices, such as the placement of constants on the left side of each equivalence (==) test.
RispondiEliminahttp://www.netrino.com/Coding-Standard
RispondiEliminaRule #15 - Constants in comparisons
RispondiEliminaWhen evaluating the equality or inequality of a variable with a constant value, always place the constant value on the left side of the comparison operator.
if (0 == x)
{
/* Do this only if x is zero. */
}
Reasoning: It is always desirable to detect possible typos and as many other bugs as possible at compile-time; run-time discovery may be dangerous to the user of the product and require significant effort to locate. By following this rule, the compiler can detect erroneous attempts to assign (i.e., = instead of ==) a new value to a constant.1
Try adding some or all of the fifteen practical embedded C coding rules from this article and the preceding "Bug-Killing Coding Standard Rules for Embedded C" to your coding standard . Then follow my blog at embeddedgurus.net/barr-code for more tips to keep bugs out of your embedded system.