From bd8db33d0073e4c227a69b9f1259db519ff181c2 Mon Sep 17 00:00:00 2001 From: Alan Griffiths Date: Fri, 15 Mar 2024 12:00:29 +0000 Subject: [PATCH] Some dead files spotted while discussing #3283 --- src/common/events/pointer_event.cpp | 1 - src/common/events/window_event.cpp | 1 - src/common/input/input_event.cpp | 1 - .../common/mir/fd_socket_transmission.h | 45 -------- src/include/common/mir/require.h | 30 ----- .../common/mir/variable_length_array.h | 62 ----------- src/include/common/mir_blob.h | 30 ----- tests/unit-tests/CMakeLists.txt | 1 - .../unit-tests/test_variable_length_array.cpp | 105 ------------------ 9 files changed, 276 deletions(-) delete mode 100644 src/include/common/mir/fd_socket_transmission.h delete mode 100644 src/include/common/mir/require.h delete mode 100644 src/include/common/mir/variable_length_array.h delete mode 100644 src/include/common/mir_blob.h delete mode 100644 tests/unit-tests/test_variable_length_array.cpp diff --git a/src/common/events/pointer_event.cpp b/src/common/events/pointer_event.cpp index adab66f3aeb..9c99af733da 100644 --- a/src/common/events/pointer_event.cpp +++ b/src/common/events/pointer_event.cpp @@ -15,7 +15,6 @@ */ #include "mir/events/pointer_event.h" -#include "mir_blob.h" #include diff --git a/src/common/events/window_event.cpp b/src/common/events/window_event.cpp index e7ac4f9afd3..b12bfe2c638 100644 --- a/src/common/events/window_event.cpp +++ b/src/common/events/window_event.cpp @@ -15,7 +15,6 @@ */ #include "mir/events/window_event.h" -#include "mir_blob.h" MirWindowEvent::MirWindowEvent() : MirEvent{mir_event_type_window} { diff --git a/src/common/input/input_event.cpp b/src/common/input/input_event.cpp index 43ae2a88e20..7edfae2a620 100644 --- a/src/common/input/input_event.cpp +++ b/src/common/input/input_event.cpp @@ -20,7 +20,6 @@ #include "mir/events/event_type_to_string.h" #include "mir/events/event_private.h" #include "mir/log.h" -#include "mir/require.h" #include "../handle_event_exception.h" diff --git a/src/include/common/mir/fd_socket_transmission.h b/src/include/common/mir/fd_socket_transmission.h deleted file mode 100644 index cb531f8231d..00000000000 --- a/src/include/common/mir/fd_socket_transmission.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright © Canonical Ltd. - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License version 2 or 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -#ifndef MIR_FD_SOCKET_TRANSMISSION_H_ -#define MIR_FD_SOCKET_TRANSMISSION_H_ -#include "mir/fd.h" -#include -#include -#include - -namespace mir -{ -struct socket_error : std::system_error -{ - socket_error(std::string const& message); -}; - -struct socket_disconnected_error : std::system_error -{ - socket_disconnected_error(std::string const& message); -}; - -struct fd_reception_error : std::runtime_error -{ - fd_reception_error(std::string const& message); -}; - -bool socket_error_is_transient(int error_code); -void send_fds(mir::Fd const& socket, std::vector const& fd); -void receive_data(mir::Fd const& socket, void* buffer, size_t bytes_requested, std::vector& fds); -} -#endif /* MIR_FD_SOCKET_TRANSMISSION_H_ */ diff --git a/src/include/common/mir/require.h b/src/include/common/mir/require.h deleted file mode 100644 index 16d6c6b0ea7..00000000000 --- a/src/include/common/mir/require.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright © Canonical Ltd. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 2 or 3 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -#ifndef MIR_REQUIRE_H_ -#define MIR_REQUIRE_H_ - -#include - -namespace mir -{ -inline void require(bool const expr) -{ - if (!expr) std::abort(); -} -} - -#endif /* MIR_REQUIRE_H_ */ diff --git a/src/include/common/mir/variable_length_array.h b/src/include/common/mir/variable_length_array.h deleted file mode 100644 index ad4caef175c..00000000000 --- a/src/include/common/mir/variable_length_array.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright © Canonical Ltd. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 2 or 3 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -#ifndef MIR_VARIABLE_LENGTH_ARRAY_H_ -#define MIR_VARIABLE_LENGTH_ARRAY_H_ - -#include -#include - -namespace mir -{ - -template -class VariableLengthArray -{ -public: - explicit VariableLengthArray(size_t size) : size_{size} - { - /* Don't call resize if the initial values of member variables are valid */ - if (size > BuiltInBufferSize) resize(size); - } - - void resize(size_t size) - { - if (size > BuiltInBufferSize) - effective_buffer = BufferUPtr{new unsigned char[size], heap_deleter}; - else - effective_buffer = BufferUPtr{builtin_buffer, null_deleter}; - - size_ = size; - } - - unsigned char* data() const { return effective_buffer.get(); } - size_t size() const { return size_; } - -private: - typedef std::unique_ptr BufferUPtr; - - static void null_deleter(unsigned char*) {} - static void heap_deleter(unsigned char* b) { delete[] b; } - - unsigned char builtin_buffer[BuiltInBufferSize]; - BufferUPtr effective_buffer{builtin_buffer, null_deleter}; - size_t size_; -}; - -} - -#endif /* MIR_VARIABLE_LENGTH_ARRAY_H_ */ diff --git a/src/include/common/mir_blob.h b/src/include/common/mir_blob.h deleted file mode 100644 index 629c3a9fbff..00000000000 --- a/src/include/common/mir_blob.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright © Canonical Ltd. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 2 or 3 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -#ifndef MIR_MIR_BLOB_H_H -#define MIR_MIR_BLOB_H_H - -#include - -struct MirBlob -{ - virtual size_t size() const = 0; - virtual void const* data() const = 0; - - virtual ~MirBlob() = default; -}; - -#endif //MIR_MIR_BLOB_H_H diff --git a/tests/unit-tests/CMakeLists.txt b/tests/unit-tests/CMakeLists.txt index 6ba368f5d8d..d62046b0501 100644 --- a/tests/unit-tests/CMakeLists.txt +++ b/tests/unit-tests/CMakeLists.txt @@ -51,7 +51,6 @@ set( test_glib_main_loop.cpp shared_library_test.cpp test_raii.cpp - test_variable_length_array.cpp test_default_emergency_cleanup.cpp test_thread_safe_list.cpp test_fatal.cpp diff --git a/tests/unit-tests/test_variable_length_array.cpp b/tests/unit-tests/test_variable_length_array.cpp deleted file mode 100644 index 2025391d194..00000000000 --- a/tests/unit-tests/test_variable_length_array.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright © Canonical Ltd. - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 or 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include "mir/variable_length_array.h" - -#include -#include - -TEST(VariableLengthArray, has_correct_size_if_using_builtin) -{ - using namespace testing; - - size_t const builtin_size{100}; - size_t const vla_size_builtin{builtin_size - 1}; - mir::VariableLengthArray vla{vla_size_builtin}; - - EXPECT_THAT(vla.size(), Eq(vla_size_builtin)); - memset(vla.data(), 0x55, vla.size()); -} - -TEST(VariableLengthArray, has_correct_size_if_using_heap) -{ - using namespace testing; - - size_t const builtin_size{100}; - size_t const vla_size_heap{builtin_size + 1}; - mir::VariableLengthArray vla{vla_size_heap}; - - EXPECT_THAT(vla.size(), Eq(vla_size_heap)); - memset(vla.data(), 0x55, vla.size()); -} - -TEST(VariableLengthArray, resizes_from_builtin_to_heap) -{ - using namespace testing; - - size_t const builtin_size{100}; - size_t const vla_size_builtin{builtin_size - 1}; - size_t const vla_size_heap{builtin_size + 1}; - mir::VariableLengthArray vla{vla_size_builtin}; - - vla.resize(vla_size_heap); - - EXPECT_THAT(vla.size(), Eq(vla_size_heap)); - memset(vla.data(), 0x55, vla.size()); -} - -TEST(VariableLengthArray, resizes_from_builtin_to_builtin) -{ - using namespace testing; - - size_t const builtin_size{100}; - size_t const vla_size_builtin1{builtin_size - 1}; - size_t const vla_size_builtin2{builtin_size}; - mir::VariableLengthArray vla{vla_size_builtin1}; - - vla.resize(vla_size_builtin2); - - EXPECT_THAT(vla.size(), Eq(vla_size_builtin2)); - memset(vla.data(), 0x55, vla.size()); -} - -TEST(VariableLengthArray, resizes_from_heap_to_builtin) -{ - using namespace testing; - - size_t const builtin_size{100}; - size_t const vla_size_builtin{builtin_size - 1}; - size_t const vla_size_heap{builtin_size + 1}; - mir::VariableLengthArray vla{vla_size_heap}; - - vla.resize(vla_size_builtin); - - EXPECT_THAT(vla.size(), Eq(vla_size_builtin)); - memset(vla.data(), 0x55, vla.size()); -} - -TEST(VariableLengthArray, resizes_from_heap_to_heap) -{ - using namespace testing; - - size_t const builtin_size{100}; - size_t const vla_size_heap1{builtin_size + 1}; - size_t const vla_size_heap2{builtin_size + 2}; - mir::VariableLengthArray vla{vla_size_heap1}; - - vla.resize(vla_size_heap2); - - EXPECT_THAT(vla.size(), Eq(vla_size_heap2)); - memset(vla.data(), 0x55, vla.size()); -}