Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: removed signed

...

This code can result in a divide-by-zero error during the division of the signed operands sl1 and sl2.

Code Block
bgColor#FFcccc
signed long sl1, sl2, result;

/* Initialize sl1 and sl2 */

result = sl1 / sl2;

...

This compliant solution tests the suspect division operation to guarantee there is no possibility of divide-by-zero errors.

Code Block
bgColor#ccccff
signed long sl1, sl2, result;

/* Initialize sl1 and sl2 */

if ( (sl2 == 0) ) {
  /* handle error condition */
}
else {
  result = sl1 / sl2;
}

...

This code can result in a divide-by-zero error during the remainder operation on the signed operands sl1 and sl2.

Code Block
bgColor#FFcccc
signed long sl1, sl2, result;

/* Initialize sl1 and sl2 */

result = sl1 % sl2;

...

This compliant solution tests the suspect remainder operation to guarantee there is no possibility of a divide-by-zero error.

Code Block
bgColor#ccccff
signed long sl1, sl2, result;

/* Initialize sl1 and sl2 */

if ( (sl2 == 0 ) ) {
  /* handle error condition */
}
else {
  result = sl1 % sl2;
}

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="bd63c8563483dc9f-78068fdb-48d84062-bda18fbd-b6ddead05e94b6309ea90a25"><ac:plain-text-body><![CDATA[

[[ISO/IEC 9899:1999

AA. Bibliography#ISO/IEC 9899-1999]]

Section 6.5.5, "Multiplicative operators"

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="0b17e7f48a016095-a8e3c449-4cea4527-abdeb056-e9e2c64a987e7fa7ca69ca46"><ac:plain-text-body><![CDATA[

[[Seacord 05

AA. Bibliography#Seacord 05]]

Chapter 5, "Integers"

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="210fbc24b764a4e9-5f25ab8e-4444448c-83938165-2e9cd3f74cb54b428f14f531"><ac:plain-text-body><![CDATA[

[[Warren 02

AA. Bibliography#Warren 02]]

Chapter 2, "Basics"

]]></ac:plain-text-body></ac:structured-macro>

...