unsigned long arrsize = free_array_size(poolsize);
unsigned char *arr = pool;
unsigned long len, off, hdrlen;
- unsigned long i, freearr[arrsize], num_freearr = 0;
+ /* Don't have sanitizer complain here if arrsize is 0! */
+ unsigned long i, freearr[arrsize ? arrsize : 1], num_freearr = 0;
bool free;
if (poolsize < MIN_BLOCK_SIZE)
size_t seed, \
struct name##_iter *iter) \
{ \
- /* Note &iter->i == NULL iff iter is NULL */ \
- return htable_pick(&ht->raw, seed, &iter->i); \
+ return htable_pick(&ht->raw, seed, iter ? &iter->i : NULL); \
} \
static inline UNNEEDED type *name##_first(const struct name *ht, \
struct name##_iter *iter) \
#endif
#ifdef builtin_ilog32_nz
-#define ilog32(_v) (builtin_ilog32_nz(_v)&-!!(_v))
+/* This used to be builtin_ilog32_nz(_v)&-!!(_v), which means it zeroes out
+ * the undefined builtin_ilog32_nz(0) return. But clang UndefinedBehaviorSantizer
+ * complains, so do the branch: */
+#define ilog32(_v) ((_v) ? builtin_ilog32_nz(_v) : 0)
#define ilog32_nz(_v) builtin_ilog32_nz(_v)
#else
#define ilog32_nz(_v) ilog32(_v)
#endif /* builtin_ilog32_nz */
#ifdef builtin_ilog64_nz
-#define ilog64(_v) (builtin_ilog64_nz(_v)&-!!(_v))
+#define ilog32(_v) ((_v) ? builtin_ilog32_nz(_v) : 0)
#define ilog64_nz(_v) builtin_ilog64_nz(_v)
#else
#define ilog64_nz(_v) ilog64(_v)