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

Warn on implicit switch case fallthrough #10074

Merged
merged 1 commit into from
Feb 26, 2024

Conversation

lf-
Copy link
Member

@lf- lf- commented Feb 24, 2024

This seems to have found one actual bug in fs-sink.cc: the symlink case was falling into the regular file case, which can't possibly be intentional, right?

Motivation

Trivially easy to do, catches bugs, doesn't degrade dev experience (just use [[fallthrough]], // fall through, etc to disable it if it's deliberate).

Context

https://docs.jade.fyi/gnu/gcc/gcc.html#index-Wimplicit_002dfallthrough_003d

Priorities and Process

Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

This seems to have found one actual bug in fs-sink.cc: the symlink case
was falling into the regular file case, which can't possibly be
intentional, right?
@lf- lf- requested a review from edolstra as a code owner February 24, 2024 23:55
@@ -38,6 +39,7 @@ void copyRecursive(
sink, to + "/" + name);
break;
Copy link
Member

Choose a reason for hiding this comment

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

We can also remove this break since it does nothing.

Copy link
Member Author

Choose a reason for hiding this comment

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

nope the compiler is a big fool and can't figure that out unfortunately. i tried :)

Copy link
Member

@thufschmitt thufschmitt left a comment

Choose a reason for hiding this comment

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

Good thing to have, indeed :)

The bug you fixed scared me to death at first because I thought that we'd been generating twisted Nar files since potentially the beginning of Nix. But it turns out that this copyRecursive function is actually dead code :)
Nearly the whole of libutil/git.{cc,hh} is actually dead code, I'll remove it in a subsequent PR

@thufschmitt thufschmitt merged commit 21282c3 into NixOS:master Feb 26, 2024
8 checks passed
tebowy pushed a commit to tebowy/nix that referenced this pull request Jul 11, 2024
Warn on implicit switch case fallthrough

(cherry picked from commit 21282c3)
Change-Id: I5ebbdfb6c037d2c55254f37dd391c07c2ce7443e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants