Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Marat-Tanalin opened this issue May 7, 2023 · 4 comments

Comments

@Marat-Tanalin
Copy link

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
Copy link
Contributor

jchv commented May 7, 2023

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
Copy link
Author

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
Copy link
Contributor

orbea commented May 7, 2023

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

@jeffythedragonslayer
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants