Versions Compared

Key

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

...

Code Block
bgColor#FFcccc
langc
#define ABS(x) (((x) < 0) ? -(x) : (x))
 
void func(int n) {
  /* Validate n is within the desired range. */
  int m = ABS(++n);

  /* ... */
}

...

Code Block
bgColor#ccccff
langc
#define ABS(x) (((x) < 0) ? -(x) : (x)) /* UNSAFE */
 
void func(int n) {
  /* Validate n is within the desired range. */
  ++n;
  int m = ABS(n);

  /* ... */
}

...

Code Block
bgColor#ccccff
langc
inline int abs(int x) {
  return (((x) < 0) ? -(x) : (x));
}

void func(int n) {
  /* Validate n is within the desired range. */
  int m = abs(++n);
  /* ... */
}

...