diff options
author | Jade Lovelace <lix@jade.fyi> | 2024-08-04 20:19:58 -0700 |
---|---|---|
committer | Jade Lovelace <lix@jade.fyi> | 2024-08-08 14:53:17 -0700 |
commit | e34833c0253340f47dc0add8609eb86cf9cba19b (patch) | |
tree | 83e196e01ed4197e8f413f21d16b93cdd60f3d63 /tests/unit | |
parent | 370ac940dd7816ad4052fafa4e0f8d17784fa16b (diff) |
tree-wide: fix a pile of lints
This:
- Converts a bunch of C style casts into C++ casts.
- Removes some very silly pointer subtraction code (which is no more or
less busted on i686 than it began)
- Fixes some "technically UB" that never had to be UB in the first
place.
- Makes finally follow the noexcept status of the inner function. Maybe
in the future we should ban the function from not being noexcept, but
that is not today.
- Makes various locally-used exceptions inherit from std::exception.
Change-Id: I22e66972602604989b5e494fd940b93e0e6e9297
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/libstore/filetransfer.cc | 3 | ||||
-rw-r--r-- | tests/unit/libutil/closure.cc | 2 | ||||
-rw-r--r-- | tests/unit/libutil/generator.cc | 5 | ||||
-rw-r--r-- | tests/unit/libutil/tests.cc | 6 |
4 files changed, 10 insertions, 6 deletions
diff --git a/tests/unit/libstore/filetransfer.cc b/tests/unit/libstore/filetransfer.cc index 6e8cf3bbe..71e7392fc 100644 --- a/tests/unit/libstore/filetransfer.cc +++ b/tests/unit/libstore/filetransfer.cc @@ -6,7 +6,6 @@ #include <future> #include <gtest/gtest.h> #include <netinet/in.h> -#include <stdexcept> #include <string> #include <string_view> #include <sys/poll.h> @@ -130,7 +129,7 @@ serveHTTP(std::string status, std::string headers, std::function<std::string()> TEST(FileTransfer, exceptionAbortsDownload) { - struct Done + struct Done : std::exception {}; auto ft = makeFileTransfer(); diff --git a/tests/unit/libutil/closure.cc b/tests/unit/libutil/closure.cc index b4eaad6f9..8cac9a9fd 100644 --- a/tests/unit/libutil/closure.cc +++ b/tests/unit/libutil/closure.cc @@ -28,7 +28,7 @@ TEST(closure, correctClosure) { } TEST(closure, properlyHandlesDirectExceptions) { - struct TestExn {}; + struct TestExn : std::exception {}; EXPECT_THROW( computeClosure<string>( {"A"}, diff --git a/tests/unit/libutil/generator.cc b/tests/unit/libutil/generator.cc index 800e6ca8a..22cc085f9 100644 --- a/tests/unit/libutil/generator.cc +++ b/tests/unit/libutil/generator.cc @@ -85,6 +85,7 @@ TEST(Generator, nestsExceptions) co_yield 1; co_yield []() -> Generator<int> { co_yield 9; + // NOLINTNEXTLINE(hicpp-exception-baseclass) throw 1; co_yield 10; }(); @@ -101,6 +102,7 @@ TEST(Generator, exception) { auto g = []() -> Generator<int> { co_yield 1; + // NOLINTNEXTLINE(hicpp-exception-baseclass) throw 1; }(); @@ -110,6 +112,7 @@ TEST(Generator, exception) } { auto g = []() -> Generator<int> { + // NOLINTNEXTLINE(hicpp-exception-baseclass) throw 1; co_return; }(); @@ -173,11 +176,13 @@ struct ThrowTransform int operator()(bool) { + // NOLINTNEXTLINE(hicpp-exception-baseclass) throw 2; } Generator<int, void> operator()(Generator<int> && inner) { + // NOLINTNEXTLINE(hicpp-exception-baseclass) throw false; } }; diff --git a/tests/unit/libutil/tests.cc b/tests/unit/libutil/tests.cc index 9a44ad59b..29a5f7164 100644 --- a/tests/unit/libutil/tests.cc +++ b/tests/unit/libutil/tests.cc @@ -29,12 +29,12 @@ namespace nix { char cwd[PATH_MAX+1]; auto p = absPath(""); - ASSERT_EQ(p, getcwd((char*)&cwd, PATH_MAX)); + ASSERT_EQ(p, getcwd(cwd, PATH_MAX)); } TEST(absPath, usesOptionalBasePathWhenGiven) { char _cwd[PATH_MAX+1]; - char* cwd = getcwd((char*)&_cwd, PATH_MAX); + char* cwd = getcwd(_cwd, PATH_MAX); auto p = absPath("", cwd); @@ -43,7 +43,7 @@ namespace nix { TEST(absPath, isIdempotent) { char _cwd[PATH_MAX+1]; - char* cwd = getcwd((char*)&_cwd, PATH_MAX); + char* cwd = getcwd(_cwd, PATH_MAX); auto p1 = absPath(cwd); auto p2 = absPath(p1); |