In relation to issue #2954, it appears that turning some size_t length
calculations to the int that uses my_strndup() upsets coverity a bit.
Instead of dealing with such warnings each time, better address it at
the root. An inspection of all call places show that the size passed
there is always positive so we can safely use an unsigned type, and
size_t will always suit it like for strndup() where it's available.
int parse_binary(const char *source, char **binstr, int *binstrlen, char **err);
/* copies at most <n> characters from <src> and always terminates with '\0' */
-char *my_strndup(const char *src, int n);
+char *my_strndup(const char *src, size_t n);
/*
* search needle in haystack
}
/* copies at most <n> characters from <src> and always terminates with '\0' */
-char *my_strndup(const char *src, int n)
+char *my_strndup(const char *src, size_t n)
{
- int len = 0;
+ size_t len = 0;
char *ret;
while (len < n && src[len])