Skip to content

Commit 77aaff6

Browse files
author
Elazar Leibovich
committed
clang-tidy: explicit one argument constructors
1 parent 6b8ca46 commit 77aaff6

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

subprocess.hpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static const size_t DEFAULT_BUF_CAP_BYTES = 8192;
123123
class CalledProcessError: public std::runtime_error
124124
{
125125
public:
126-
CalledProcessError(const std::string& error_msg):
126+
explicit CalledProcessError(const std::string& error_msg):
127127
std::runtime_error(error_msg)
128128
{}
129129
};
@@ -651,7 +651,7 @@ namespace util
651651
* Default value is 0.
652652
*/
653653
struct bufsize {
654-
bufsize(int siz): bufsiz(siz) {}
654+
explicit bufsize(int siz): bufsiz(siz) {}
655655
int bufsiz = 0;
656656
};
657657

@@ -661,7 +661,7 @@ struct bufsize {
661661
* Default value is false.
662662
*/
663663
struct defer_spawn {
664-
defer_spawn(bool d): defer(d) {}
664+
explicit defer_spawn(bool d): defer(d) {}
665665
bool defer = false;
666666
};
667667

@@ -675,7 +675,7 @@ struct defer_spawn {
675675
* Default value is false.
676676
*/
677677
struct close_fds {
678-
close_fds(bool c): close_all(c) {}
678+
explicit close_fds(bool c): close_all(c) {}
679679
bool close_all = false;
680680
};
681681

@@ -686,12 +686,12 @@ struct close_fds {
686686
* Default value is false.
687687
*/
688688
struct session_leader {
689-
session_leader(bool sl): leader_(sl) {}
689+
explicit session_leader(bool sl): leader_(sl) {}
690690
bool leader_ = false;
691691
};
692692

693693
struct shell {
694-
shell(bool s): shell_(s) {}
694+
explicit shell(bool s): shell_(s) {}
695695
bool shell_ = false;
696696
};
697697

@@ -742,7 +742,7 @@ struct environment
742742
{
743743
environment(env_map_t&& env):
744744
env_(std::move(env)) {}
745-
environment(const env_map_t& env):
745+
explicit environment(const env_map_t& env):
746746
env_(env) {}
747747
env_map_t env_;
748748
};
@@ -773,17 +773,17 @@ enum IOTYPE {
773773
struct input
774774
{
775775
// For an already existing file descriptor.
776-
input(int fd): rd_ch_(fd) {}
776+
explicit input(int fd): rd_ch_(fd) {}
777777

778778
// FILE pointer.
779-
input (FILE* fp):input(fileno(fp)) { assert(fp); }
779+
explicit input (FILE* fp):input(fileno(fp)) { assert(fp); }
780780

781-
input(const char* filename) {
781+
explicit input(const char* filename) {
782782
int fd = open(filename, O_RDONLY);
783783
if (fd == -1) throw OSError("File not found: ", errno);
784784
rd_ch_ = fd;
785785
}
786-
input(IOTYPE typ) {
786+
explicit input(IOTYPE typ) {
787787
assert (typ == PIPE && "STDOUT/STDERR not allowed");
788788
#ifndef __USING_WINDOWS__
789789
std::tie(rd_ch_, wr_ch_) = util::pipe_cloexec();
@@ -807,16 +807,16 @@ struct input
807807
*/
808808
struct output
809809
{
810-
output(int fd): wr_ch_(fd) {}
810+
explicit output(int fd): wr_ch_(fd) {}
811811

812-
output (FILE* fp):output(fileno(fp)) { assert(fp); }
812+
explicit output (FILE* fp):output(fileno(fp)) { assert(fp); }
813813

814-
output(const char* filename) {
814+
explicit output(const char* filename) {
815815
int fd = open(filename, O_APPEND | O_CREAT | O_RDWR, 0640);
816816
if (fd == -1) throw OSError("File not found: ", errno);
817817
wr_ch_ = fd;
818818
}
819-
output(IOTYPE typ) {
819+
explicit output(IOTYPE typ) {
820820
assert (typ == PIPE && "STDOUT/STDERR not allowed");
821821
#ifndef __USING_WINDOWS__
822822
std::tie(rd_ch_, wr_ch_) = util::pipe_cloexec();
@@ -838,16 +838,16 @@ struct output
838838
*/
839839
struct error
840840
{
841-
error(int fd): wr_ch_(fd) {}
841+
explicit error(int fd): wr_ch_(fd) {}
842842

843-
error(FILE* fp):error(fileno(fp)) { assert(fp); }
843+
explicit error(FILE* fp):error(fileno(fp)) { assert(fp); }
844844

845-
error(const char* filename) {
845+
explicit error(const char* filename) {
846846
int fd = open(filename, O_APPEND | O_CREAT | O_RDWR, 0640);
847847
if (fd == -1) throw OSError("File not found: ", errno);
848848
wr_ch_ = fd;
849849
}
850-
error(IOTYPE typ) {
850+
explicit error(IOTYPE typ) {
851851
assert ((typ == PIPE || typ == STDOUT) && "STDERR not aloowed");
852852
if (typ == PIPE) {
853853
#ifndef __USING_WINDOWS__
@@ -879,7 +879,7 @@ class preexec_func
879879
preexec_func() {}
880880

881881
template <typename Func>
882-
preexec_func(Func f): holder_(new FuncHolder<Func>(std::move(f)))
882+
explicit preexec_func(Func f): holder_(new FuncHolder<Func>(std::move(f)))
883883
{}
884884

885885
void operator()() {
@@ -920,7 +920,7 @@ class Buffer
920920
{
921921
public:
922922
Buffer() {}
923-
Buffer(size_t cap) { buf.resize(cap); }
923+
explicit Buffer(size_t cap) { buf.resize(cap); }
924924
void add_cap(size_t cap) { buf.resize(cap); }
925925
std::string string() const { return std::string(buf.begin(), buf.end()); }
926926

0 commit comments

Comments
 (0)