GNOME Bugzilla – Bug 729067
goom filter: left shift of 24 places cannot be represented in type 'int'
Last modified: 2014-05-01 20:20:22 UTC
In gst/goom/filters.c there is a left shift of 24 places to an integer. This can cause a problem for values over 128. For example: runtime error: left shift of 134 by 24 places cannot be represented in type 'int'.
Created attachment 275272 [details] [review] fix
Looks fine I guess, but you're fixing a compiler warning, so don't talk about run-time errors in the commit message unless you have actually seen any errors caused by this in the output :) (And then the result is put into an int array and ints are used everywhere else as well..)
I saw the pasted error when I run `make check` after building with -fsanitize=undefined. I can remove the reference to a run-time error in the commit message if you like though. Does testing input count?
Created attachment 275282 [details] [review] change precalCoef[][] to uint. The result of the first patch was put into an int array, so it was merely protecting for sign flipping due to an overflow. This patch changes the array to allocate unsigned integers. The change is a bit more intrusive, but would behave better with an overflow. Let me know which one you prefer better. Thanks for the review! :)
The runtime error bit is still confusing, since it's caused by the special '-fsanitize' option which you don't mention there. IMHO just say that you're fixing undefined behaviour, like "don't left-shift into the sign bit, the result is undefined" or somesuch. I would stick to the minimal patch required to fix this, unless you actually understand how the code affected by your changes works, or you're sure it doesn't have undesired side-effects (or it generates further warnings).
Sure! Will change the message of the first commit and push. I have read the affected code thoroughly and tested my changes, but I am not going to pretend I have a deep understanding of everything related. Half of the comments are in French! :P Also there is a big function that is just commented out. Should it remain there? I offer to translate and remove that function, if you would like me to. I know it falls into "style" changes, which is why I ask before submitting something to bugzilla.
Tim. Thanks for fixing this s/uint/Uint :)