From 121be1a558841ca31b65d99ddf3e1fda602e7892 Mon Sep 17 00:00:00 2001 From: Phil Hord Date: Tue, 27 Mar 2018 17:43:48 -0700 Subject: [PATCH 1/4] Add updated definition to squash warning _BSD_SOURCE is deprecated and using it emits warnings unless you also define _DEFAULT_SOURCE. Let's define _DEFAULT_SOURCE. --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index 76274102..666ed427 100644 --- a/configure.ac +++ b/configure.ac @@ -144,6 +144,7 @@ LNAV_WITH_SQLITE3("3.9.0") case "$host_os" in *) # AC_DEFINE([_XOPEN_SOURCE], [500], [Need pread]) + AC_DEFINE([_DEFAULT_SOURCE], [1], [Need pread]) AC_DEFINE([_BSD_SOURCE], [1], [Need pread]) ;; esac From 5a20829ed4f453198e889cae62dc767c43be76f7 Mon Sep 17 00:00:00 2001 From: Phil Hord Date: Tue, 27 Mar 2018 17:45:49 -0700 Subject: [PATCH 2/4] dynamic exception specifications are deprecated in C++11 Remove exception specifications to appease modern compilers and reduce warning counts. I sort of hate to remove all these exception-decls, but they are in fact deprecated, and my compiler loves to complain. --- src/line_buffer.cc | 9 +-------- src/line_buffer.hh | 19 ++++++++----------- src/logfile.cc | 2 -- src/logfile.hh | 5 ++--- src/pcrepp.hh | 2 +- 5 files changed, 12 insertions(+), 25 deletions(-) diff --git a/src/line_buffer.cc b/src/line_buffer.cc index 90552d55..59bfa675 100644 --- a/src/line_buffer.cc +++ b/src/line_buffer.cc @@ -139,7 +139,6 @@ line_buffer::~line_buffer() } void line_buffer::set_fd(auto_fd &fd) -throw (error) { off_t newoff = 0; @@ -220,7 +219,6 @@ throw (error) } void line_buffer::resize_buffer(size_t new_max) -throw (error) { require(this->lb_bz_file || this->lb_gz_file || new_max <= MAX_LINE_BUFFER_SIZE); @@ -244,7 +242,6 @@ throw (error) } void line_buffer::ensure_available(off_t start, size_t max_length) -throw (error) { size_t prefill, available; @@ -317,7 +314,6 @@ throw (error) } bool line_buffer::fill_range(off_t start, size_t max_length) -throw (error) { bool retval = false; @@ -484,7 +480,6 @@ throw (error) } bool line_buffer::read_line(off_t &offset, line_value &lv, bool include_delim) -throw (error) { size_t request_size = DEFAULT_INCREMENT; bool retval = false; @@ -592,7 +587,6 @@ throw (error) } bool line_buffer::read_line(off_t &offset_inout, shared_buffer_ref &sbr, line_value *lv) - throw (error) { line_value lv_tmp; bool retval; @@ -612,7 +606,6 @@ bool line_buffer::read_line(off_t &offset_inout, shared_buffer_ref &sbr, line_va } bool line_buffer::read_range(off_t offset, size_t len, shared_buffer_ref &sbr) - throw (error) { char *line_start; size_t avail; @@ -636,7 +629,7 @@ bool line_buffer::read_range(off_t offset, size_t len, shared_buffer_ref &sbr) return true; } -void line_buffer::read_available(shared_buffer_ref &sbr) throw(error) +void line_buffer::read_available(shared_buffer_ref &sbr) { sbr.disown(); diff --git a/src/line_buffer.hh b/src/line_buffer.hh index d2d6997f..be8474d6 100644 --- a/src/line_buffer.hh +++ b/src/line_buffer.hh @@ -82,7 +82,7 @@ public: virtual ~line_buffer(); /** @param fd The file descriptor that data should be pulled from. */ - void set_fd(auto_fd &fd) throw (error); + void set_fd(auto_fd &fd); /** @return The file descriptor that data should be pulled from. */ int get_fd() const { return this->lb_fd; }; @@ -140,16 +140,13 @@ public: * line to refresh the buffer. */ bool read_line(off_t &offset_inout, line_value &lv, - bool include_delim = false) - throw (error); + bool include_delim = false); - bool read_line(off_t &offset_inout, shared_buffer_ref &sbr, line_value *lv = NULL) - throw (error); + bool read_line(off_t &offset_inout, shared_buffer_ref &sbr, line_value *lv = NULL); - bool read_range(off_t offset, size_t len, shared_buffer_ref &sbr) - throw (error); + bool read_range(off_t offset, size_t len, shared_buffer_ref &sbr); - void read_available(shared_buffer_ref &sbr) throw(error); + void read_available(shared_buffer_ref &sbr); void clear() { @@ -188,7 +185,7 @@ private: off < (int)(this->lb_file_offset + this->lb_buffer_size); }; - void resize_buffer(size_t new_max) throw (error); + void resize_buffer(size_t new_max); /** * Ensure there is enough room in the buffer to cache a range of data from @@ -202,7 +199,7 @@ private: * @param start The file offset of the start of the line. * @param max_length The amount of data to be cached in the buffer. */ - void ensure_available(off_t start, size_t max_length) throw (error); + void ensure_available(off_t start, size_t max_length); /** * Fill the buffer with the given range of data from the file. @@ -212,7 +209,7 @@ private: * @param max_length The maximum amount of data to read from the file. * @return True if any data was read from the file. */ - bool fill_range(off_t start, size_t max_length) throw (error); + bool fill_range(off_t start, size_t max_length); /** * After a successful fill, the cached data can be retrieved with this diff --git a/src/logfile.cc b/src/logfile.cc index 0d1dc013..bbcc4572 100644 --- a/src/logfile.cc +++ b/src/logfile.cc @@ -54,7 +54,6 @@ static const size_t MAX_UNRECOGNIZED_LINES = 1000; static const size_t INDEX_RESERVE_INCREMENT = 1024; logfile::logfile(const string &filename, logfile_open_options &loo) -throw (error) : lf_filename(filename), lf_index_time(0), lf_index_size(0), @@ -281,7 +280,6 @@ bool logfile::process_prefix(off_t offset, shared_buffer_ref &sbr) } logfile::rebuild_result_t logfile::rebuild_index() -throw (line_buffer::error, logfile::error) { rebuild_result_t retval = RR_NO_NEW_LINES; struct stat st; diff --git a/src/logfile.hh b/src/logfile.hh index 95193e20..394082fe 100644 --- a/src/logfile.hh +++ b/src/logfile.hh @@ -127,7 +127,7 @@ public: * constructor should open the file specified by 'filename'. The * descriptor needs to be seekable. */ - logfile(const std::string &filename, logfile_open_options &loo) throw (error); + logfile(const std::string &filename, logfile_open_options &loo); virtual ~logfile(); @@ -359,8 +359,7 @@ public: * indexing. * @return True if any new lines were indexed. */ - rebuild_result_t rebuild_index() - throw (line_buffer::error, logfile::error); + rebuild_result_t rebuild_index(); void reobserve_from(iterator iter); diff --git a/src/pcrepp.hh b/src/pcrepp.hh index efefae05..2724292b 100644 --- a/src/pcrepp.hh +++ b/src/pcrepp.hh @@ -340,7 +340,7 @@ public: public: error(std::string msg, int offset = 0) : e_msg(msg), e_offset(offset) { }; - virtual ~error() throw () { }; + virtual ~error() { }; virtual const char *what() const throw() { return this->e_msg.c_str(); From eee7d0ddfc599fe457a8f9d197c8226f78d99956 Mon Sep 17 00:00:00 2001 From: Phil Hord Date: Tue, 27 Mar 2018 18:54:50 -0700 Subject: [PATCH 3/4] Squash a bunch of signed/unsigned warnings --- src/help_text_formatter.cc | 2 +- src/hist_source.hh | 2 +- src/line_buffer.cc | 4 ++-- src/lnav.cc | 2 +- src/lnav_commands.cc | 2 +- src/lnav_util.cc | 2 +- src/log_format.cc | 10 +++++----- src/logfile_sub_source.hh | 4 ++-- src/readline_callbacks.cc | 2 +- src/sql_util.cc | 2 +- src/view_curses.cc | 16 ++++++++-------- src/views_vtab.cc | 2 +- src/yajlpp.cc | 2 +- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/help_text_formatter.cc b/src/help_text_formatter.cc index f94b0b88..62358d69 100644 --- a/src/help_text_formatter.cc +++ b/src/help_text_formatter.cc @@ -120,7 +120,7 @@ void format_help_text_for_term(const help_text &ht, int width, attr_line_t &out) .append(ht.ht_name, &view_curses::VC_STYLE, A_BOLD); for (auto ¶m : ht.ht_parameters) { if (break_all || - (out.get_string().length() - start_index - line_start + 10) >= + (int)(out.get_string().length() - start_index - line_start + 10) >= tws.tws_width) { out.append("\n"); line_start = out.get_string().length(); diff --git a/src/hist_source.hh b/src/hist_source.hh index 6eabdec6..8c094e55 100644 --- a/src/hist_source.hh +++ b/src/hist_source.hh @@ -310,7 +310,7 @@ public: if (this->sbc_ident_to_show < -1) { this->sbc_ident_to_show = this->sbc_idents.size() - 1; } - else if (this->sbc_ident_to_show >= this->sbc_idents.size()) { + else if (this->sbc_ident_to_show >= (int)this->sbc_idents.size()) { this->sbc_ident_to_show = -1; } return this->sbc_ident_to_show; diff --git a/src/line_buffer.cc b/src/line_buffer.cc index 59bfa675..0c55e1ee 100644 --- a/src/line_buffer.cc +++ b/src/line_buffer.cc @@ -223,7 +223,7 @@ void line_buffer::resize_buffer(size_t new_max) require(this->lb_bz_file || this->lb_gz_file || new_max <= MAX_LINE_BUFFER_SIZE); - if (new_max > this->lb_buffer_max) { + if (new_max > (size_t)this->lb_buffer_max) { char *tmp, *old; /* Still need more space, try a realloc. */ @@ -248,7 +248,7 @@ void line_buffer::ensure_available(off_t start, size_t max_length) require(max_length <= MAX_LINE_BUFFER_SIZE); if (this->lb_file_size != -1) { - if (start + max_length > this->lb_file_size) { + if (start + (off_t)max_length > this->lb_file_size) { max_length = (this->lb_file_size - start); } } diff --git a/src/lnav.cc b/src/lnav.cc index d4689f27..79bb5bb5 100644 --- a/src/lnav.cc +++ b/src/lnav.cc @@ -2011,7 +2011,7 @@ static void execute_examples() al); ex.he_result.append(al); for (int lpc = 0; - lpc < dls.text_line_count(); lpc++) { + lpc < (int)dls.text_line_count(); lpc++) { al.clear(); dls.text_value_for_line(db_tc, lpc, al.get_string(), diff --git a/src/lnav_commands.cc b/src/lnav_commands.cc index 8906520a..dc4cb996 100644 --- a/src/lnav_commands.cc +++ b/src/lnav_commands.cc @@ -2347,7 +2347,7 @@ static string com_toggle_field(exec_context &ec, string cmdline, vector bool hide = args[0] == "hide-fields"; vector found_fields, missing_fields; - for (int lpc = 1; lpc < args.size(); lpc++) { + for (int lpc = 1; lpc < (int)args.size(); lpc++) { intern_string_t name; log_format *format = nullptr; size_t dot; diff --git a/src/lnav_util.cc b/src/lnav_util.cc index 9425db64..61825b06 100644 --- a/src/lnav_util.cc +++ b/src/lnav_util.cc @@ -577,7 +577,7 @@ const char *date_time_scanner::scan(const char *time_dest, } #endif if (ptime_fmt(time_fmt[curr_time_fmt], tm_out, time_dest, off, time_len) && - (time_dest[off] == '.' || time_dest[off] == ',' || off == time_len)) { + (time_dest[off] == '.' || time_dest[off] == ',' || off == (off_t)time_len)) { retval = &time_dest[off]; if (tm_out->et_tm.tm_year < 70) { tm_out->et_tm.tm_year = 80; diff --git a/src/log_format.cc b/src/log_format.cc index 352b7205..a72e1f42 100644 --- a/src/log_format.cc +++ b/src/log_format.cc @@ -585,13 +585,13 @@ bool external_log_format::scan_for_partial(shared_buffer_ref &sbr, size_t &len_o return true; } - if (pat->p_timestamp_end == -1 || pat->p_timestamp_end > sbr.length()) { + if (pat->p_timestamp_end == -1 || pat->p_timestamp_end > (int)sbr.length()) { len_out = 0; return false; } len_out = pat->p_pcre->match_partial(pi); - return len_out > pat->p_timestamp_end; + return (int)len_out > pat->p_timestamp_end; } log_format::scan_result_t external_log_format::scan(nonstd::optional lf, @@ -1141,7 +1141,7 @@ void external_log_format::get_subline(const logline &ll, shared_buffer_ref &sbr, lr.lr_start = this->jlf_cached_line.size(); lv_iter->lv_hidden = lv_iter->lv_user_hidden; - if (str.size() > jfe.jfe_max_width) { + if ((int)str.size() > jfe.jfe_max_width) { switch (jfe.jfe_overflow) { case json_format_element::ABBREV: { this->json_append_to_cache( @@ -1293,7 +1293,7 @@ void external_log_format::get_subline(const logline &ll, shared_buffer_ref &sbr, if (this->jlf_cached_line[this_off] == '\n') { this_off += 1; } - if ((ll.get_sub_offset() + 1) < this->jlf_line_offsets.size()) { + if ((ll.get_sub_offset() + 1) < (int)this->jlf_line_offsets.size()) { next_off = this->jlf_line_offsets[ll.get_sub_offset() + 1]; } else { @@ -1428,7 +1428,7 @@ void external_log_format::build(std::vector &errors) { stable_sort(pat.p_value_by_index.begin(), pat.p_value_by_index.end()); - for (int lpc = 0; lpc < pat.p_value_by_index.size(); lpc++) { + for (int lpc = 0; lpc < (int)pat.p_value_by_index.size(); lpc++) { auto &ivd = pat.p_value_by_index[lpc]; auto &vd = *ivd.ivd_value_def; diff --git a/src/logfile_sub_source.hh b/src/logfile_sub_source.hh index 27000304..e448dfa5 100644 --- a/src/logfile_sub_source.hh +++ b/src/logfile_sub_source.hh @@ -100,7 +100,7 @@ public: }; void increase_line_context(void) { - long old_flags = this->lss_flags; + auto old_flags = this->lss_flags; if (this->lss_flags & F_FILENAME) { // Nothing to do @@ -116,7 +116,7 @@ public: }; bool decrease_line_context(void) { - long old_flags = this->lss_flags; + auto old_flags = this->lss_flags; if (this->lss_flags & F_FILENAME) { this->lss_flags &= ~F_NAME_MASK; diff --git a/src/readline_callbacks.cc b/src/readline_callbacks.cc index d50cf0c2..86da3aed 100644 --- a/src/readline_callbacks.cc +++ b/src/readline_callbacks.cc @@ -235,7 +235,7 @@ static void rl_search_internal(void *dummy, readline_curses *rc, bool complete = annotate_sql_statement(al); - if (x > 0 && x >= al.length()) { + if (x > 0 && (int)x >= al.length()) { x -= 1; } diff --git a/src/sql_util.cc b/src/sql_util.cc index bc982ca4..9d739dae 100644 --- a/src/sql_util.cc +++ b/src/sql_util.cc @@ -900,7 +900,7 @@ void annotate_sql_statement(attr_line_t &al) bool found_open = false; ssize_t lpc; - for (lpc = iter->sa_range.lr_end; lpc < line.length(); lpc++) { + for (lpc = iter->sa_range.lr_end; lpc < (int)line.length(); lpc++) { if (line[lpc] == '(') { found_open = true; break; diff --git a/src/view_curses.cc b/src/view_curses.cc index 73c92b99..ca01a910 100644 --- a/src/view_curses.cc +++ b/src/view_curses.cc @@ -240,11 +240,11 @@ attr_line_t &attr_line_t::append(const attr_line_t &al, text_wrap_settings *tws) } } - if (tws != nullptr && this->al_string.length() > tws->tws_width) { + if (tws != nullptr && (int)this->al_string.length() > tws->tws_width) { ssize_t start_pos = start_len; ssize_t line_start = this->al_string.rfind('\n', start_pos); - if (line_start == string::npos) { + if (line_start == (ssize_t)string::npos) { line_start = 0; } else { line_start += 1; @@ -258,12 +258,12 @@ attr_line_t &attr_line_t::append(const attr_line_t &al, text_wrap_settings *tws) avail = INT_MAX; } - while (start_pos < this->al_string.length()) { + while (start_pos < (int)this->al_string.length()) { ssize_t lpc; // Find the end of a word or a breakpoint. for (lpc = start_pos; - lpc < this->al_string.length() && + lpc < (int)this->al_string.length() && (isalnum(this->al_string[lpc]) || this->al_string[lpc] == ',' || this->al_string[lpc] == '_' || @@ -286,7 +286,7 @@ attr_line_t &attr_line_t::append(const attr_line_t &al, text_wrap_settings *tws) } else { // There's still room to add stuff. avail -= (lpc - start_pos); - while (lpc < this->al_string.length() && avail) { + while (lpc < (int)this->al_string.length() && avail) { if (this->al_string[lpc] == '\n') { this->insert(lpc + 1, tws->tws_indent, ' '); avail = usable_width; @@ -308,7 +308,7 @@ attr_line_t &attr_line_t::append(const attr_line_t &al, text_wrap_settings *tws) avail = usable_width; for (lpc = start_pos; - lpc < this->al_string.length() && + lpc < (int)this->al_string.length() && this->al_string[lpc] == ' '; lpc++) { } @@ -453,7 +453,7 @@ void view_curses::mvwattrline(WINDOW *window, for (auto tab_iter = tab_list.rbegin(); tab_iter != tab_list.rend(); ++tab_iter) { - if (tab_iter->tm_origin < attr_range.lr_start) { + if ((int)tab_iter->tm_origin < attr_range.lr_start) { attr_range.lr_start += tab_iter->length() - 1; } } @@ -462,7 +462,7 @@ void view_curses::mvwattrline(WINDOW *window, for (auto tab_iter = tab_list.rbegin(); tab_iter != tab_list.rend(); ++tab_iter) { - if (tab_iter->tm_origin < attr_range.lr_end) { + if ((int)tab_iter->tm_origin < attr_range.lr_end) { attr_range.lr_end += tab_iter->length() - 1; } } diff --git a/src/views_vtab.cc b/src/views_vtab.cc index 266d90f7..bde9b8b3 100644 --- a/src/views_vtab.cc +++ b/src/views_vtab.cc @@ -231,7 +231,7 @@ CREATE TABLE lnav_view_stack ( }; int delete_row(sqlite3_vtab *tab, sqlite3_int64 rowid) { - if (rowid != lnav_data.ld_view_stack.size() - 1) { + if ((size_t)rowid != lnav_data.ld_view_stack.size() - 1) { tab->zErrMsg = sqlite3_mprintf( "Only the top view in the stack can be deleted"); return SQLITE_ERROR; diff --git a/src/yajlpp.cc b/src/yajlpp.cc index ab4e1139..47c37c86 100644 --- a/src/yajlpp.cc +++ b/src/yajlpp.cc @@ -615,7 +615,7 @@ void yajlpp_parse_context::update_callbacks(const json_path_handler_base *orig_h this->update_callbacks(jph.jph_children, child_start + cap->c_end); } else { - if (child_start + cap->c_end != this->ypc_path.size() - 1) { + if (child_start + cap->c_end != (int)this->ypc_path.size() - 1) { continue; } From 3f7f80e32c528dcad714ee81b38b1359d76ed8bb Mon Sep 17 00:00:00 2001 From: Phil Hord Date: Tue, 27 Mar 2018 19:07:13 -0700 Subject: [PATCH 4/4] Squash various compiler warnings Unused-result from sensitive APIs, printf/scanf formatting types, set but never used variables, and uninitialized variables. Also there's one select(enum) that doesn't cover all cases. --- src/lnav_commands.cc | 2 +- src/lnav_log.cc | 11 ++++++----- src/log_vtab_impl.cc | 1 + src/logfile_sub_source.cc | 5 ++++- src/readline_callbacks.cc | 4 +++- src/string-extension-functions.cc | 6 +++--- src/view_curses.cc | 4 ++-- test/scripty.cc | 2 +- test/test_ncurses_unicode.cc | 5 +++-- 9 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/lnav_commands.cc b/src/lnav_commands.cc index dc4cb996..935e02f9 100644 --- a/src/lnav_commands.cc +++ b/src/lnav_commands.cc @@ -156,7 +156,7 @@ static string com_adjust_log_time(exec_context &ec, string cmdline, vector 0 && tolower(response) == 'y') { pid_t lnav_pid = getpid(); pid_t child_pid; @@ -436,6 +436,7 @@ static void sigabrt(int sig) _exit(1); } +#pragma GCC diagnostic pop void log_install_handlers(void) { diff --git a/src/log_vtab_impl.cc b/src/log_vtab_impl.cc index 3a946160..a3b60970 100644 --- a/src/log_vtab_impl.cc +++ b/src/log_vtab_impl.cc @@ -849,6 +849,7 @@ string log_vtab_manager::unregister_vtab(intern_string_t name) } else { auto_mem sql(sqlite3_free); + __attribute((unused)) int rc; sql = sqlite3_mprintf("DROP TABLE %s ", name.get()); diff --git a/src/logfile_sub_source.cc b/src/logfile_sub_source.cc index d7aa0ce6..9ec77404 100644 --- a/src/logfile_sub_source.cc +++ b/src/logfile_sub_source.cc @@ -324,7 +324,7 @@ void logfile_sub_source::text_attrs_for_line(textview_curses &lv, chtype graph = ACS_VLINE; if (is_first_for_file) { if (is_last_for_file) { - graph = ACS_DIAMOND; + graph = ACS_HLINE; } else { graph = ACS_ULCORNER; @@ -472,6 +472,9 @@ bool logfile_sub_source::rebuild_index(bool force) logfile &lf = *ld.get_file(); switch (lf.rebuild_index()) { + case logfile::RR_NO_NEW_LINES: + // No changes + break; case logfile::RR_NEW_LINES: retval = true; if (!this->lss_index.empty()) { diff --git a/src/readline_callbacks.cc b/src/readline_callbacks.cc index 86da3aed..226f2f9a 100644 --- a/src/readline_callbacks.cc +++ b/src/readline_callbacks.cc @@ -502,7 +502,9 @@ void rl_display_matches(void *dummy, readline_curses *rc) { const std::vector &matches = rc->get_matches(); textview_curses &tc = lnav_data.ld_match_view; - unsigned long width, height; + unsigned long width; + __attribute((unused)) + unsigned long height; int max_len, cols, rows; getmaxyx(lnav_data.ld_window, height, width); diff --git a/src/string-extension-functions.cc b/src/string-extension-functions.cc index 69cfdfbf..013e86dc 100644 --- a/src/string-extension-functions.cc +++ b/src/string-extension-functions.cc @@ -103,7 +103,7 @@ regexp_match(const char *re, const char *str) } else { char *cap_copy = (char *)alloca(cap->length() + 1); - int64_t i_value; + long long int i_value; double d_value; int end_index; @@ -112,7 +112,7 @@ regexp_match(const char *re, const char *str) if (sscanf(cap_copy, "%lld%n", &i_value, &end_index) == 1 && (end_index == cap->length())) { - return i_value; + return (int64_t)i_value; } else if (sscanf(cap_copy, "%lf%n", &d_value, &end_index) == 1 && (end_index == cap->length())) { @@ -139,7 +139,7 @@ regexp_match(const char *re, const char *str) else { const char *cap_start = pi.get_substr_start(cap); char *cap_copy = (char *) alloca(cap->length() + 1); - int64_t i_value; + long long int i_value; double d_value; int end_index; diff --git a/src/view_curses.cc b/src/view_curses.cc index ca01a910..565c2d4d 100644 --- a/src/view_curses.cc +++ b/src/view_curses.cc @@ -204,10 +204,10 @@ attr_line_t &attr_line_t::with_ansi_string(const char *str, ...) va_list args; va_start(args, str); - vasprintf(formatted_str.out(), str, args); + auto ret = vasprintf(formatted_str.out(), str, args); va_end(args); - if (formatted_str != NULL) { + if (ret >= 0 && formatted_str != NULL) { this->al_string = formatted_str; scrub_ansi_string(this->al_string, this->al_attrs); } diff --git a/test/scripty.cc b/test/scripty.cc index 5c799317..dff2eacf 100644 --- a/test/scripty.cc +++ b/test/scripty.cc @@ -517,7 +517,7 @@ int main(int argc, char *argv[]) else { int maxfd, out_len = 0; bool got_expected = true; - bool got_user_step; + bool got_user_step = false; struct timeval last, now; char out_buffer[8192]; fd_set read_fds; diff --git a/test/test_ncurses_unicode.cc b/test/test_ncurses_unicode.cc index ebe25cff..67cc6bea 100644 --- a/test/test_ncurses_unicode.cc +++ b/test/test_ncurses_unicode.cc @@ -27,8 +27,9 @@ int main(int argc, char *argv[]) FILE *file = fopen(argv[1], "r"); int row = 0; while (!feof(file)) { - fgets(buf, sizeof(buf), file); - mvwaddstr(stdscr, row++, 0, buf); + if (0 < fgets(buf, sizeof(buf), file)) { + mvwaddstr(stdscr, row++, 0, buf); + } } getch(); endwin();