Everybody makes mistakes when writing comparison functions
karpov2007.medium.com
Everybody makes mistakes when writing comparison functions
1–10 of 63 posts
Re: Everybody makes mistakes when writing comparison functions
#2Regarding the OpenSSL example presented here, wouldn't any decent IDE catch an unused parameter in a function? Why is a separate static analyzer necessary for this
Re: Everybody makes mistakes when writing comparison functions
#3Re: Everybody makes mistakes when writing comparison functions
#4The author's article about comparison functions linked in the blog post is worth the read Regarding the OpenSSL example presented here, wouldn't any decent IDE catch an unused parameter in a function? Why is a separate static analyzer necessary for this
Re: Everybody makes mistakes when writing comparison functions
#5Re: Everybody makes mistakes when writing comparison functions
#6The author's article about comparison functions linked in the blog post is worth the read Regarding the OpenSSL example presented here, wouldn't any decent IDE catch an unused parameter in a function? Why is a separate static analyzer necessary for this
Because this is a nail this co-founder of PVS-Studio saw while holding the hammer he wants to sell.
By the way, it seems to me this error does not have much to do with comparison functions, it is a mistake that can be made in many kinds of functions.
Unused parameters are warned against in C (hence all the UNUSED macro hacks) and no static analyzers are going to save you if you don't address compiler warnings, they are just going to add more warnings to that pile of warnings you already have (or maybe don't get because the right warnings are not enabled).
(I'm sure their blog is full of cases a static analyzer would handle which compilers won't warn you for though)
Still surprising to see such an error in OpenSSL and like others here I would be interested to know why it was not caught.
Re: Everybody makes mistakes when writing comparison functions
#7My favorite thing about Clojure is that comparison functions work on any number of arguments and correctly test equality of nested data structures.
Re: Everybody makes mistakes when writing comparison functions
#8Re: Everybody makes mistakes when writing comparison functions
#9Re: Everybody makes mistakes when writing comparison functions
#10Unused function argument is a warning any sane compiler can spit out and turn into a hard error (so this is not really the best example of what PVS studio can do for you), which makes one wonder: why was this not caught earlier? Warnings not enabled, or ignored, and is that something which is problematic wrt something as major as OpenSSL?