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

fix: Unreachable code #2488

Merged
merged 1 commit into from
Sep 20, 2018
Merged

Conversation

Egor18
Copy link
Contributor

@Egor18 Egor18 commented Sep 20, 2018

Fix unreachable code (#2483 Warning 2)

I'm not quite sure what to do with that one, but there is definitely an error here (unreachable code):

if (content[off] == '\r') {
    if (content[off] == '\n') {

@@ -691,7 +691,7 @@ private int getEndOfComment(char[] content, int maxOff, int off) {
if (content[off] == '\r') {
//we have found end of this comment
//skip windows \n too if any
if (content[off] == '\n') {
if (off < maxOff && content[off + 1] == '\n') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, it needs + 1. But also in first part of condition. Like this:
if (off + 1 < maxOff && content[off + 1] == '\n')
OK?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But why? The maximum value of maxOff is content.length - 1 (see the upper lines), so it seems like a valid bounds check to me.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You are right! So it is OK. Thank you.

@pvojtechovsky pvojtechovsky merged commit 7df31e5 into INRIA:master Sep 20, 2018
@Egor18 Egor18 deleted the fixUnreachableCode branch October 5, 2018 09:30
@monperrus monperrus mentioned this pull request Oct 10, 2018
4 tasks
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.

2 participants