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 some warnings/bugs found by clang-tidy #8812

Merged
merged 4 commits into from
Aug 19, 2023
Merged

Conversation

yorickvP
Copy link
Contributor

Motivation

I ran clang-tidy (bear make && run-clang-tidy.py), it found a few things, ranging from mostly harmless to potential crash.

Context

  • use-after-move in toJSON, cc @Ericson2314
  • non-final virtual methods called in destructors, this would be horrible for anyone ever running into it
  • use-after-move in FileTransfer::download. Relied on undefined behaviour, might have worked.
  • unintended fallthrough in SimpleLogger. Just caused some dead code.

Checklist for maintainers

Maintainers: tick if completed or explain if not relevant

  • agreed on idea
  • agreed on implementation strategy
  • tests, as appropriate
    • functional tests - tests/**.sh
    • unit tests - src/*/tests
    • integration tests - tests/nixos/*
  • documentation in the manual
  • documentation in the internal API docs
  • code and comments are self-explanatory
  • commit message explains why the change was made
  • new feature or incompatible change: updated release notes

Priorities

Add 👍 to pull requests you find important.

Virtual methods are no longer valid once the derived destructor has
run. This means the compiler is free to optimize them to be
non-virtual.

Found using clang-tidy
std::move(state->data) and data.empty() were called in a loop, and
could run with no other threads intervening. Accessing moved objects
is undefined behavior, and could cause a crash.
@roberth roberth merged commit 10afcf0 into NixOS:master Aug 19, 2023
@roberth
Copy link
Member

roberth commented Aug 19, 2023

Thanks @yorickvP!

inclyc added a commit to inclyc/nix that referenced this pull request Sep 28, 2023
This is an NFC PR that splits epilogue & prologue from parser.

As mentioned in NixOS#8812, we can add static checking tools & auto
formatting for these files, but if it is written .y directly, the clang
parser cannot understand the code is actually "C++".
inclyc added a commit to inclyc/nix that referenced this pull request Sep 29, 2023
This is an NFC PR that splits epilogue & prologue from parser.

As mentioned in NixOS#8812, we can add static checking tools & auto
formatting for these files, but if it is written .y directly, the clang
parser cannot understand the code is actually "C++".
inclyc added a commit to inclyc/nix that referenced this pull request Oct 5, 2023
This is an NFC PR that splits epilogue & prologue from parser.

As mentioned in NixOS#8812, we can add static checking tools & auto
formatting for these files, but if it is written .y directly, the clang
parser cannot understand the code is actually "C++".
@fricklerhandwerk fricklerhandwerk added the build-problem Nix fails to compile or test; also improvements to build process label Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build-problem Nix fails to compile or test; also improvements to build process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants