Is there an option to disable the newly added vd: prefer explicit comparison against zero for non-bool conditions feature in IDA 9.4? If there isn’t one currently, could you please consider adding a toggle for it?
The reason I’m asking is that this explicit C++ coding style feels rather verbose and doesn’t quite align with the common coding habits of most C++ programmers, who typically prefer implicit checks (e.g., if (ptr) instead of if (ptr != nullptr)).
Source code:
#include <windows.h>
#include <time.h>
void* ppp = (void*)GetTickCount64();
int main()
{
if (ppp)
{
return GetTickCount()+1;
}
return (int)_time32(NULL);
}
Perhaps a more reasonable solution would be an automatic/smart selection based on the underlying type:
If the result type is a boolean or a pointer, it would be better to retain the old IDA 9.3 behavior (using implicit checks). However, if the type is an enum or a named constant, applying the new IDA 9.4 explicit comparison makes perfect sense, as it conveys the exact meaning.
For example:
IDA 9.3:
normalizeState = this->_normalizeState;
if ( normalizeState )
{
IDA 9.4:
normalizeState = this->_normalizeState;
if ( normalizeState != NormalizeState_None )
{
In the 9.4 example, explicitly showing which enum value is being compared makes the intent much clearer and greatly improves readability. On the other hand, applying this explicit comparison to pointers or booleans just feels like redundant boilerplate.
Hi!
Thanks for explaining your perspective. Indeed, at this moment, you can’t switch off this behavior. This came from a deliberate decision, and here’s the reasoning:
Booleans are untouched (never compared against boolean constant).
For enums and plain integers, now we explicitly compare them against zero.
For pointers, now we compare them against nullptr.
So, from that angle, it’s more of a differentiation/disambiguation than just redundant “noise”. It can be considered an improvement, as it’s easier to tell which one is which.
But we’ll let the community speak if this is a behavior they want to leave or adjust - so we’ll keep an eye on the feedback.
Hurry with feedback.
Obviously explicitly showing is better for the rookie understanding. On another side, when you dissect complicated code overloaded by non-significant lines (inlined C++ STL for example) any additional noise, produced by IDA just for fun, is unwelcomed.
It may be compromise to make common “rookie/nightmare” switch in settings that turns off newbies bells and whistles in pro mode.