@@ -123,7 +123,7 @@ static const size_t DEFAULT_BUF_CAP_BYTES = 8192;
123
123
class CalledProcessError : public std ::runtime_error
124
124
{
125
125
public:
126
- CalledProcessError (const std::string& error_msg):
126
+ explicit CalledProcessError (const std::string& error_msg):
127
127
std::runtime_error(error_msg)
128
128
{}
129
129
};
@@ -651,7 +651,7 @@ namespace util
651
651
* Default value is 0.
652
652
*/
653
653
struct bufsize {
654
- bufsize (int siz): bufsiz(siz) {}
654
+ explicit bufsize (int siz): bufsiz(siz) {}
655
655
int bufsiz = 0 ;
656
656
};
657
657
@@ -661,7 +661,7 @@ struct bufsize {
661
661
* Default value is false.
662
662
*/
663
663
struct defer_spawn {
664
- defer_spawn (bool d): defer(d) {}
664
+ explicit defer_spawn (bool d): defer(d) {}
665
665
bool defer = false ;
666
666
};
667
667
@@ -675,7 +675,7 @@ struct defer_spawn {
675
675
* Default value is false.
676
676
*/
677
677
struct close_fds {
678
- close_fds (bool c): close_all(c) {}
678
+ explicit close_fds (bool c): close_all(c) {}
679
679
bool close_all = false ;
680
680
};
681
681
@@ -686,12 +686,12 @@ struct close_fds {
686
686
* Default value is false.
687
687
*/
688
688
struct session_leader {
689
- session_leader (bool sl): leader_(sl) {}
689
+ explicit session_leader (bool sl): leader_(sl) {}
690
690
bool leader_ = false ;
691
691
};
692
692
693
693
struct shell {
694
- shell (bool s): shell_(s) {}
694
+ explicit shell (bool s): shell_(s) {}
695
695
bool shell_ = false ;
696
696
};
697
697
@@ -742,7 +742,7 @@ struct environment
742
742
{
743
743
environment (env_map_t && env):
744
744
env_ (std::move(env)) {}
745
- environment (const env_map_t & env):
745
+ explicit environment (const env_map_t & env):
746
746
env_(env) {}
747
747
env_map_t env_;
748
748
};
@@ -773,17 +773,17 @@ enum IOTYPE {
773
773
struct input
774
774
{
775
775
// For an already existing file descriptor.
776
- input (int fd): rd_ch_(fd) {}
776
+ explicit input (int fd): rd_ch_(fd) {}
777
777
778
778
// FILE pointer.
779
- input (FILE* fp):input(fileno(fp)) { assert (fp); }
779
+ explicit input (FILE* fp):input(fileno(fp)) { assert (fp); }
780
780
781
- input (const char * filename) {
781
+ explicit input (const char * filename) {
782
782
int fd = open (filename, O_RDONLY);
783
783
if (fd == -1 ) throw OSError (" File not found: " , errno);
784
784
rd_ch_ = fd;
785
785
}
786
- input (IOTYPE typ) {
786
+ explicit input (IOTYPE typ) {
787
787
assert (typ == PIPE && " STDOUT/STDERR not allowed" );
788
788
#ifndef __USING_WINDOWS__
789
789
std::tie (rd_ch_, wr_ch_) = util::pipe_cloexec ();
@@ -807,16 +807,16 @@ struct input
807
807
*/
808
808
struct output
809
809
{
810
- output (int fd): wr_ch_(fd) {}
810
+ explicit output (int fd): wr_ch_(fd) {}
811
811
812
- output (FILE* fp):output(fileno(fp)) { assert (fp); }
812
+ explicit output (FILE* fp):output(fileno(fp)) { assert (fp); }
813
813
814
- output (const char * filename) {
814
+ explicit output (const char * filename) {
815
815
int fd = open (filename, O_APPEND | O_CREAT | O_RDWR, 0640 );
816
816
if (fd == -1 ) throw OSError (" File not found: " , errno);
817
817
wr_ch_ = fd;
818
818
}
819
- output (IOTYPE typ) {
819
+ explicit output (IOTYPE typ) {
820
820
assert (typ == PIPE && " STDOUT/STDERR not allowed" );
821
821
#ifndef __USING_WINDOWS__
822
822
std::tie (rd_ch_, wr_ch_) = util::pipe_cloexec ();
@@ -838,16 +838,16 @@ struct output
838
838
*/
839
839
struct error
840
840
{
841
- error (int fd): wr_ch_(fd) {}
841
+ explicit error (int fd): wr_ch_(fd) {}
842
842
843
- error (FILE* fp):error(fileno(fp)) { assert (fp); }
843
+ explicit error (FILE* fp):error(fileno(fp)) { assert (fp); }
844
844
845
- error (const char * filename) {
845
+ explicit error (const char * filename) {
846
846
int fd = open (filename, O_APPEND | O_CREAT | O_RDWR, 0640 );
847
847
if (fd == -1 ) throw OSError (" File not found: " , errno);
848
848
wr_ch_ = fd;
849
849
}
850
- error (IOTYPE typ) {
850
+ explicit error (IOTYPE typ) {
851
851
assert ((typ == PIPE || typ == STDOUT) && " STDERR not aloowed" );
852
852
if (typ == PIPE) {
853
853
#ifndef __USING_WINDOWS__
@@ -879,7 +879,7 @@ class preexec_func
879
879
preexec_func () {}
880
880
881
881
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)))
883
883
{}
884
884
885
885
void operator ()() {
@@ -920,7 +920,7 @@ class Buffer
920
920
{
921
921
public:
922
922
Buffer () {}
923
- Buffer (size_t cap) { buf.resize (cap); }
923
+ explicit Buffer (size_t cap) { buf.resize (cap); }
924
924
void add_cap (size_t cap) { buf.resize (cap); }
925
925
std::string string () const { return std::string (buf.begin (), buf.end ()); }
926
926
0 commit comments