-
-
Notifications
You must be signed in to change notification settings - Fork 946
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
type conversion to new types to avoid unsigned int rollover and signed int overflow #7216
Conversation
GLuint was being initialized to -1 and rolling over to unsigned int max, its defined behaviour but very unnecessery. add a bool and use it for checking if allocated or not.
-1 rolls over to unsigned int max, use 0xFF instead.
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.
please do what I said with the typedefs just for the sake of having it done
any particular file you want those typedefs in |
sharedDefs? |
onto it! |
also does this mean you want all of the various getworkspace* getmonitor* etc refactored for these typedefs? |
si |
unless i typoed something, something like this? |
yeah lmk when done |
ok this went rather overboard, changed a few types and more and more and more until WORKSPACEID/MONITORID/WINDOWID was done. turned on -Wshorten-64-to-32 and fixed the related warnings and while i was there the other ones not related. |
there is still a few warnings remaining around -Wshorten-64-to-32 but thats for another PR cant catch it all in one sweep heh |
yeah id call it ready for review |
or would you? |
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.
could we also get MONITOR_INVALID
macros (like WORKSPACE_INVALID
) for -1?
When there's a will, there's a way — that way is code. sure |
there were a few uint64_t to int implicit conversions overflowing int and causing UB, make all monitor/workspaces/windows use the new typedefs. also fix the various related 64 to 32 implicit conversions going around found with -Wshorten-64-to-32
done |
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.
cheers, love ya (nohomo)
unsigned int = -1 rolls over to unsigned int max, avoid rolling over by using the new typedefs WORKSPACEID/MONITORID/WINDOWID where this occured and also since we were rolling over getmonitorid() was passed a unsigned int max value and overflowed causing UB.
as a consequence of this turning on -Wshorten-64-to-32 revealed a few other mismatches related or close to same place where i changed the type to the correct one when refactoring. still remains a few in other places but thats for a future PR.
the opengl changes im not sure about if they are correct, requires a keen eye what the intention behind the stencil calls were but same deal there, -1 to gluint rolls over to uint max.