domenica 28 febbraio 2010

Bug-Killing Coding Standard Rules for Embedded C

http://www.netrino.com/Embedded-Systems/How-To/Bug-Killing-Standards-for-Embedded-C

4 commenti:

  1. The 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.

    RispondiElimina
  2. Rule #15 - Constants in comparisons

    When 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.

    RispondiElimina

Nota. Solo i membri di questo blog possono postare un commento.