C code Ghidra decompile results in syntax I am unfamiliar with

I am working on reversing a simple binary using Ghidra. The decompile results in this line of code

if ((param_1 != 4) && (func0(param_1 + 1), param_1 + 1 == 0x32))
The param_1+1==0x32 section is confusing me as I’m just not familiar with the syntax and am not sure what it is doing inside a boolean expression.

>Solution :

That’s the comma operator. In this case, it’s just unnecessarily confusing, as an alternative decompilation could have avoided it, e.g., these are equivalent:

if ((param_1 != 4) && (func0(param_1 + 1), param_1 + 1 == 0x32)) {
    doStuff();
}
if (param_1 != 4) {
    func0(param_1 + 1);
    if(param_1 + 1 == 0x32) {
        doStuff();
    }
}

Leave a Reply