Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Using correct macros based on type information

...

Code Block
bgColor#ccccff
langc
#include <limits.h>
 
void func(signed long s_a) {
  signed long result;
  if (s_a == INTLONG_MIN) {
    /* Handle error */
  } else {
    result = -s_a;
  }
  /* ... */
}

...

Code Block
bgColor#ccccff
langc
#include <limits.h>

void func(signed long si_a, signed long si_b) {
  signed long result;
  if ((si_a < 0) || (si_b < 0) ||
      (si_b >= UWIDTH(signed long, ULONG_MAX)) ||
      (si_a > (INTLONG_MAX >> si_b))) {
    /* Handle error */
  } else {
    result = si1 << si2;
  }
 
  /* ... */
}

...