bsnes-emu / bsnes

bsnes is a Super Nintendo (SNES) emulator focused on performance, features, and ease of use.
Other
1.63k stars 154 forks source link

bsnes/heuristics/game-boy.cpp — 3 lines after `if` are indented, but not in block #281

Open Marat-Tanalin opened 1 year ago

Marat-Tanalin commented 1 year ago

Found suspicious code in bsnes/heuristics/game-boy.cpp#L277 that contains 3 lines indented, but not wrapped in a {} block, so only the first of them effectively depends on the condition:

if(serial)
  output.append("  serial: ", serial, "\n");
  output.append("  board:  ", mapper, "\n");
  output.append(Memory{}.type("ROM").size(data.size()).content("Program").text());

Not sure what this code does, but this might be a bug.

jchv commented 1 year ago

Looks like it's not a bug, just weird code formatting, probably to keep the statements aligned. Notice that only the statement covered by the conditional pertains to it.

Marat-Tanalin commented 1 year ago

Yeah, the first line just explicitly contains the variable from the condition, but the other two lines might make sense depending on that variable too.

orbea commented 1 year ago

The others are always present, only serial might be empty.

jeffythedragonslayer commented 1 year ago

I'm hesitant to recommend putting braces around that serial condition because none of the rest of the conditions in that file have braces. Would simply moving those two lines of code to below the board and Memory output lines be ok?