When subtracting two pointers, the result is signed as the subtrahend
may point at a position after the minuend, in which case it is bigger
and the result would be negative. This causes a warning in
`_zzip_strnlen`, which is supposed to return an unsigned `size_t`.
As the minuend is computed by using `memchr` on the subtrahend, we know
that it is always either `NULL` or bigger than the subtrahend. And due
to the subtraction only being performed when it is non-`NULL`, we may
simply cast the result to `size_t` to fix the issue, fixing the warning.
_zzip_strnlen(const char *p, size_t maxlen)
{
const char * stop = (char *)memchr(p, '\0', maxlen);
- return stop ? stop - p : maxlen;
+ return stop ? (size_t)(stop - p) : maxlen;
}
#endif