beardypig / ghidra-emotionengine

Ghidra Processor for the Play Station 2's Emotion Engine MIPS based CPU
Apache License 2.0
198 stars 35 forks source link

Incorrect usage of & instead of &&? #37

Open asmblur opened 3 years ago

asmblur commented 3 years ago

https://github.com/beardypig/ghidra-emotionengine/blob/7a00c5ed76b8bbda682a883c7db53f5f1240548f/src/main/java/ghidra/emotionengine/MipsR5900AddressAnalyzer.java#L395

Is this an accidental usage of & instead of &&?

astrelsky commented 3 years ago

https://github.com/beardypig/ghidra-emotionengine/blob/7a00c5ed76b8bbda682a883c7db53f5f1240548f/src/main/java/ghidra/emotionengine/MipsR5900AddressAnalyzer.java#L395

Is this an accidental usage of & instead of &&?

This is a good question. The analyzer is a copy of the MipsAddressAnalyzer in Ghidra with the necessary changes for this plugin.

@emteere if you have a moment may you confirm whether this is correct or not? This is the same as line 388 in MipsAddressAnalyzer.java

beardypig commented 3 years ago

I haven't looked at the return types, but if they are all Boolean then it won't make a difference will it?

astrelsky commented 3 years ago

I haven't looked at the return types, but if they are all Boolean then it won't make a difference will it?

I was thinking about that. It wouldn't matter in c. I'm assuming it wouldn't either in java.

asmblur commented 3 years ago

Technically it should work since "true" is 1 and "false" is 0, so ("true" & "true") == "true". I was just pointing out the bug.