bsnes icon indicating copy to clipboard operation
bsnes copied to clipboard

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

Open Marat-Tanalin opened this issue 1 year ago • 4 comments

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.

Marat-Tanalin avatar May 07 '23 18:05 Marat-Tanalin

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.

jchv avatar May 07 '23 19:05 jchv

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.

Marat-Tanalin avatar May 07 '23 20:05 Marat-Tanalin

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

orbea avatar May 07 '23 21:05 orbea

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?

jeffythedragonslayer avatar Jun 11 '23 06:06 jeffythedragonslayer