From edc5bf171bf23ee7948132b0559873d97d7d0bd7 Mon Sep 17 00:00:00 2001 From: Tim Stack Date: Fri, 14 Jun 2024 09:07:48 -0700 Subject: [PATCH] [coverity] (more) use move to avoid auto copies --- src/breadcrumb_curses.cc | 10 +- src/json-extension-functions.cc | 6 +- src/lnav.cc | 23 ++-- src/lnav.indexing.cc | 4 +- src/lnav.management_cli.cc | 223 ++++++++++++++++++-------------- src/lnav_commands.cc | 12 +- src/lnav_config.cc | 12 +- src/log.watch.cc | 6 +- src/log_format_loader.cc | 10 +- src/md2attr_line.cc | 27 ++-- src/piper.looper.cc | 4 +- src/regexp_vtab.cc | 7 +- src/spectro_impls.cc | 24 ++-- src/static_file_vtab.cc | 5 +- src/text_overlay_menu.cc | 3 +- src/view_helpers.cc | 6 +- src/views_vtab.cc | 9 +- src/xpath_vtab.cc | 12 +- 18 files changed, 240 insertions(+), 163 deletions(-) diff --git a/src/breadcrumb_curses.cc b/src/breadcrumb_curses.cc index d2be6901..10995fbe 100644 --- a/src/breadcrumb_curses.cc +++ b/src/breadcrumb_curses.cc @@ -152,10 +152,12 @@ breadcrumb_curses::reload_data() } } - auto matches = attr_line_t().join( - this->bc_similar_values - | lnav::itertools::map(&breadcrumb::possibility::p_display_value), - "\n"); + auto matches = attr_line_t() + .join(this->bc_similar_values + | lnav::itertools::map( + &breadcrumb::possibility::p_display_value), + "\n") + .move(); this->bc_match_source.replace_with(matches); auto width = this->bc_possible_values | lnav::itertools::fold( diff --git a/src/json-extension-functions.cc b/src/json-extension-functions.cc index 70d267e4..d25fff5c 100644 --- a/src/json-extension-functions.cc +++ b/src/json-extension-functions.cc @@ -293,7 +293,8 @@ sql_jget(sqlite3_context* context, int argc, sqlite3_value** argv) err = yajl_get_error( handle.in(), 1, json_in.udata(), json_in.length()); auto um = lnav::console::user_message::error("invalid JSON") - .with_reason((const char*) err); + .with_reason((const char*) err) + .move(); to_sqlite(context, um); yajl_free_error(handle.in(), err); @@ -318,7 +319,8 @@ sql_jget(sqlite3_context* context, int argc, sqlite3_value** argv) err = yajl_get_error( handle.in(), 1, json_in.udata(), json_in.length()); auto um = lnav::console::user_message::error("invalid JSON") - .with_reason((const char*) err); + .with_reason((const char*) err) + .move(); to_sqlite(context, um); yajl_free_error(handle.in(), err); diff --git a/src/lnav.cc b/src/lnav.cc index b2684cda..f6b4ec9d 100644 --- a/src/lnav.cc +++ b/src/lnav.cc @@ -986,11 +986,11 @@ check_for_file_zones() } } if (with_tz_count > 0 && !without_tz_files.empty()) { - auto note + const auto note = attr_line_t("The file(s) without a zone: ") - .join( - without_tz_files, VC_ROLE.value(role_t::VCR_FILE), ", "); - auto um + .join(without_tz_files, VC_ROLE.value(role_t::VCR_FILE), ", ") + .move(); + const auto um = lnav::console::user_message::warning( "Some messages may not be sorted by time correctly") .with_reason( @@ -1003,7 +1003,8 @@ check_for_file_zones() .append(":set-file-timezone"_symbol) .append( " command to set the zone for messages in files " - "that do not include a zone in the timestamp")); + "that do not include a zone in the timestamp")) + .move(); lnav_data.ld_exec_context.ec_error_callback_stack.back()(um); } @@ -2644,7 +2645,8 @@ SELECT tbl_name FROM sqlite_master WHERE sql LIKE 'CREATE VIRTUAL TABLE%' "definition " "files to install in your lnav " "configuration " - "directory"); + "directory") + .move(); const auto install_help = attr_line_t( "log format definitions are JSON files that " @@ -2653,7 +2655,8 @@ SELECT tbl_name FROM sqlite_master WHERE sql LIKE 'CREATE VIRTUAL TABLE%' .append( "See: " "https://docs.lnav.org/en/latest/" - "formats.html"); + "formats.html") + .move(); lnav::console::print(stderr, lnav::console::user_message::error( @@ -2759,7 +2762,8 @@ SELECT tbl_name FROM sqlite_master WHERE sql LIKE 'CREATE VIRTUAL TABLE%' auto um = lnav::console::user_message::error( attr_line_t("cannot read file to install -- ") .append(lnav::roles::file(file_path))) - .with_reason(read_res.unwrap()); + .with_reason(read_res.unwrap()) + .move(); lnav::console::print(stderr, um); return EXIT_FAILURE; @@ -2790,7 +2794,8 @@ SELECT tbl_name FROM sqlite_master WHERE sql LIKE 'CREATE VIRTUAL TABLE%' auto um = lnav::console::user_message::error( attr_line_t("failed to install file to -- ") .append(lnav::roles::file(dst_path))) - .with_reason(write_res.unwrapErr()); + .with_reason(write_res.unwrapErr()) + .move(); lnav::console::print(stderr, um); return EXIT_FAILURE; diff --git a/src/lnav.indexing.cc b/src/lnav.indexing.cc index 8ce7ad9f..24c550ab 100644 --- a/src/lnav.indexing.cc +++ b/src/lnav.indexing.cc @@ -457,8 +457,8 @@ update_active_files(file_collection& new_files) .with_help( attr_line_t("Use ") .append("ulimit -n"_quoted_code) - .append( - " to increase the limit before running lnav")); + .append(" to increase the limit before running lnav")) + .move(); lnav_data.ld_exec_context.ec_error_callback_stack.back()(um); } diff --git a/src/lnav.management_cli.cc b/src/lnav.management_cli.cc index 93525a3a..c6a0f3ff 100644 --- a/src/lnav.management_cli.cc +++ b/src/lnav.management_cli.cc @@ -94,12 +94,15 @@ struct subcmd_config_t { static perform_result_t default_action(const subcmd_config_t& sc) { - auto um = console::user_message::error( - "expecting an operation related to the regex101.com integration"); - um.with_help( - sc.sc_config_app->get_subcommands({}) - | lnav::itertools::fold( - subcmd_reducer, attr_line_t{"the available operations are:"})); + auto um + = console::user_message::error( + "expecting an operation related to the regex101.com " + "integration") + .with_help(sc.sc_config_app->get_subcommands({}) + | lnav::itertools::fold( + subcmd_reducer, + attr_line_t{"the available operations are:"})) + .move(); return {std::move(um)}; } @@ -148,7 +151,8 @@ struct subcmd_config_t { auto um = lnav::console::user_message::error( attr_line_t("Unable to get full path for file: ") .append(lnav::roles::file(sc.sc_path))) - .with_reason(realpath_res.unwrapErr()); + .with_reason(realpath_res.unwrapErr()) + .move(); return {std::move(um)}; } @@ -176,7 +180,8 @@ struct subcmd_config_t { .append(":set-file-timezone"_symbol) .append( " command to set the zone for messages in files " - "that do not include a zone in the timestamp")); + "that do not include a zone in the timestamp")) + .move(); return {std::move(um)}; } @@ -212,33 +217,41 @@ struct subcmd_format_t { const { if (this->sf_name.empty()) { - auto um = console::user_message::error( - "expecting a format name to operate on"); - um.with_note( - (log_format::get_root_formats() - | lnav::itertools::map(&log_format::get_name) - | lnav::itertools::sort_with(intern_string_t::case_lt) - | lnav::itertools::map(&intern_string_t::to_string) - | lnav::itertools::fold(symbol_reducer, attr_line_t{})) - .add_header("the available formats are: ") - .wrap_with(&DEFAULT_WRAPPING)); + auto um + = console::user_message::error( + "expecting a format name to operate on") + .with_note( + (log_format::get_root_formats() + | lnav::itertools::map(&log_format::get_name) + | lnav::itertools::sort_with( + intern_string_t::case_lt) + | lnav::itertools::map(&intern_string_t::to_string) + | lnav::itertools::fold(symbol_reducer, + attr_line_t{})) + .add_header("the available formats are: ") + .wrap_with(&DEFAULT_WRAPPING)) + .move(); return Err(um); } auto lformat = log_format::find_root_format(this->sf_name.c_str()); if (lformat == nullptr) { - auto um = console::user_message::error( - attr_line_t("unknown format: ") - .append(lnav::roles::symbol(this->sf_name))); - um.with_note( - (log_format::get_root_formats() - | lnav::itertools::map(&log_format::get_name) - | lnav::itertools::similar_to(this->sf_name) - | lnav::itertools::map(&intern_string_t::to_string) - | lnav::itertools::fold(symbol_reducer, attr_line_t{})) - .add_header("did you mean one of the following?\n") - .wrap_with(&DEFAULT_WRAPPING)); + auto um + = console::user_message::error( + attr_line_t("unknown format: ") + .append(lnav::roles::symbol(this->sf_name))) + .with_note( + (log_format::get_root_formats() + | lnav::itertools::map(&log_format::get_name) + | lnav::itertools::similar_to(this->sf_name) + | lnav::itertools::map(&intern_string_t::to_string) + | lnav::itertools::fold(symbol_reducer, + attr_line_t{})) + .add_header( + "did you mean one of the following?\n") + .wrap_with(&DEFAULT_WRAPPING)) + .move(); return Err(um); } @@ -271,15 +284,18 @@ struct subcmd_format_t { auto* ext_lformat = TRY(this->validate_external_format()); if (this->sf_regex_name.empty()) { - auto um = console::user_message::error( - "expecting a regex name to operate on"); - um.with_note( - ext_lformat->elf_pattern_order - | lnav::itertools::map(&external_log_format::pattern::p_name) - | lnav::itertools::map(&intern_string_t::to_string) - | lnav::itertools::fold( - symbol_reducer, - attr_line_t{"the available regexes are: "})); + auto um + = console::user_message::error( + "expecting a regex name to operate on") + .with_note( + ext_lformat->elf_pattern_order + | lnav::itertools::map( + &external_log_format::pattern::p_name) + | lnav::itertools::map(&intern_string_t::to_string) + | lnav::itertools::fold( + symbol_reducer, + attr_line_t{"the available regexes are: "})) + .move(); return Err(um); } @@ -290,16 +306,19 @@ struct subcmd_format_t { } } - auto um = console::user_message::error( - attr_line_t("unknown regex: ") - .append(lnav::roles::symbol(this->sf_regex_name))); - um.with_note( - (ext_lformat->elf_pattern_order - | lnav::itertools::map(&external_log_format::pattern::p_name) - | lnav::itertools::map(&intern_string_t::to_string) - | lnav::itertools::similar_to(this->sf_regex_name) - | lnav::itertools::fold(symbol_reducer, attr_line_t{})) - .add_header("did you mean one of the following?\n")); + auto um + = console::user_message::error( + attr_line_t("unknown regex: ") + .append(lnav::roles::symbol(this->sf_regex_name))) + .with_note( + (ext_lformat->elf_pattern_order + | lnav::itertools::map( + &external_log_format::pattern::p_name) + | lnav::itertools::map(&intern_string_t::to_string) + | lnav::itertools::similar_to(this->sf_regex_name) + | lnav::itertools::fold(symbol_reducer, attr_line_t{})) + .add_header("did you mean one of the following?\n")) + .move(); return Err(um); } @@ -327,19 +346,21 @@ struct subcmd_format_t { ", "); } - auto um = console::user_message::error( - attr_line_t("expecting an operation to perform on the ") - .append(lnav::roles::symbol(sf.sf_name)) - .append(" format")); - um.with_note(attr_line_t() - .append(lnav::roles::symbol(sf.sf_name)) - .append(": ") - .append(lformat->lf_description) - .append(ext_details)); - um.with_help( - sf.sf_format_app->get_subcommands({}) - | lnav::itertools::fold( - subcmd_reducer, attr_line_t{"the available operations are:"})); + auto um + = console::user_message::error( + attr_line_t("expecting an operation to perform on the ") + .append(lnav::roles::symbol(sf.sf_name)) + .append(" format")) + .with_note(attr_line_t() + .append(lnav::roles::symbol(sf.sf_name)) + .append(": ") + .append(lformat->lf_description) + .append(ext_details)) + .with_help(sf.sf_format_app->get_subcommands({}) + | lnav::itertools::fold( + subcmd_reducer, + attr_line_t{"the available operations are:"})) + .move(); return {std::move(um)}; } @@ -353,13 +374,15 @@ struct subcmd_format_t { } auto um = console::user_message::error( - attr_line_t("expecting an operation to perform on the ") - .append(lnav::roles::symbol(sf.sf_regex_name)) - .append(" regular expression")); - - um.with_help(attr_line_t{"the available subcommands are:"}.append( - sf.sf_regex_app->get_subcommands({}) - | lnav::itertools::fold(subcmd_reducer, attr_line_t{}))); + attr_line_t("expecting an operation to perform on the ") + .append(lnav::roles::symbol(sf.sf_regex_name)) + .append(" regular expression")) + .with_help( + attr_line_t{"the available subcommands are:"}.append( + sf.sf_regex_app->get_subcommands({}) + | lnav::itertools::fold(subcmd_reducer, + attr_line_t{}))) + .move(); return {std::move(um)}; } @@ -764,12 +787,14 @@ struct subcmd_piper_t { static perform_result_t default_action(const subcmd_piper_t& sp) { - auto um = console::user_message::error( - "expecting an operation related to piper storage"); - um.with_help( - sp.sp_app->get_subcommands({}) - | lnav::itertools::fold( - subcmd_reducer, attr_line_t{"the available operations are:"})); + auto um + = console::user_message::error( + "expecting an operation related to piper storage") + .with_help(sp.sp_app->get_subcommands({}) + | lnav::itertools::fold( + subcmd_reducer, + attr_line_t{"the available operations are:"})) + .move(); return {std::move(um)}; } @@ -893,7 +918,8 @@ struct subcmd_piper_t { attr_line_t("unable to access piper directory: ") .append(lnav::roles::file( lnav::piper::storage_path().string()))) - .with_reason(ec.message()); + .with_reason(ec.message()) + .move(); return {std::move(um)}; } @@ -910,7 +936,8 @@ struct subcmd_piper_t { .append(lnav::roles::file("lnav")) .append(" or using the ") .append_quoted(lnav::roles::symbol(":sh")) - .append(" command")); + .append(" command")) + .move(); return {std::move(um)}; } @@ -1000,7 +1027,8 @@ struct subcmd_piper_t { "associated metadata.")) .with_help( "You can reopen a capture by passing the piper URL " - "to lnav"); + "to lnav") + .move(); retval.emplace_back(extra_um); } retval.emplace_back(lnav::console::user_message::raw(txt)); @@ -1044,12 +1072,15 @@ struct subcmd_regex101_t { static perform_result_t default_action(const subcmd_regex101_t& sr) { - auto um = console::user_message::error( - "expecting an operation related to the regex101.com integration"); - um.with_help( - sr.sr_app->get_subcommands({}) - | lnav::itertools::fold( - subcmd_reducer, attr_line_t{"the available operations are:"})); + auto um + = console::user_message::error( + "expecting an operation related to the regex101.com " + "integration") + .with_help(sr.sr_app->get_subcommands({}) + | lnav::itertools::fold( + subcmd_reducer, + attr_line_t{"the available operations are:"})) + .move(); return {std::move(um)}; } @@ -1130,12 +1161,14 @@ struct subcmd_crash_t { static perform_result_t default_action(const subcmd_crash_t& sc) { - auto um = console::user_message::error( - "expecting an operation related to crash logs"); - um.with_help( - sc.sc_app->get_subcommands({}) - | lnav::itertools::fold( - subcmd_reducer, attr_line_t{"the available operations are:"})); + auto um + = console::user_message::error( + "expecting an operation related to crash logs") + .with_help(sc.sc_app->get_subcommands({}) + | lnav::itertools::fold( + subcmd_reducer, + attr_line_t{"the available operations are:"})) + .move(); return {std::move(um)}; } @@ -1458,11 +1491,13 @@ perform(std::shared_ptr opts) return opts->o_ops.match( [](const no_subcmd_t& ns) -> perform_result_t { auto um = console::user_message::error( - attr_line_t("expecting an operation to perform")); - um.with_help(ns.ns_root_app->get_subcommands({}) - | lnav::itertools::fold( - subcmd_reducer, - attr_line_t{"the available operations are:"})); + attr_line_t("expecting an operation to perform")) + .with_help( + ns.ns_root_app->get_subcommands({}) + | lnav::itertools::fold( + subcmd_reducer, + attr_line_t{"the available operations are:"})) + .move(); return {std::move(um)}; }, diff --git a/src/lnav_commands.cc b/src/lnav_commands.cc index a81e627f..83bf9f1c 100644 --- a/src/lnav_commands.cc +++ b/src/lnav_commands.cc @@ -1061,8 +1061,10 @@ com_mark_expr(exec_context& ec, #endif if (retcode != SQLITE_OK) { const char* errmsg = sqlite3_errmsg(lnav_data.ld_db); - auto expr_al = attr_line_t(expr).with_attr_for_all( - VC_ROLE.value(role_t::VCR_QUOTED_CODE)); + auto expr_al + = attr_line_t(expr) + .with_attr_for_all(VC_ROLE.value(role_t::VCR_QUOTED_CODE)) + .move(); readline_sqlite_highlighter(expr_al, std::nullopt); auto um = lnav::console::user_message::error( @@ -2626,8 +2628,10 @@ com_filter_expr(exec_context& ec, #endif if (retcode != SQLITE_OK) { const char* errmsg = sqlite3_errmsg(lnav_data.ld_db); - auto expr_al = attr_line_t(expr).with_attr_for_all( - VC_ROLE.value(role_t::VCR_QUOTED_CODE)); + auto expr_al + = attr_line_t(expr) + .with_attr_for_all(VC_ROLE.value(role_t::VCR_QUOTED_CODE)) + .move(); readline_sqlite_highlighter(expr_al, std::nullopt); auto um = lnav::console::user_message::error( attr_line_t("invalid filter expression: ") diff --git a/src/lnav_config.cc b/src/lnav_config.cc index 280ac945..448a45a0 100644 --- a/src/lnav_config.cc +++ b/src/lnav_config.cc @@ -279,7 +279,8 @@ install_from_git(const std::string& repo) .with_reason( attr_line_t("git failed to create the local directory ") .append( - lnav::roles::file(local_staging_path.string()))); + lnav::roles::file(local_staging_path.string()))) + .move(); lnav::console::print(stderr, um); return false; } @@ -330,7 +331,8 @@ install_from_git(const std::string& repo) auto um = lnav::console::user_message::error( attr_line_t("invalid lnav repo: ") .append(lnav::roles::file(repo))) - .with_reason("no .json, .sql, or .lnav files were found"); + .with_reason("no .json, .sql, or .lnav files were found") + .move(); lnav::console::print(stderr, um); return false; } @@ -364,7 +366,8 @@ install_from_git(const std::string& repo) auto um = lnav::console::user_message::ok( attr_line_t("installed lnav repo at: ") .append(lnav::roles::file(local_configs_path.string()))) - .with_note(notes); + .with_note(notes) + .move(); lnav::console::print(stdout, um); return true; @@ -2056,7 +2059,8 @@ reload_config(std::vector& errors) um.um_message = attr_line_t() .append("missing value for property ") - .append_quoted(lnav::roles::symbol(path)); + .append_quoted(lnav::roles::symbol(path)) + .move(); } errors.emplace_back(um); diff --git a/src/log.watch.cc b/src/log.watch.cc index 724a7aa2..8c5d5817 100644 --- a/src/log.watch.cc +++ b/src/log.watch.cc @@ -80,7 +80,8 @@ struct expressions : public lnav_config_listener { auto sql_al = attr_line_t(pair.second.we_expr) .with_attr_for_all(SA_PREFORMATTED.value()) .with_attr_for_all( - VC_ROLE.value(role_t::VCR_QUOTED_CODE)); + VC_ROLE.value(role_t::VCR_QUOTED_CODE)) + .move(); readline_sqlite_highlighter(sql_al, std::nullopt); intern_string_t watch_expr_path = intern_string::lookup( fmt::format(FMT_STRING("/log/watch-expressions/{}/expr"), @@ -91,7 +92,8 @@ struct expressions : public lnav_config_listener { auto um = lnav::console::user_message::error( "SQL expression is invalid") .with_reason(sqlite3_errmsg(lnav_db)) - .with_snippet(snippet); + .with_snippet(snippet) + .move(); reporter(&pair.second.we_expr, um); continue; diff --git a/src/log_format_loader.cc b/src/log_format_loader.cc index ebc2623e..04a94f90 100644 --- a/src/log_format_loader.cc +++ b/src/log_format_loader.cc @@ -1287,8 +1287,8 @@ load_format_file(const std::filesystem::path& filename, .append( fmt::format(FMT_STRING(" \"$schema\": \"{}\","), *SUPPORTED_FORMAT_SCHEMAS.begin())) - .with_attr_for_all( - VC_ROLE.value(role_t::VCR_QUOTED_CODE)); + .with_attr_for_all(VC_ROLE.value(role_t::VCR_QUOTED_CODE)) + .move(); errors.emplace_back( lnav::console::user_message::warning( @@ -1588,14 +1588,14 @@ static void find_format_in_path(const std::filesystem::path& path, available_scripts& scripts) { - for (auto format_path : + for (const auto& format_path : {path / "formats/*/*.lnav", path / "configs/*/*.lnav"}) { static_root_mem gl; log_debug("Searching for script in path: %s", format_path.c_str()); if (glob(format_path.c_str(), 0, nullptr, gl.inout()) == 0) { - for (int lpc = 0; lpc < (int) gl->gl_pathc; lpc++) { + for (size_t lpc = 0; lpc < gl->gl_pathc; lpc++) { const char* filename = basename(gl->gl_pathv[lpc]); auto script_name = std::string(filename, strlen(filename) - 5); struct script_metadata meta; @@ -1605,7 +1605,7 @@ find_format_in_path(const std::filesystem::path& path, extract_metadata_from_file(meta); scripts.as_scripts[script_name].push_back(meta); - log_debug(" found script: %s", meta.sm_path.c_str()); + log_info(" found script: %s", meta.sm_path.c_str()); } } } diff --git a/src/md2attr_line.cc b/src/md2attr_line.cc index 04e56133..b68f9000 100644 --- a/src/md2attr_line.cc +++ b/src/md2attr_line.cc @@ -90,7 +90,8 @@ md2attr_line::flush_footnotes() .append(lnav::roles::footnote_text( fmt::format(FMT_STRING("[{}] - "), index))) .append(foot.pad_to(longest_foot)) - .with_attr_for_all(SA_PREFORMATTED.value()); + .with_attr_for_all(SA_PREFORMATTED.value()) + .move(); block_text.append(footline).append("\n"); } @@ -165,7 +166,8 @@ md2attr_line::leave_block(const md4cpp::event_handler::block& bl) } else if (bl.is()) { block_text = attr_line_t() .append(lnav::roles::hr(repeat("\u2501", 70))) - .with_attr_for_all(SA_PREFORMATTED.value()); + .with_attr_for_all(SA_PREFORMATTED.value()) + .move(); last_block.append("\n").append(block_text).append("\n"); } else if (bl.is() || bl.is()) { this->ml_list_stack.pop_back(); @@ -287,7 +289,7 @@ md2attr_line::leave_block(const md4cpp::event_handler::block& bl) new_block_text.append(line).append("\n"); } } - block_text = new_block_text; + block_text = new_block_text.move(); } auto code_lines = block_text.rtrim().split_lines(); @@ -753,10 +755,11 @@ md2attr_line::to_attr_line(const pugi::xml_node& doc) auto href = attr_line_t() .append(lnav::roles::hyperlink(src_href.value())) - .append(" "); - href.with_attr_for_all( - VC_ROLE.value(role_t::VCR_FOOTNOTE_TEXT)); - href.with_attr_for_all(SA_PREFORMATTED.value()); + .append(" ") + .with_attr_for_all( + VC_ROLE.value(role_t::VCR_FOOTNOTE_TEXT)) + .with_attr_for_all(SA_PREFORMATTED.value()) + .move(); this->ml_footnotes.emplace_back(href); } else { retval.append(link_label); @@ -1080,10 +1083,12 @@ md2attr_line::append_url_footnote(std::string href_str) href_str = fmt::format(FMT_STRING("file://{}"), link_path.string()); } - auto href - = attr_line_t().append(lnav::roles::hyperlink(href_str)).append(" "); - href.with_attr_for_all(VC_ROLE.value(role_t::VCR_FOOTNOTE_TEXT)); - href.with_attr_for_all(SA_PREFORMATTED.value()); + auto href = attr_line_t() + .append(lnav::roles::hyperlink(href_str)) + .append(" ") + .with_attr_for_all(VC_ROLE.value(role_t::VCR_FOOTNOTE_TEXT)) + .with_attr_for_all(SA_PREFORMATTED.value()) + .move(); this->ml_footnotes.emplace_back(href); return href_str; diff --git a/src/piper.looper.cc b/src/piper.looper.cc index 5b361f87..aaa401e9 100644 --- a/src/piper.looper.cc +++ b/src/piper.looper.cc @@ -749,8 +749,8 @@ cleanup() { (void) std::async(std::launch::async, []() { const auto& cfg = injector::get(); - auto now = std::filesystem::file_time_type::clock::now(); - auto cache_path = storage_path(); + const auto now = std::filesystem::file_time_type::clock::now(); + const auto& cache_path = storage_path(); std::vector to_remove; for (const auto& cache_subdir : diff --git a/src/regexp_vtab.cc b/src/regexp_vtab.cc index 30fcde5a..bcc86b6f 100644 --- a/src/regexp_vtab.cc +++ b/src/regexp_vtab.cc @@ -514,9 +514,10 @@ rcjFilter(sqlite3_vtab_cursor* pVtabCursor, flags_json); if (parse_res.isErr()) { - auto um = lnav::console::user_message::error( - "unable to parse flags") - .with_reason(parse_res.unwrapErr()[0]); + const auto um = lnav::console::user_message::error( + "unable to parse flags") + .with_reason(parse_res.unwrapErr()[0]) + .move(); set_vtable_errmsg(pVtabCursor->pVtab, um); return SQLITE_ERROR; diff --git a/src/spectro_impls.cc b/src/spectro_impls.cc index beab8b58..ae262813 100644 --- a/src/spectro_impls.cc +++ b/src/spectro_impls.cc @@ -105,7 +105,8 @@ public: std::vector fss_lines; }; -log_spectro_value_source::log_spectro_value_source(intern_string_t colname) +log_spectro_value_source:: +log_spectro_value_source(intern_string_t colname) : lsvs_colname(colname) { this->update_stats(); @@ -330,7 +331,8 @@ log_spectro_value_source::spectro_mark(textview_curses& tc, } } -db_spectro_value_source::db_spectro_value_source(std::string colname) +db_spectro_value_source:: +db_spectro_value_source(std::string colname) : dsvs_colname(std::move(colname)) { this->update_stats(); @@ -354,7 +356,8 @@ db_spectro_value_source::update_stats() .append(" ") .append("log_time"_variable) .append(" ") - .append("ASC"_keyword); + .append("ASC"_keyword) + .move(); this->dsvs_error_msg = lnav::console::user_message::error( @@ -378,7 +381,8 @@ db_spectro_value_source::update_stats() .append_quoted(order_by_help) .append(" clause to your ") .append("SELECT"_keyword) - .append(" statement")); + .append(" statement")) + .move(); } else { this->dsvs_error_msg = lnav::console::user_message::error( @@ -400,7 +404,8 @@ db_spectro_value_source::update_stats() .append(" statement. Use an ") .append("AS"_keyword) .append( - " directive to alias a computed timestamp")); + " directive to alias a computed timestamp")) + .move(); } return; } @@ -412,7 +417,8 @@ db_spectro_value_source::update_stats() .with_reason(attr_line_t("unknown column -- ") .append_quoted(lnav::roles::variable( this->dsvs_colname))) - .with_help("Expecting a numeric column to visualize"); + .with_help("Expecting a numeric column to visualize") + .move(); return; } @@ -424,7 +430,8 @@ db_spectro_value_source::update_stats() .append_quoted(lnav::roles::variable( this->dsvs_colname)) .append(" is not a numeric column")) - .with_help("Only numeric columns can be visualized"); + .with_help("Only numeric columns can be visualized") + .move(); return; } @@ -432,7 +439,8 @@ db_spectro_value_source::update_stats() this->dsvs_error_msg = lnav::console::user_message::error( "Cannot generate spectrogram for database results") - .with_reason("Result set is empty"); + .with_reason("Result set is empty") + .move(); return; } diff --git a/src/static_file_vtab.cc b/src/static_file_vtab.cc index df95b286..1c154707 100644 --- a/src/static_file_vtab.cc +++ b/src/static_file_vtab.cc @@ -27,6 +27,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include "static_file_vtab.hh" @@ -37,7 +38,6 @@ #include "base/fs_util.hh" #include "base/lnav_log.hh" #include "config.h" -#include #include "lnav.hh" #include "vtab_module.hh" @@ -232,7 +232,8 @@ sfvt_column(sqlite3_vtab_cursor* cur, sqlite3_context* ctx, int col) if (read_res.isErr()) { auto um = lnav::console::user_message::error( "unable to read static file") - .with_reason(read_res.unwrapErr()); + .with_reason(read_res.unwrapErr()) + .move(); to_sqlite(ctx, um); } else { diff --git a/src/text_overlay_menu.cc b/src/text_overlay_menu.cc index 11dbd4bb..845e5e62 100644 --- a/src/text_overlay_menu.cc +++ b/src/text_overlay_menu.cc @@ -79,7 +79,8 @@ text_overlay_menu::list_overlay_menu(const listview_curses& lv, vis_line_t row) = attr_line_t(" Link: ") .append(lnav::roles::table_header(sti.sti_href)) .with_attr_for_all(VC_ROLE.value(role_t::VCR_STATUS_INFO)) - .with_attr_for_all(VC_STYLE.value(ta)); + .with_attr_for_all(VC_STYLE.value(ta)) + .move(); retval.emplace_back(href_al); menu_line += 1_vl; } diff --git a/src/view_helpers.cc b/src/view_helpers.cc index aca20ea4..21a1ba8c 100644 --- a/src/view_helpers.cc +++ b/src/view_helpers.cc @@ -1056,16 +1056,16 @@ execute_examples() auto old_width = dls.dls_max_column_width; dls.dls_max_column_width = 15; - for (auto help_pair : sqlite_function_help) { + for (const auto& help_pair : sqlite_function_help) { execute_example(*help_pair.second); } - for (auto help_pair : lnav::sql::prql_functions) { + for (const auto& help_pair : lnav::sql::prql_functions) { if (help_pair.second->ht_context != help_context_t::HC_PRQL_FUNCTION) { continue; } execute_example(*help_pair.second); } - for (auto cmd_pair : *sql_cmd_map) { + for (const auto& cmd_pair : *sql_cmd_map) { if (cmd_pair.second->c_help.ht_context != help_context_t::HC_PRQL_TRANSFORM && cmd_pair.second->c_help.ht_context diff --git a/src/views_vtab.cc b/src/views_vtab.cc index 75f44c77..514b3d0b 100644 --- a/src/views_vtab.cc +++ b/src/views_vtab.cc @@ -588,7 +588,8 @@ CREATE TABLE lnav_views ( .append(" value")) .with_reason( attr_line_t("Unrecognized time value: ") - .append(lnav::roles::string(top_time))); + .append(lnav::roles::string(top_time))) + .move(); set_vtable_errmsg(tab, um); return SQLITE_ERROR; } @@ -620,7 +621,8 @@ CREATE TABLE lnav_views ( .append(" value")) .with_reason(attr_line_t("Unknown text file: ") .append(lnav::roles::file( - tlm.tlm_file.value()))); + tlm.tlm_file.value()))) + .move(); set_vtable_errmsg(tab, um); return SQLITE_ERROR; } @@ -646,7 +648,8 @@ CREATE TABLE lnav_views ( .append(" value")) .with_reason( attr_line_t("Unknown anchor: ") - .append(lnav::roles::symbol(req_anchor))); + .append(lnav::roles::symbol(req_anchor))) + .move(); set_vtable_errmsg(tab, um); return SQLITE_ERROR; } diff --git a/src/xpath_vtab.cc b/src/xpath_vtab.cc index 0fe88bdd..20387ba0 100644 --- a/src/xpath_vtab.cc +++ b/src/xpath_vtab.cc @@ -317,7 +317,8 @@ rcFilter(sqlite3_vtab_cursor* pVtabCursor, auto attr_xmldoc = attr_line_t(pCur->c_value) - .with_attr_for_all(VC_ROLE.value(role_t::VCR_QUOTED_CODE)); + .with_attr_for_all(VC_ROLE.value(role_t::VCR_QUOTED_CODE)) + .move(); auto um = lnav::console::user_message::error("Invalid XML document") .with_reason(parse_res.description()) .with_snippet( @@ -325,7 +326,8 @@ rcFilter(sqlite3_vtab_cursor* pVtabCursor, ARG1, attr_xmldoc, parse_res.offset, - parse_res.description())); + parse_res.description())) + .move(); set_vtable_errmsg(pVtabCursor->pVtab, um); return SQLITE_ERROR; } @@ -338,12 +340,14 @@ rcFilter(sqlite3_vtab_cursor* pVtabCursor, const auto& res = pCur->c_query.result(); auto attr_xpath = attr_line_t(pCur->c_xpath) - .with_attr_for_all(VC_ROLE.value(role_t::VCR_QUOTED_CODE)); + .with_attr_for_all(VC_ROLE.value(role_t::VCR_QUOTED_CODE)) + .move(); auto um = lnav::console::user_message::error("Invalid XPath expression") .with_reason(res.description()) .with_snippet( lnav::console::snippet::from_content_with_offset( - ARG0, attr_xpath, res.offset, res.description())); + ARG0, attr_xpath, res.offset, res.description())) + .move(); set_vtable_errmsg(pVtabCursor->pVtab, um); return SQLITE_ERROR; }