Download raw body.
use size_t for loop indices to avoid signedness warnings
On Thu, 17 Dec 2020 21:48:42 +0100, Stefan Sperling wrote:
> Note that the condition i >= 0 is always true for an unsigned type.
> The loop no longer stops iterating and eventually attempts to index
> the array path_list_input with a very large value after i overflows.
>
> I guess changing i to ssize_t would be one possibility, but I don't
> know if that will bring back the warnings you were trying to avoid.
> So instead I have removed the assumption that i can become negative:
You could also just iterate over the number of items instead of the
indexes into the array and move the decrement to immediately before
the call to got_pathlist_insert() to adjust from item number to
array index. For example:
for (i = nitems(path_list_input); i > 0; ) {
i--;
err = got_pathlist_insert(NULL, &paths, path_list_input[i],
NULL);
if (err) {
test_printf("%s\n", __func__, err->msg);
return 0;
}
}
Or alternately without the standalone decrememnt:
err = got_pathlist_insert(NULL, &paths, path_list_input[--i],
NULL);
- todd
use size_t for loop indices to avoid signedness warnings