Bug #2077

lots of unreachable breaks in illumos gate

Added by Milan Jurik over 3 years ago. Updated about 3 years ago.

Status:ResolvedStart date:2012-02-04
Priority:LowDue date:
Assignee:Milan Jurik% Done:

100%

Category:lib - userland libraries
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 Magnifier - suggested fix (64.1 KB) Milan Jurik, 2012-02-18 07:30 PM

History

#1 Updated by Rich Lowe over 3 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

#2 Updated by Milan Jurik over 3 years ago

I am pretty sure that code like:

return (0);
break;

means that break is unreachable in C :-)

#3 Updated by Rich Lowe over 3 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.

#4 Updated by Dan McDonald over 3 years ago

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

#5 Updated by Milan Jurik over 3 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;
}

#6 Updated by Milan Jurik over 3 years ago

#7 Updated by Rich Lowe about 3 years ago

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

#8 Updated by Rich Lowe about 3 years ago

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

Resolved in r13622 commit:e5889df1eaac

Also available in: Atom