From 5f5d43ff51936080b036c130bc0f2a81d4f20d4f Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Mon, 18 Oct 2021 18:46:57 +0000 Subject: [PATCH] Disallow copy and assign for DataBuilder & RandomGenerator BUG=tint:1247 Change-Id: I48f7b1e1679bcba43e4c284b2f97a02210feabb3 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/66740 Auto-Submit: Ryan Harrison Reviewed-by: Ben Clayton Commit-Queue: Ryan Harrison Kokoro: Kokoro --- fuzzers/data_builder.h | 7 ++++++- fuzzers/random_generator.h | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/fuzzers/data_builder.h b/fuzzers/data_builder.h index b6ec22fd45..5abb98c4fd 100644 --- a/fuzzers/data_builder.h +++ b/fuzzers/data_builder.h @@ -34,7 +34,8 @@ class DataBuilder { explicit DataBuilder(const uint8_t* data, size_t size) : generator_(data, size) {} - ~DataBuilder() {} + ~DataBuilder() = default; + DataBuilder(DataBuilder&&) = default; /// Generate pseudo-random data of a specific type /// @tparam T - type of data to produce @@ -85,6 +86,10 @@ class DataBuilder { private: RandomGenerator generator_; + // Disallow copy & assign + DataBuilder(const DataBuilder&) = delete; + DataBuilder& operator=(const DataBuilder&) = delete; + /// Get N bytes of pseudo-random data /// @param out - pointer to location to save data /// @param n - number of bytes to get diff --git a/fuzzers/random_generator.h b/fuzzers/random_generator.h index c7b7afce74..5a61baed4f 100644 --- a/fuzzers/random_generator.h +++ b/fuzzers/random_generator.h @@ -33,6 +33,9 @@ class RandomGenerator { /// @param size - size of data buffer explicit RandomGenerator(const uint8_t* data, size_t size); + ~RandomGenerator() = default; + RandomGenerator(RandomGenerator&&) = default; + /// Get uint32_t value from uniform distribution. /// @param lower - lower bound of integer generated /// @param upper - upper bound of integer generated @@ -98,6 +101,10 @@ class RandomGenerator { private: std::mt19937_64 engine_; + // Disallow copy & assign + RandomGenerator(const RandomGenerator&) = delete; + RandomGenerator& operator=(const RandomGenerator&) = delete; + }; // class RandomGenerator } // namespace fuzzers