refactor(tvix/libutil): Mark single-argument constructors explicit
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>
This commit is contained in:
		
							parent
							
								
									1443298657
								
							
						
					
					
						commit
						1cf11317ca
					
				
					 34 changed files with 309 additions and 272 deletions
				
			
		
							
								
								
									
										26
									
								
								third_party/nix/src/libutil/util.hh
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										26
									
								
								third_party/nix/src/libutil/util.hh
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -167,11 +167,11 @@ class AutoDelete {
 | 
			
		|||
 | 
			
		||||
 public:
 | 
			
		||||
  AutoDelete();
 | 
			
		||||
  AutoDelete(Path p, bool recursive = true);
 | 
			
		||||
  explicit AutoDelete(Path p, bool recursive = true);
 | 
			
		||||
  ~AutoDelete();
 | 
			
		||||
  void cancel();
 | 
			
		||||
  void reset(const Path& p, bool recursive = true);
 | 
			
		||||
  operator Path() const { return path; }
 | 
			
		||||
  explicit operator Path() const { return path; }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class AutoCloseFD {
 | 
			
		||||
| 
						 | 
				
			
			@ -180,7 +180,7 @@ class AutoCloseFD {
 | 
			
		|||
 | 
			
		||||
 public:
 | 
			
		||||
  AutoCloseFD();
 | 
			
		||||
  AutoCloseFD(int fd);
 | 
			
		||||
  explicit AutoCloseFD(int fd);
 | 
			
		||||
  AutoCloseFD(const AutoCloseFD& fd) = delete;
 | 
			
		||||
  AutoCloseFD(AutoCloseFD&& that);
 | 
			
		||||
  ~AutoCloseFD();
 | 
			
		||||
| 
						 | 
				
			
			@ -210,16 +210,24 @@ class Pid {
 | 
			
		|||
 | 
			
		||||
 public:
 | 
			
		||||
  Pid();
 | 
			
		||||
  Pid(pid_t pid);
 | 
			
		||||
  explicit Pid(pid_t pid);
 | 
			
		||||
  ~Pid();
 | 
			
		||||
  void operator=(pid_t pid);
 | 
			
		||||
  operator pid_t();
 | 
			
		||||
  explicit operator pid_t();
 | 
			
		||||
  int kill();
 | 
			
		||||
  int wait();
 | 
			
		||||
 | 
			
		||||
  void setSeparatePG(bool separatePG);
 | 
			
		||||
  void setKillSignal(int signal);
 | 
			
		||||
  pid_t release();
 | 
			
		||||
 | 
			
		||||
  friend bool operator==(const Pid& lhs, const Pid& rhs) {
 | 
			
		||||
    return lhs.pid == rhs.pid;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  friend bool operator!=(const Pid& lhs, const Pid& rhs) {
 | 
			
		||||
    return !(lhs == rhs);
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* Kill all processes running under the specified uid by sending them
 | 
			
		||||
| 
						 | 
				
			
			@ -275,7 +283,8 @@ class ExecError : public Error {
 | 
			
		|||
  int status;
 | 
			
		||||
 | 
			
		||||
  template <typename... Args>
 | 
			
		||||
  ExecError(int status, Args... args) : Error(args...), status(status) {}
 | 
			
		||||
  explicit ExecError(int status, Args... args)
 | 
			
		||||
      : Error(args...), status(status) {}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* Convert a list of strings to a null-terminated vector of char
 | 
			
		||||
| 
						 | 
				
			
			@ -378,7 +387,7 @@ class Callback {
 | 
			
		|||
  std::atomic_flag done = ATOMIC_FLAG_INIT;
 | 
			
		||||
 | 
			
		||||
 public:
 | 
			
		||||
  Callback(std::function<void(std::future<T>)> fun) : fun(fun) {}
 | 
			
		||||
  explicit Callback(std::function<void(std::future<T>)> fun) : fun(fun) {}
 | 
			
		||||
 | 
			
		||||
  Callback(Callback&& callback) : fun(std::move(callback.fun)) {
 | 
			
		||||
    auto prev = callback.done.test_and_set();
 | 
			
		||||
| 
						 | 
				
			
			@ -449,7 +458,8 @@ template <typename T>
 | 
			
		|||
struct MaintainCount {
 | 
			
		||||
  T& counter;
 | 
			
		||||
  long delta;
 | 
			
		||||
  MaintainCount(T& counter, long delta = 1) : counter(counter), delta(delta) {
 | 
			
		||||
  explicit MaintainCount(T& counter, long delta = 1)
 | 
			
		||||
      : counter(counter), delta(delta) {
 | 
			
		||||
    counter += delta;
 | 
			
		||||
  }
 | 
			
		||||
  ~MaintainCount() { counter -= delta; }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue