mirror of
https://github.com/tstack/lnav.git
synced 2024-08-17 00:40:30 +03:00
[coverity] moare fixes
This commit is contained in:
parent
2117a12ded
commit
cccc72f3c1
@ -584,6 +584,9 @@ public:
|
||||
|
||||
void apply_hide();
|
||||
|
||||
attr_line_t move() & { return std::move(*this); }
|
||||
attr_line_t move() && { return std::move(*this); }
|
||||
|
||||
std::string al_string;
|
||||
string_attrs_t al_attrs;
|
||||
};
|
||||
|
@ -74,7 +74,7 @@ public:
|
||||
explicit future_queue(
|
||||
std::function<processor_result_t(std::future<T>&)> processor,
|
||||
size_t max_queue_size = 8)
|
||||
: fq_processor(processor), fq_max_queue_size(max_queue_size)
|
||||
: fq_processor(std::move(processor)), fq_max_queue_size(max_queue_size)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ protected:
|
||||
template<typename T>
|
||||
class service : public service_base {
|
||||
public:
|
||||
explicit service(std::string sub_name = "")
|
||||
explicit service(const std::string& sub_name = "")
|
||||
: service_base(std::string(__PRETTY_FUNCTION__) + " " + sub_name)
|
||||
{
|
||||
}
|
||||
@ -174,9 +174,11 @@ public:
|
||||
template<typename F>
|
||||
void send(F msg)
|
||||
{
|
||||
this->s_port.send({[lifetime = this->shared_from_this(), this, msg]() {
|
||||
msg(*(static_cast<T*>(this)));
|
||||
}});
|
||||
this->s_port.send({
|
||||
[lifetime = this->shared_from_this(),
|
||||
this,
|
||||
msg2 = std::move(msg)]() { msg2(*(static_cast<T*>(this))); },
|
||||
});
|
||||
}
|
||||
|
||||
template<typename F, class Rep, class Period>
|
||||
@ -185,12 +187,16 @@ public:
|
||||
{
|
||||
msg_port reply_port;
|
||||
|
||||
this->s_port.send(
|
||||
{[lifetime = this->shared_from_this(), this, &reply_port, msg]() {
|
||||
msg(*(static_cast<T*>(this)));
|
||||
this->s_port.send({
|
||||
[lifetime = this->shared_from_this(),
|
||||
this,
|
||||
&reply_port,
|
||||
msg2 = std::move(msg)]() {
|
||||
msg2(*(static_cast<T*>(this)));
|
||||
reply_port.send(empty_msg());
|
||||
}});
|
||||
reply_port.template process_for(rel_time);
|
||||
},
|
||||
});
|
||||
reply_port.process_for(rel_time);
|
||||
}
|
||||
};
|
||||
|
||||
@ -200,7 +206,7 @@ struct to {
|
||||
{
|
||||
auto& service = injector::get<T&, Service>();
|
||||
|
||||
service.send(cb);
|
||||
service.send(std::move(cb));
|
||||
}
|
||||
|
||||
template<class Rep, class Period>
|
||||
@ -209,14 +215,14 @@ struct to {
|
||||
{
|
||||
auto& service = injector::get<T&, Service>();
|
||||
|
||||
service.send_and_wait(cb, rel_time);
|
||||
service.send_and_wait(std::move(cb), rel_time);
|
||||
}
|
||||
|
||||
void send_and_wait(std::function<void(T)> cb)
|
||||
{
|
||||
using namespace std::literals::chrono_literals;
|
||||
|
||||
this->send_and_wait(cb, 48h);
|
||||
this->send_and_wait(std::move(cb), 48h);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -193,6 +193,9 @@ struct user_message {
|
||||
attr_line_t to_attr_line(std::set<render_flags> flags
|
||||
= {render_flags::prefix}) const;
|
||||
|
||||
user_message move() & { return std::move(*this); }
|
||||
user_message move() && { return std::move(*this); }
|
||||
|
||||
level um_level{level::ok};
|
||||
attr_line_t um_message;
|
||||
std::vector<snippet> um_snippets;
|
||||
|
@ -114,7 +114,7 @@ multiplex_matcher::match(const string_fragment& line)
|
||||
if (!md[df.dd_muxid_capture_index].has_value()) {
|
||||
log_info(" however, mux_id was not captured");
|
||||
|
||||
auto match_um = lnav::console::user_message::warning(
|
||||
const auto match_um = lnav::console::user_message::warning(
|
||||
attr_line_t("demuxer ")
|
||||
.append_quoted(demux_pair.first)
|
||||
.append(" matched, however the ")
|
||||
@ -125,7 +125,7 @@ multiplex_matcher::match(const string_fragment& line)
|
||||
}
|
||||
if (!md[df.dd_body_capture_index].has_value()) {
|
||||
log_info(" however, body was not captured");
|
||||
auto match_um = lnav::console::user_message::warning(
|
||||
const auto match_um = lnav::console::user_message::warning(
|
||||
attr_line_t("demuxer ")
|
||||
.append_quoted(demux_pair.first)
|
||||
.append(" matched, however the ")
|
||||
@ -146,10 +146,13 @@ multiplex_matcher::match(const string_fragment& line)
|
||||
this->mm_details.emplace_back(match_um);
|
||||
return found{demux_pair.first};
|
||||
}
|
||||
auto config_al = attr_line_t().append(
|
||||
fmt::format(FMT_STRING(":config /log/demux/{}/enabled "
|
||||
"true"),
|
||||
demux_pair.first));
|
||||
auto config_al
|
||||
= attr_line_t()
|
||||
.append(fmt::format(
|
||||
FMT_STRING(":config /log/demux/{}/enabled "
|
||||
"true"),
|
||||
demux_pair.first))
|
||||
.move();
|
||||
readline_lnav_highlighter(config_al, -1);
|
||||
auto match_um
|
||||
= lnav::console::user_message::info(
|
||||
@ -163,7 +166,8 @@ multiplex_matcher::match(const string_fragment& line)
|
||||
attr_line_t("Use ")
|
||||
.append_quoted(
|
||||
lnav::roles::quoted_code(config_al))
|
||||
.append(" to enable this demuxer"));
|
||||
.append(" to enable this demuxer"))
|
||||
.move();
|
||||
this->mm_details.emplace_back(match_um);
|
||||
}
|
||||
|
||||
@ -184,14 +188,16 @@ multiplex_matcher::match(const string_fragment& line)
|
||||
.append(lnav::roles::quoted_code(in_line))
|
||||
.append("\n")
|
||||
.append(partial_size + 2, ' ')
|
||||
.append("^ matched up to here");
|
||||
.append("^ matched up to here")
|
||||
.move();
|
||||
auto match_um = lnav::console::user_message::info(
|
||||
attr_line_t("demuxer ")
|
||||
.append_quoted(demux_pair.first)
|
||||
.append(" did not match line ")
|
||||
.append(lnav::roles::number(
|
||||
fmt::to_string(this->mm_line_count))))
|
||||
.with_note(note);
|
||||
.with_note(note)
|
||||
.move();
|
||||
this->mm_details.emplace_back(match_um);
|
||||
}
|
||||
if (df.dd_control_pattern.pp_value) {
|
||||
|
@ -100,7 +100,8 @@ field_overlay_source::build_field_lines(const listview_curses& lv,
|
||||
line_range{1, 2}, VC_GRAPHIC.value(ACS_LLCORNER)))
|
||||
.with_attr(string_attr(
|
||||
line_range{0, 22},
|
||||
VC_ROLE.value(role_t::VCR_INVALID_MSG)));
|
||||
VC_ROLE.value(role_t::VCR_INVALID_MSG)))
|
||||
.move();
|
||||
this->fos_lines.emplace_back(al);
|
||||
}
|
||||
}
|
||||
@ -419,7 +420,8 @@ field_overlay_source::build_field_lines(const listview_curses& lv,
|
||||
auto qname = lnav::sql::mprintf("%Q", extra_pair.first.c_str());
|
||||
auto key_line = attr_line_t(" jget(log_raw_text, ")
|
||||
.append(qname.in())
|
||||
.append(")");
|
||||
.append(")")
|
||||
.move();
|
||||
readline_sqlite_highlighter(key_line, std::nullopt);
|
||||
auto key_size = key_line.length();
|
||||
key_line.append(" = ").append(scrub_ws(extra_pair.second));
|
||||
@ -431,8 +433,10 @@ field_overlay_source::build_field_lines(const listview_curses& lv,
|
||||
const auto& jpairs = jpairs_map.second;
|
||||
|
||||
for (size_t lpc = 0; lpc < jpairs.size(); lpc++) {
|
||||
auto key_line = attr_line_t(" ").append(
|
||||
this->fos_log_helper.format_json_getter(jpairs_map.first, lpc));
|
||||
auto key_line = attr_line_t(" ")
|
||||
.append(this->fos_log_helper.format_json_getter(
|
||||
jpairs_map.first, lpc))
|
||||
.move();
|
||||
readline_sqlite_highlighter(key_line, std::nullopt);
|
||||
auto key_size = key_line.length();
|
||||
key_line.append(" = ").append(scrub_ws(jpairs[lpc].wt_value));
|
||||
@ -452,7 +456,7 @@ field_overlay_source::build_field_lines(const listview_curses& lv,
|
||||
xml_pair.first.second.c_str(),
|
||||
this->fos_log_helper.ldh_file->get_format()->get_name().c_str(),
|
||||
qname.in());
|
||||
auto key_line = attr_line_t(" ").append(xp_call.in());
|
||||
auto key_line = attr_line_t(" ").append(xp_call.in()).move();
|
||||
readline_sqlite_highlighter(key_line, std::nullopt);
|
||||
auto key_size = key_line.length();
|
||||
key_line.append(" = ").append(scrub_ws(xml_pair.second));
|
||||
@ -526,8 +530,8 @@ field_overlay_source::build_meta_line(const listview_curses& lv,
|
||||
.append(" to apply them")
|
||||
.append(lv.get_selection() == row ? " to this line"
|
||||
: "")
|
||||
.with_attr_for_all(
|
||||
VC_ROLE.value(role_t::VCR_COMMENT));
|
||||
.with_attr_for_all(VC_ROLE.value(role_t::VCR_COMMENT))
|
||||
.move();
|
||||
|
||||
dst.emplace_back(anno_msg);
|
||||
}
|
||||
@ -545,7 +549,8 @@ field_overlay_source::build_meta_line(const listview_curses& lv,
|
||||
if (!line_meta.bm_opid.empty()) {
|
||||
auto al = attr_line_t()
|
||||
.append(" Op ID: "_table_header)
|
||||
.append(lnav::roles::identifier(line_meta.bm_opid));
|
||||
.append(lnav::roles::identifier(line_meta.bm_opid))
|
||||
.move();
|
||||
|
||||
dst.emplace_back(al);
|
||||
}
|
||||
|
@ -221,7 +221,8 @@ handle_paging_key(int ch, const char* keyseq)
|
||||
|
||||
auto al = attr_line_t("mouse mode -- ")
|
||||
.append(mouse_i.is_enabled() ? "enabled"_symbol
|
||||
: "disabled"_symbol);
|
||||
: "disabled"_symbol)
|
||||
.move();
|
||||
if (mouse_i.is_enabled()
|
||||
&& lnav_config.lc_mouse_mode == lnav_mouse_mode::disabled)
|
||||
{
|
||||
|
@ -2992,7 +2992,8 @@ external_log_format::build(std::vector<lnav::console::user_message>& errors)
|
||||
auto sql_al = attr_line_t(hpair.second)
|
||||
.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("/{}/converter/header/expr/{}"),
|
||||
@ -3004,7 +3005,8 @@ external_log_format::build(std::vector<lnav::console::user_message>& errors)
|
||||
auto um = lnav::console::user_message::error(
|
||||
"SQL expression is invalid")
|
||||
.with_reason(sqlite3_errmsg(hexprs->e_db.in()))
|
||||
.with_snippet(snippet);
|
||||
.with_snippet(snippet)
|
||||
.move();
|
||||
|
||||
errors.emplace_back(um);
|
||||
continue;
|
||||
@ -3022,7 +3024,8 @@ external_log_format::build(std::vector<lnav::console::user_message>& errors)
|
||||
.with_help(
|
||||
"The converter command transforms the file "
|
||||
"into a format that can be consumed by lnav")
|
||||
.with_snippets(this->get_snippets());
|
||||
.with_snippets(this->get_snippets())
|
||||
.move();
|
||||
errors.emplace_back(um);
|
||||
}
|
||||
}
|
||||
@ -3069,7 +3072,8 @@ external_log_format::build(std::vector<lnav::console::user_message>& errors)
|
||||
= attr_line_t("the following captures are available:\n ")
|
||||
.join(available_captures,
|
||||
VC_ROLE.value(role_t::VCR_SYMBOL),
|
||||
", ");
|
||||
", ")
|
||||
.move();
|
||||
errors.emplace_back(
|
||||
lnav::console::user_message::warning(
|
||||
attr_line_t("invalid value ")
|
||||
@ -3298,7 +3302,8 @@ external_log_format::build(std::vector<lnav::console::user_message>& errors)
|
||||
attr_line_t("timestamp was not fully matched: ")
|
||||
.append_quoted(ts_cap.value()))
|
||||
.with_snippet(elf_sample.s_line.to_snippet())
|
||||
.with_note(notes);
|
||||
.with_note(notes)
|
||||
.move();
|
||||
|
||||
errors.emplace_back(um);
|
||||
}
|
||||
@ -3439,7 +3444,8 @@ external_log_format::build(std::vector<lnav::console::user_message>& errors)
|
||||
.append_quoted(lnav::roles::symbol(
|
||||
level_names[elf_sample.s_level])))
|
||||
.with_snippet(elf_sample.s_line.to_snippet())
|
||||
.with_note(note_al);
|
||||
.with_note(note_al)
|
||||
.move();
|
||||
if (!this->elf_level_patterns.empty()) {
|
||||
um.with_help(
|
||||
attr_line_t("Level regexes are not anchored to the "
|
||||
|
@ -2544,7 +2544,8 @@ logfile_sub_source::text_crumbs_for_line(int line,
|
||||
auto key = text_anchors::to_anchor_string(name);
|
||||
auto display = attr_line_t()
|
||||
.append("\u2291 "_symbol)
|
||||
.append(lnav::roles::variable(name));
|
||||
.append(lnav::roles::variable(name))
|
||||
.move();
|
||||
crumbs.emplace_back(
|
||||
key,
|
||||
display,
|
||||
|
@ -87,17 +87,14 @@ struct is_nullable<nullable<T>> : std::true_type {};
|
||||
|
||||
template<typename T>
|
||||
struct from_sqlite {
|
||||
using U = typename std::remove_reference<T>::type;
|
||||
using U = std::remove_reference_t<T>;
|
||||
|
||||
inline U operator()(int argc, sqlite3_value** val, int argi)
|
||||
{
|
||||
return U();
|
||||
};
|
||||
U operator()(int argc, sqlite3_value** val, int argi) { return U(); }
|
||||
};
|
||||
|
||||
template<>
|
||||
struct from_sqlite<bool> {
|
||||
inline bool operator()(int argc, sqlite3_value** val, int argi)
|
||||
bool operator()(int argc, sqlite3_value** val, int argi)
|
||||
{
|
||||
if (sqlite3_value_numeric_type(val[argi]) != SQLITE_INTEGER) {
|
||||
throw from_sqlite_conversion_error("integer", argi);
|
||||
@ -109,7 +106,7 @@ struct from_sqlite<bool> {
|
||||
|
||||
template<>
|
||||
struct from_sqlite<int64_t> {
|
||||
inline int64_t operator()(int argc, sqlite3_value** val, int argi)
|
||||
int64_t operator()(int argc, sqlite3_value** val, int argi)
|
||||
{
|
||||
if (sqlite3_value_numeric_type(val[argi]) != SQLITE_INTEGER) {
|
||||
throw from_sqlite_conversion_error("integer", argi);
|
||||
@ -121,7 +118,7 @@ struct from_sqlite<int64_t> {
|
||||
|
||||
template<>
|
||||
struct from_sqlite<sqlite3_value*> {
|
||||
inline sqlite3_value* operator()(int argc, sqlite3_value** val, int argi)
|
||||
sqlite3_value* operator()(int argc, sqlite3_value** val, int argi)
|
||||
{
|
||||
return val[argi];
|
||||
}
|
||||
@ -129,7 +126,7 @@ struct from_sqlite<sqlite3_value*> {
|
||||
|
||||
template<>
|
||||
struct from_sqlite<int> {
|
||||
inline int operator()(int argc, sqlite3_value** val, int argi)
|
||||
int operator()(int argc, sqlite3_value** val, int argi)
|
||||
{
|
||||
if (sqlite3_value_numeric_type(val[argi]) != SQLITE_INTEGER) {
|
||||
throw from_sqlite_conversion_error("integer", argi);
|
||||
@ -141,7 +138,7 @@ struct from_sqlite<int> {
|
||||
|
||||
template<>
|
||||
struct from_sqlite<const char*> {
|
||||
inline const char* operator()(int argc, sqlite3_value** val, int argi)
|
||||
const char* operator()(int argc, sqlite3_value** val, int argi)
|
||||
{
|
||||
return (const char*) sqlite3_value_text(val[argi]);
|
||||
}
|
||||
@ -149,9 +146,9 @@ struct from_sqlite<const char*> {
|
||||
|
||||
template<>
|
||||
struct from_sqlite<string_fragment> {
|
||||
inline string_fragment operator()(int argc, sqlite3_value** val, int argi)
|
||||
string_fragment operator()(int argc, sqlite3_value** val, int argi)
|
||||
{
|
||||
auto ptr = (const char*) sqlite3_value_blob(val[argi]);
|
||||
const auto ptr = (const char*) sqlite3_value_blob(val[argi]);
|
||||
|
||||
if (ptr == nullptr) {
|
||||
return string_fragment::invalid();
|
||||
@ -162,7 +159,7 @@ struct from_sqlite<string_fragment> {
|
||||
|
||||
template<>
|
||||
struct from_sqlite<std::string> {
|
||||
inline std::string operator()(int argc, sqlite3_value** val, int argi)
|
||||
std::string operator()(int argc, sqlite3_value** val, int argi)
|
||||
{
|
||||
return {
|
||||
(const char*) sqlite3_value_blob(val[argi]),
|
||||
@ -173,7 +170,7 @@ struct from_sqlite<std::string> {
|
||||
|
||||
template<>
|
||||
struct from_sqlite<double> {
|
||||
inline double operator()(int argc, sqlite3_value** val, int argi)
|
||||
double operator()(int argc, sqlite3_value** val, int argi)
|
||||
{
|
||||
return sqlite3_value_double(val[argi]);
|
||||
}
|
||||
@ -181,9 +178,7 @@ struct from_sqlite<double> {
|
||||
|
||||
template<typename T>
|
||||
struct from_sqlite<std::optional<T>> {
|
||||
inline std::optional<T> operator()(int argc,
|
||||
sqlite3_value** val,
|
||||
int argi)
|
||||
std::optional<T> operator()(int argc, sqlite3_value** val, int argi)
|
||||
{
|
||||
if (argi >= argc || sqlite3_value_type(val[argi]) == SQLITE_NULL) {
|
||||
return std::nullopt;
|
||||
@ -195,7 +190,7 @@ struct from_sqlite<std::optional<T>> {
|
||||
|
||||
template<typename T>
|
||||
struct from_sqlite<const std::vector<T>&> {
|
||||
inline std::vector<T> operator()(int argc, sqlite3_value** val, int argi)
|
||||
std::vector<T> operator()(int argc, sqlite3_value** val, int argi)
|
||||
{
|
||||
std::vector<T> retval;
|
||||
|
||||
@ -209,9 +204,7 @@ struct from_sqlite<const std::vector<T>&> {
|
||||
|
||||
template<typename T>
|
||||
struct from_sqlite<vtab_types::nullable<T>> {
|
||||
inline vtab_types::nullable<T> operator()(int argc,
|
||||
sqlite3_value** val,
|
||||
int argi)
|
||||
vtab_types::nullable<T> operator()(int argc, sqlite3_value** val, int argi)
|
||||
{
|
||||
return {from_sqlite<T*>()(argc, val, argi)};
|
||||
}
|
||||
@ -276,12 +269,12 @@ to_sqlite(sqlite3_context* ctx, bool val)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void
|
||||
to_sqlite(sqlite3_context* ctx,
|
||||
T val,
|
||||
typename std::enable_if<std::is_integral<T>::value
|
||||
&& !std::is_same<T, bool>::value>::type* dummy
|
||||
= 0)
|
||||
void
|
||||
to_sqlite(
|
||||
sqlite3_context* ctx,
|
||||
T val,
|
||||
std::enable_if_t<std::is_integral_v<T> && !std::is_same_v<T, bool>>* dummy
|
||||
= 0)
|
||||
{
|
||||
sqlite3_result_int64(ctx, val);
|
||||
}
|
||||
@ -295,7 +288,7 @@ to_sqlite(sqlite3_context* ctx, double val)
|
||||
inline void
|
||||
to_sqlite(sqlite3_context* ctx, auto_mem<char> str)
|
||||
{
|
||||
auto free_func = str.get_free_func<void (*)(void*)>();
|
||||
const auto free_func = str.get_free_func<void (*)(void*)>();
|
||||
sqlite3_result_text(ctx, str.release(), -1, free_func);
|
||||
}
|
||||
|
||||
@ -303,7 +296,7 @@ to_sqlite(sqlite3_context* ctx, auto_mem<char> str)
|
||||
#define FLATTEN_SUBTYPE 0x5f
|
||||
|
||||
template<typename T>
|
||||
inline void
|
||||
void
|
||||
to_sqlite(sqlite3_context* ctx, std::optional<T>& val)
|
||||
{
|
||||
if (val.has_value()) {
|
||||
@ -314,7 +307,7 @@ to_sqlite(sqlite3_context* ctx, std::optional<T>& val)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void
|
||||
void
|
||||
to_sqlite(sqlite3_context* ctx, std::optional<T> val)
|
||||
{
|
||||
if (val.has_value()) {
|
||||
@ -469,12 +462,14 @@ struct sqlite_func_adapter<Return (*)(Args...), f> {
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t lpc = 0; lpc < REQ_COUNT; lpc++) {
|
||||
if (!IS_NULLABLE[lpc] && !IS_SQLITE3_VALUE[lpc]
|
||||
&& sqlite3_value_type(argv[lpc]) == SQLITE_NULL)
|
||||
{
|
||||
sqlite3_result_null(context);
|
||||
return;
|
||||
if constexpr (REQ_COUNT > 0) {
|
||||
for (size_t lpc = 0; lpc < REQ_COUNT; lpc++) {
|
||||
if (!IS_NULLABLE[lpc] && !IS_SQLITE3_VALUE[lpc]
|
||||
&& sqlite3_value_type(argv[lpc]) == SQLITE_NULL)
|
||||
{
|
||||
sqlite3_result_null(context);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user