Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To provide a true (never negative) modulo operation, use the imod() ("integer modulo") inline function.  The number of operations it performs can be reduced to one in the case of C99.:

Code Block
bgColor#ccccff
/* modulo function giving non-negative result */
inline int imod(int i, int j) {
#if __STDC_VERSION__ >= 199901L
  return (i % j;
#else
  return) < 0 ? (i % j) + (j < 0 ? (i-j %: j) + j : i % j;
#endif
}

Risk Assessment

Recommendation

Severity

Likelihood

Remediation Cost

Priority

Level

INT10-A

1 (low)

1 (unlikely)

2 (medium)

P2

L3

...