Bug #2077

lots of unreachable breaks in illumos gate

Added by Milan Jurik about 2 years ago. Updated about 2 years ago.

Status:Resolved Start date:2012-02-04
Priority:Low Due date:
Assignee:Milan Jurik % Done:

100%

Category:lib - userland libraries Spent time: -
Target version:-
Difficulty:Bite-size Tags:

Description

The source code contains many unreachable breaks on different places. Unreachable code can be misleading and it is better to remove it and clean up the source code.

break-clean.patch - suggested fix (64.1 kB) Milan Jurik, 02/18/2012 07:30 pm

History

Updated by Rich Lowe about 2 years ago

You have to be careful here to make sure that the intelligence of the lint you are using, the lint everyone else is using, and the compilers we are using can all align.

I've seen cases where it was very hard, without a lot of extra work, to make them all agree on unreachability.

Hopefully you won't hit any, though, but please do check

Updated by Milan Jurik about 2 years ago

I am pretty sure that code like:

return (0);
break;

means that break is unreachable in C :-)

Updated by Rich Lowe about 2 years ago

I guess I was unclear, let me try to be more clear.

The fact that code is unreachable is easy to determine visually, how lint and the compiler decide this is less obvious in cases involving exit(), panic(), and friends. With return statements it's dead simple and you're fine, in cases that involve a non-returning function, it can really truly suck to get everything to agree.

Updated by Dan McDonald about 2 years ago

Can you confirm here in the bug's comments that the only removals are for gotos and returns?

Updated by Milan Jurik about 2 years ago

  • % Done changed from 50 to 100

This bug covers only break; unreachable after goto/continue/return/exit in the same function. It is NOT solving cross-call "notreached" like:

f() {
exit(0);
}

{
f();
break;
}

Updated by Milan Jurik about 2 years ago

Updated by Rich Lowe about 2 years ago

  • Subject changed from lots of unreachable breaks in Illumos gate to lots of unreachable breaks in illumos gate

Updated by Rich Lowe about 2 years ago

  • Status changed from In Progress to Resolved
  • Tags deleted (needs-triage)

Resolved in r13622 e5889df1eaac

Also available in: Atom PDF