exiv2 icon indicating copy to clipboard operation
exiv2 copied to clipboard

use isgreater

Open neheb opened this issue 9 months ago • 3 comments

neheb avatar Mar 17 '25 19:03 neheb

What's the benefit of using std::isgreater? It's more verbose. Also some of these changes look like they would change behavior. For example, replacing != with std::isgreater` doesn't look right.

kevinbackhouse avatar Apr 03 '25 10:04 kevinbackhouse

the original idea came from https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-integer-sign-comparison.html

Comparing a float number against 0 is also not quite safe.

neheb avatar Apr 03 '25 19:04 neheb

I see. According to this document, isgreater behaves exactly the same as >, except it will never trigger an exception. I assume the word "exception" here means a SIGFPE rather than a C++ exception which we could catch. That sounds like a good change for us, because I don't think we ever want to trigger a SIGFPE, especially when we're used as a library rather than as a standalone application.

But please don't replace the == and != operators, because that could change the behavior of the code. Also, there's no need because those operators are non-signaling.

kevinbackhouse avatar Apr 18 '25 11:04 kevinbackhouse

@neheb: Please could you revert the changes to the == and != operators? I think we should only replace the > operator.

kevinbackhouse avatar Aug 13 '25 17:08 kevinbackhouse