20

So was going through the Linux kernel

Comments
  • 7
    we can only hope we don't ever go there
  • 0
    Why do a default: break; then? You can leave it out.
  • 1
    Oh cool.

    I have similar parts in my code and thought was bad.

    Good to see others do it to :D
    (in my case I often write logs in that case "we should have ended up here.."
  • 3
    @filthyranter So that there's a place to put the comment.
  • 0
    Mhm Interesting.
    10 years Linux, never went that far.
  • 2
    @filthyranter
    It's a pattern of "good programming" to include the default case.
    This makes it clear that
    a) there could be a different case that handled above.
    B) the programmer is aware of this task and c) may have taken proper action

    So for general: increase readability, decrease misunderstanding and error rate. Create more 'fool proof systems' (at least in my opinion, you can Ofc say 'more code decreases the readability - it's a guideline not a rule)
  • 1
    @Daniil I'd make a comment

    /* default case not needed */
  • 1
    @filthyranter
    In my opinion would be the same or equivalent.

    Though " default " can be checked by tools your comment not (or not that easy).
Add Comment