-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Silence sign conversion warnings from NClist
functions
#2812
Conversation
362dab4
to
599225a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is an error in this PR somewhere. When run thru github actions,
several tests are timing out.
Always called with a `size_t` and passes `n` to `qsort` which expects a `size_t` anyway
599225a
to
4e1ff16
Compare
I was a little rushed and missed a couple of places where it wasn't safe to just switch to There's a few places where it would be safe to switch to |
A much simpler alternative could be to change |
Testing something locally; I expect it to pass, but better safe than sorry. Thanks, once this passes I'll get it merged in! |
Definitely true in any function in nclist that is checking an incoming index into the list. |
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.