diff --git a/src/autoload.h b/src/autoload.h index c364a4c39..f0ad9d030 100644 --- a/src/autoload.h +++ b/src/autoload.h @@ -27,7 +27,7 @@ file_access_attempt_t access_file(const wcstring &path, int mode); struct autoload_function_t : public lru_node_t { - autoload_function_t(const wcstring &key) : lru_node_t(key), access(), is_loaded(false), is_placeholder(false), is_internalized(false) { } + explicit autoload_function_t(const wcstring &key) : lru_node_t(key), access(), is_loaded(false), is_placeholder(false), is_internalized(false) { } file_access_attempt_t access; /** The last access attempt */ bool is_loaded; /** Whether we have actually loaded this function */ bool is_placeholder; /** Whether we are a placeholder that stands in for "no such function". If this is true, then is_loaded must be false. */ diff --git a/src/builtin.cpp b/src/builtin.cpp index a4363e4b2..b83bb82a6 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -2805,7 +2805,7 @@ static int builtin_read(parser_t &parser, io_streams_t &streams, wchar_t **argv) wcstring tokens; tokens.reserve(buff.size()); bool empty = true; - + for (wcstring_range loc = wcstring_tok(buff, ifs); loc.first != wcstring::npos; loc = wcstring_tok(buff, ifs, loc)) { if (!empty) tokens.push_back(ARRAY_SEP); @@ -2820,7 +2820,7 @@ static int builtin_read(parser_t &parser, io_streams_t &streams, wchar_t **argv) while (isecond.val; + result = env_var_t(where->second.val); } return result; } @@ -1454,7 +1454,7 @@ class universal_notifier_named_pipe_t : public universal_notifier_t } public: - universal_notifier_named_pipe_t(const wchar_t *test_path) : pipe_fd(-1), readback_time_usec(0), readback_amount(0), polling_due_to_readable_fd(false), drain_if_still_readable_time_usec(0) + explicit universal_notifier_named_pipe_t(const wchar_t *test_path) : pipe_fd(-1), readback_time_usec(0), readback_amount(0), polling_due_to_readable_fd(false), drain_if_still_readable_time_usec(0) { make_pipe(test_path); } diff --git a/src/env_universal_common.h b/src/env_universal_common.h index 3428c6937..60cf00278 100644 --- a/src/env_universal_common.h +++ b/src/env_universal_common.h @@ -75,7 +75,7 @@ class env_universal_t static var_table_t read_message_internal(int fd); public: - env_universal_t(const wcstring &path); + explicit env_universal_t(const wcstring &path); ~env_universal_t(); /* Get the value of the variable with the specified name */ diff --git a/src/event.h b/src/event.h index 80737596d..bf068c5d3 100644 --- a/src/event.h +++ b/src/event.h @@ -87,7 +87,7 @@ struct event_t */ wcstring_list_t arguments; - event_t(int t); + explicit event_t(int t); ~event_t(); static event_t signal_event(int sig); diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index adbc13a53..efc134d73 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -1318,7 +1318,7 @@ static void test_escape_sequences(void) class lru_node_test_t : public lru_node_t { public: - lru_node_test_t(const wcstring &tmp) : lru_node_t(tmp) { } + explicit lru_node_test_t(const wcstring &tmp) : lru_node_t(tmp) { } }; class test_lru_t : public lru_cache_t diff --git a/src/history.cpp b/src/history.cpp index 112af1eaf..28be7bc55 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -129,7 +129,7 @@ class time_profiler_t double start; public: - time_profiler_t(const char *w) + explicit time_profiler_t(const char *w) { if (LOG_TIMES) { @@ -165,7 +165,7 @@ class history_lru_node_t : public lru_node_t public: time_t timestamp; path_list_t required_paths; - history_lru_node_t(const history_item_t &item) : + explicit history_lru_node_t(const history_item_t &item) : lru_node_t(item.str()), timestamp(item.timestamp()), required_paths(item.required_paths) @@ -183,7 +183,7 @@ protected: } public: - history_lru_cache_t(size_t max) : lru_cache_t(max) { } + explicit history_lru_cache_t(size_t max) : lru_cache_t(max) { } /* Function to add a history item */ void add_item(const history_item_t &item) diff --git a/src/history.h b/src/history.h index 63372ba02..f99950aa0 100644 --- a/src/history.h +++ b/src/history.h @@ -116,7 +116,7 @@ class history_t history_t &operator=(const history_t&); /** Private creator */ - history_t(const wcstring &pname); + explicit history_t(const wcstring &pname); /** Privately add an item. If pending, the item will not be returned by history searches until a call to resolve_pending. */ void add(const history_item_t &item, bool pending = false); @@ -348,7 +348,7 @@ void history_sanity_check(); struct file_detection_context_t { /* Constructor */ - file_detection_context_t(history_t *hist, history_identifier_t ident = 0); + explicit file_detection_context_t(history_t *hist, history_identifier_t ident = 0); /* Determine which of potential_paths are valid, and put them in valid_paths */ int perform_file_detection(); diff --git a/src/io.h b/src/io.h index bb4c0621d..adc59be17 100644 --- a/src/io.h +++ b/src/io.h @@ -56,7 +56,7 @@ class io_data_t class io_close_t : public io_data_t { public: - io_close_t(int f) : + explicit io_close_t(int f) : io_data_t(IO_CLOSE, f) { } @@ -137,7 +137,7 @@ class io_buffer_t : public io_pipe_t /** buffer to save output in */ std::vector out_buffer; - io_buffer_t(int f): + explicit io_buffer_t(int f): io_pipe_t(IO_BUFFER, f, false /* not input */), out_buffer() { @@ -195,7 +195,7 @@ class io_chain_t : public std::vector > { public: io_chain_t(); - io_chain_t(const shared_ptr &); + explicit io_chain_t(const shared_ptr &); void remove(const shared_ptr &element); void push_back(const shared_ptr &element); diff --git a/src/lru.h b/src/lru.h index 779c2edcf..a70b165d6 100644 --- a/src/lru.h +++ b/src/lru.h @@ -35,7 +35,7 @@ class lru_node_t const wcstring key; /** Constructor */ - lru_node_t(const wcstring &pkey) : prev(NULL), next(NULL), key(pkey) { } + explicit lru_node_t(const wcstring &pkey) : prev(NULL), next(NULL), key(pkey) { } /** Virtual destructor that does nothing for classes that inherit lru_node_t */ virtual ~lru_node_t() {} @@ -117,7 +117,7 @@ class lru_cache_t public: /** Constructor */ - lru_cache_t(size_t max_size = 1024) : max_node_count(max_size), node_count(0), mouth(wcstring()) + explicit lru_cache_t(size_t max_size = 1024) : max_node_count(max_size), node_count(0), mouth(wcstring()) { /* Hook up the mouth to itself: a one node circularly linked list! */ mouth.prev = mouth.next = &mouth; @@ -220,7 +220,7 @@ class lru_cache_t { lru_node_t *node; public: - iterator(lru_node_t *val) : node(val) { } + explicit iterator(lru_node_t *val) : node(val) { } void operator++() { node = lru_cache_t::get_previous(node); diff --git a/src/parse_tree.cpp b/src/parse_tree.cpp index ead78a6e5..5939e270d 100644 --- a/src/parse_tree.cpp +++ b/src/parse_tree.cpp @@ -628,7 +628,7 @@ class parse_ll_t public: /* Constructor */ - parse_ll_t(enum parse_token_type_t goal) : fatal_errored(false), should_generate_error_messages(true) + explicit parse_ll_t(enum parse_token_type_t goal) : fatal_errored(false), should_generate_error_messages(true) { this->symbol_stack.reserve(16); this->nodes.reserve(64); diff --git a/src/parser.h b/src/parser.h index 1b2bad1b5..db35471be 100644 --- a/src/parser.h +++ b/src/parser.h @@ -85,7 +85,7 @@ struct block_t { protected: /** Protected constructor. Use one of the subclasses below. */ - block_t(block_type_t t); + explicit block_t(block_type_t t); private: const block_type_t block_type; /**< Type of block. */ @@ -134,7 +134,7 @@ struct if_block_t : public block_t struct event_block_t : public block_t { event_t const event; - event_block_t(const event_t &evt); + explicit event_block_t(const event_t &evt); }; struct function_block_t : public block_t @@ -147,7 +147,7 @@ struct function_block_t : public block_t struct source_block_t : public block_t { const wchar_t * const source_file; - source_block_t(const wchar_t *src); + explicit source_block_t(const wchar_t *src); }; struct for_block_t : public block_t @@ -172,7 +172,7 @@ struct fake_block_t : public block_t struct scope_block_t : public block_t { - scope_block_t(block_type_t type); //must be BEGIN, TOP or SUBST + explicit scope_block_t(block_type_t type); //must be BEGIN, TOP or SUBST }; struct breakpoint_block_t : public block_t diff --git a/src/proc.cpp b/src/proc.cpp index 0a0da0a8b..e16688f02 100644 --- a/src/proc.cpp +++ b/src/proc.cpp @@ -354,8 +354,6 @@ int job_signal(job_t *j, int signal) /** Store the status of the process pid that was returned by waitpid. - Return 0 if all went well, nonzero otherwise. - This is called from a signal handler. */ static void mark_process_status(const job_t *j, process_t *p, int status) { @@ -374,18 +372,7 @@ static void mark_process_status(const job_t *j, process_t *p, int status) { /* This should never be reached */ p->completed = 1; - - char mess[MESS_SIZE]; - snprintf(mess, - MESS_SIZE, - "Process %ld exited abnormally\n", - (long) p->pid); - /* - If write fails, do nothing. We're in a signal handlers error - handler. If things aren't working properly, it's safer to - give up. - */ - write_ignore(2, mess, strlen(mess)); + fprintf(stderr, "Process %ld exited abnormally\n", (long)p->pid); } } @@ -399,10 +386,8 @@ void job_mark_process_as_failed(const job_t *job, process_t *p) } /** - Handle status update for child \c pid. This function is called by - the signal handler, so it mustn't use malloc or any such hitech - nonsense. - + Handle status update for child \c pid. + \param pid the pid of the process whose status changes \param status the status as returned by wait */ @@ -411,14 +396,6 @@ static void handle_child_status(pid_t pid, int status) bool found_proc = false; const job_t *j = NULL; process_t *p = NULL; -// char mess[MESS_SIZE]; - /* - snprintf( mess, - MESS_SIZE, - "Process %d\n", - (int) pid ); - write( 2, mess, strlen(mess )); - */ job_iterator_t jobs; while (! found_proc && (j = jobs.next())) diff --git a/src/proc.h b/src/proc.h index 8dd66c7ce..68ec54543 100644 --- a/src/proc.h +++ b/src/proc.h @@ -422,7 +422,7 @@ class job_iterator_t return job; } - job_iterator_t(job_list_t &jobs); + explicit job_iterator_t(job_list_t &jobs); job_iterator_t(); size_t count() const; }; diff --git a/src/screen.cpp b/src/screen.cpp index dc78d2278..7bb5cf4bd 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -74,7 +74,7 @@ class scoped_buffer_t int (* const old_writer)(char); public: - scoped_buffer_t(data_buffer_t *buff) : old_buff(s_writeb_buffer), old_writer(output_get_writer()) + explicit scoped_buffer_t(data_buffer_t *buff) : old_buff(s_writeb_buffer), old_writer(output_get_writer()) { s_writeb_buffer = buff; output_set_writer(s_writeb); diff --git a/src/tokenizer.h b/src/tokenizer.h index d88feef6c..d6de25598 100644 --- a/src/tokenizer.h +++ b/src/tokenizer.h @@ -195,7 +195,7 @@ class move_word_state_machine_t public: - move_word_state_machine_t(move_word_style_t st); + explicit move_word_state_machine_t(move_word_style_t st); bool consume_char(wchar_t c); void reset(); };