Silence sign conversion warnings from NClist
functions
#2812
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes warnings about sign conversion from uses of
nclistget/nclistlength
and otherNClist
functions.In a lot of the places that these functions are used, the index is an
int
instead ofsize_t
, mostly in loops. In this PR, I've fixed these local variables to besize_t
-- an alternative would be to change the API forNClist
to useint
, but unlike #2781 this still leaves >100 warnings, so there would still be lots of places that need fixing.I've opted for changing the local variables to
size_t
rather than just casting the argument tonclistget
, as this tended to fix multiple warnings in one go. There are a few places where casting is the better option, mostly where there's some interaction with a netCDFint
ID.There was one place (
libdap2/getvara.c
) where I also changed the function signature, but this was a localstatic
function and I could verify all places where it is used.I've left alone any place where there's some potentially unsafe arithmetic done with the list index, e.g.
index - 1
orindex--
, mostly in loops iterating backwards over the list. I just wanted to go for the easy, low hanging fruit here.This silences >400 warnings.