sqc 0.4.13

Software Code Quality - CERT C compliance checker
/*
 * Rule: INT35-C
 * Source: wiki
 * Status: PASS - Should NOT trigger INT35-C violation
 */

#include <stddef.h>
#include <stdint.h>
 
/* Returns the number of set bits */
size_t popcount(uintmax_t num) {
  size_t precision = 0;
  while (num != 0) {
    if (num % 2 == 1) {
      precision++;
    }
    num >>= 1;
  }
  return precision;
}
#define PRECISION(umax_value) popcount(umax_value)