diff options
author | Vincent Ambo <mail@tazj.in> | 2020-08-21T03·00+0100 |
---|---|---|
committer | tazjin <mail@tazj.in> | 2020-08-23T11·58+0000 |
commit | 1cf11317cac2c11d20b2324d4283814f1351c1a3 (patch) | |
tree | 5a77610f94b0b8fd60bf64c1ca765b05ab8a6fd6 /third_party/nix/src/libutil/serialise.hh | |
parent | 1443298657156107704b5d9fcfa7356ee8fa8789 (diff) |
refactor(tvix/libutil): Mark single-argument constructors explicit r/1704
This is the clang-tidy lint 'google-explicit-constructor'. There's a whole bunch of breakage that was introduced by this, and we had to opt out a few types of this (esp. the string formatting crap). In some cases minor other changes have been done to keep the code working, instead of converting between types (e.g. an explicit comparison operator implementation for nix::Pid). Change-Id: I12e1ca51a6bc2c882dba81a2526b9729d26988e7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1832 Tested-by: BuildkiteCI Reviewed-by: kanepyork <rikingcoding@gmail.com> Reviewed-by: glittershark <grfn@gws.fyi>
Diffstat (limited to 'third_party/nix/src/libutil/serialise.hh')
-rw-r--r-- | third_party/nix/src/libutil/serialise.hh | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/third_party/nix/src/libutil/serialise.hh b/third_party/nix/src/libutil/serialise.hh index bbfbe16a016c..c6d1d814dbdd 100644 --- a/third_party/nix/src/libutil/serialise.hh +++ b/third_party/nix/src/libutil/serialise.hh @@ -23,7 +23,7 @@ struct BufferedSink : Sink { size_t bufSize, bufPos; std::unique_ptr<unsigned char[]> buffer; - BufferedSink(size_t bufSize = 32 * 1024) + explicit BufferedSink(size_t bufSize = 32 * 1024) : bufSize(bufSize), bufPos(0), buffer(nullptr) {} void operator()(const unsigned char* data, size_t len) override; @@ -59,7 +59,7 @@ struct BufferedSource : Source { size_t bufSize, bufPosIn, bufPosOut; std::unique_ptr<unsigned char[]> buffer; - BufferedSource(size_t bufSize = 32 * 1024) + explicit BufferedSource(size_t bufSize = 32 * 1024) : bufSize(bufSize), bufPosIn(0), bufPosOut(0), buffer(nullptr) {} size_t read(unsigned char* data, size_t len) override; @@ -78,7 +78,7 @@ struct FdSink : BufferedSink { size_t written = 0; FdSink() : fd(-1) {} - FdSink(int fd) : fd(fd) {} + explicit FdSink(int fd) : fd(fd) {} FdSink(FdSink&&) = default; FdSink& operator=(FdSink&& s) { @@ -106,7 +106,7 @@ struct FdSource : BufferedSource { size_t read = 0; FdSource() : fd(-1) {} - FdSource(int fd) : fd(fd) {} + explicit FdSource(int fd) : fd(fd) {} FdSource(FdSource&&) = default; FdSource& operator=(FdSource&& s) { @@ -129,7 +129,7 @@ struct FdSource : BufferedSource { struct StringSink : Sink { ref<std::string> s; StringSink() : s(make_ref<std::string>()){}; - StringSink(ref<std::string> s) : s(s){}; + explicit StringSink(ref<std::string> s) : s(s){}; void operator()(const unsigned char* data, size_t len) override; }; @@ -137,7 +137,7 @@ struct StringSink : Sink { struct StringSource : Source { const std::string& s; size_t pos; - StringSource(const std::string& _s) : s(_s), pos(0) {} + explicit StringSource(const std::string& _s) : s(_s), pos(0) {} size_t read(unsigned char* data, size_t len) override; }; @@ -145,7 +145,8 @@ struct StringSource : Source { struct TeeSource : Source { Source& orig; ref<std::string> data; - TeeSource(Source& orig) : orig(orig), data(make_ref<std::string>()) {} + explicit TeeSource(Source& orig) + : orig(orig), data(make_ref<std::string>()) {} size_t read(unsigned char* data, size_t len) { size_t n = orig.read(data, len); this->data->append((const char*)data, n); @@ -186,7 +187,7 @@ struct LambdaSink : Sink { lambda_t lambda; - LambdaSink(const lambda_t& lambda) : lambda(lambda) {} + explicit LambdaSink(const lambda_t& lambda) : lambda(lambda) {} virtual void operator()(const unsigned char* data, size_t len) { lambda(data, len); @@ -199,7 +200,7 @@ struct LambdaSource : Source { lambda_t lambda; - LambdaSource(const lambda_t& lambda) : lambda(lambda) {} + explicit LambdaSource(const lambda_t& lambda) : lambda(lambda) {} size_t read(unsigned char* data, size_t len) override { return lambda(data, len); |