Skip to content

remove implicit fallthroughs (#1194)#1196

Merged
kripken merged 4 commits into
WebAssembly:masterfrom
z2oh:master
Sep 20, 2017
Merged

remove implicit fallthroughs (#1194)#1196
kripken merged 4 commits into
WebAssembly:masterfrom
z2oh:master

Conversation

@z2oh

@z2oh z2oh commented Sep 19, 2017

Copy link
Copy Markdown

Fixes two implicit fall through warnings which caused building to fail.

Closes #1194

Comment thread src/tools/translate-to-fuzz.h Outdated
switch (conditions) {
case 0: if (!oneIn(4)) continue;
case 1: if (!oneIn(2)) continue;
case 0: if (!oneIn(4)) continue; break;

@dschuff dschuff Sep 19, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having it all on one line like this makes this difficult to read (i.e. it's not obvious that the continue is conditional but the break is not). Could we do

case 0:
 if (!oneIn(4)) continue;
 break;

instead?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Changed in b377dde.

@dschuff dschuff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Comment thread src/tools/translate-to-fuzz.h Outdated
case 0: if (!oneIn(4)) continue;
case 1: if (!oneIn(2)) continue;
default: if (oneIn(conditions + 1)) continue;
case 0:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since the body isn't on the same line, please add {,} for each (see other switches for the convention)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 90364e3.

@kripken

kripken commented Sep 19, 2017

Copy link
Copy Markdown
Member

Perfect, thanks! Just waiting for CI to finish before merging.

@dschuff

dschuff commented Sep 19, 2017

Copy link
Copy Markdown
Member

lol @z2oh sorry you hit a perfect storm of conflicting reviewers. This isn't the first time @kripken and I have clashed on exactly this bit of style :D

@kripken

kripken commented Sep 19, 2017

Copy link
Copy Markdown
Member

Oh sorry, I didn't notice there were previous comments - they're hidden in the diff view.

@dschuff, did we ever come to a consensus on that? Looking in the code most have the {,} but I don't remember details of discussion on the topic.

@dschuff

dschuff commented Sep 19, 2017

Copy link
Copy Markdown
Member

I think you won mostly just by virtue of having written a lot of code in that style before I did, so I didn't want to change it all :)

@kripken

kripken commented Sep 19, 2017

Copy link
Copy Markdown
Member

Heh, ok :) Anyhow, I'm not super-invested in this - if most people prefer another convention let's switch (separate from this PR of course).

But just for the record (since I'm not sure where else this is documented), my logic is that this is similar to the case of

if (..) {
  ..
} else {
  ..
}

Without {,} there is a risk of getting things wrong, and switch cases also denote separate code paths like if arms.

@dschuff

dschuff commented Sep 19, 2017

Copy link
Copy Markdown
Member

Oh hey, the translate-to-fuzz test is failing becuase... yeah this actually does change the behavior. Before, we had multiple rolls of the RNG to continue and now it's just one. Since that was probably the intended behavior, should we just auto-update the tests?

@kripken

kripken commented Sep 20, 2017

Copy link
Copy Markdown
Member

Yeah, I agree. Let's just run ./auto_update_tests.py and add that change here.

@z2oh

z2oh commented Sep 20, 2017

Copy link
Copy Markdown
Author

I ran ./auto_update_tests.py and a subsequent run of ./check.py passed on my system. Here is the output of git diff: https://hastebin.com/zayuraniho .

I know very little about the testing process of this project, so I can't really say if this is correct or not. Should I commit this change?

@dschuff

dschuff commented Sep 20, 2017

Copy link
Copy Markdown
Member

That looks about right to me. It's just the one test that's affected, and it will be affected in a random way, so it's probably correct. I'd say go ahead and commit it, and if @kripken agrees with my assessment we'll merge.

@kripken

kripken commented Sep 20, 2017

Copy link
Copy Markdown
Member

Yeah, perfect. Thanks again!

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

Successfully merging this pull request may close these issues.

3 participants