[lint] fix some coverity/clang-tidy issues

This commit is contained in:
Tim Stack 2022-10-05 12:28:29 -07:00
parent faeaf477ab
commit 057be8c66d
11 changed files with 32 additions and 30 deletions

View File

@ -87,6 +87,7 @@ uncompress(const std::string& src, const void* buffer, size_t size)
int err;
strm.next_in = (Bytef*) buffer;
strm.msg = Z_NULL;
strm.avail_in = size;
strm.total_in = 0;
strm.total_out = 0;

View File

@ -37,7 +37,7 @@ namespace snippets {
void regex_highlighter(attr_line_t& al, int x, line_range sub);
}
} // namespace snippets
} // namespace lnav
#endif

View File

@ -116,13 +116,12 @@ filter_status_source::statusview_fields()
role_t::VCR_STATUS_STITCH_NORMAL_TO_TITLE);
this->tss_fields[TSF_TITLE].set_value(" " ANSI_ROLE("T") "ext Filters ",
role_t::VCR_STATUS_HOTKEY);
this->tss_fields[TSF_TITLE].set_role(
role_t::VCR_STATUS_DISABLED_TITLE);
this->tss_fields[TSF_STITCH_TITLE].set_stitch_value(
role_t::VCR_STATUS, role_t::VCR_STATUS);
this->tss_fields[TSF_TITLE].set_role(role_t::VCR_STATUS_DISABLED_TITLE);
this->tss_fields[TSF_STITCH_TITLE].set_stitch_value(role_t::VCR_STATUS,
role_t::VCR_STATUS);
} else {
this->tss_fields[TSF_FILES_TITLE].set_value(
" " ANSI_ROLE("F") "iles ", role_t::VCR_STATUS_HOTKEY);
this->tss_fields[TSF_FILES_TITLE].set_value(" " ANSI_ROLE("F") "iles ",
role_t::VCR_STATUS_HOTKEY);
if (lnav_data.ld_active_files.fc_name_to_errors.empty()) {
this->tss_fields[TSF_FILES_TITLE].set_role(
role_t::VCR_STATUS_DISABLED_TITLE);
@ -142,9 +141,8 @@ filter_status_source::statusview_fields()
this->tss_fields[TSF_FILES_RIGHT_STITCH].set_stitch_value(
role_t::VCR_STATUS_STITCH_NORMAL_TO_TITLE,
role_t::VCR_STATUS_STITCH_TITLE_TO_NORMAL);
this->tss_fields[TSF_TITLE].set_value(
" " ANSI_ROLE("T") "ext Filters ",
role_t::VCR_STATUS_TITLE_HOTKEY);
this->tss_fields[TSF_TITLE].set_value(" " ANSI_ROLE("T") "ext Filters ",
role_t::VCR_STATUS_TITLE_HOTKEY);
this->tss_fields[TSF_TITLE].set_role(role_t::VCR_STATUS_TITLE);
this->tss_fields[TSF_STITCH_TITLE].set_stitch_value(
role_t::VCR_STATUS_STITCH_TITLE_TO_NORMAL,
@ -194,9 +192,13 @@ filter_status_source::statusview_value_for_field(int field)
void
filter_status_source::update_filtered(text_sub_source* tss)
{
status_field& sf = this->tss_fields[TSF_FILTERED];
if (tss == nullptr) {
return;
}
if (tss == nullptr || tss->get_filtered_count() == 0) {
auto& sf = this->tss_fields[TSF_FILTERED];
if (tss->get_filtered_count() == 0) {
if (tss->tss_apply_filters) {
sf.clear();
} else {
@ -205,8 +207,8 @@ filter_status_source::update_filtered(text_sub_source* tss)
":toggle-filtering" ANSI_NORM);
}
} else {
ui_periodic_timer& timer = ui_periodic_timer::singleton();
attr_line_t& al = sf.get_value();
auto& timer = ui_periodic_timer::singleton();
auto& al = sf.get_value();
if (tss->get_filtered_count() == this->bss_last_filtered_count) {
if (timer.fade_diff(this->bss_filter_counter) == 0) {
@ -215,8 +217,7 @@ filter_status_source::update_filtered(text_sub_source* tss)
VC_STYLE.value(text_attrs{A_BOLD})));
}
} else {
this->tss_fields[TSF_FILTERED].set_role(
role_t::VCR_ALERT_STATUS);
this->tss_fields[TSF_FILTERED].set_role(role_t::VCR_ALERT_STATUS);
this->bss_last_filtered_count = tss->get_filtered_count();
timer.start_fade(this->bss_filter_counter, 3);
}
@ -286,7 +287,8 @@ filter_help_status_source::statusview_fields()
: "Enable Filtering");
}
} else if (lnav_data.ld_mode == ln_mode_t::FILES
&& lnav_data.ld_session_loaded) {
&& lnav_data.ld_session_loaded)
{
auto& lv = lnav_data.ld_files_view;
auto sel = files_model::from_selection(lv.get_selection());

View File

@ -164,10 +164,10 @@ combined_user_marks(vis_bookmarks& vb)
const auto& bv_expr = vb[&textview_curses::BM_USER_EXPR];
bookmark_vector<vis_line_t> retval;
for (const auto row : bv) {
for (const auto& row : bv) {
retval.insert_once(row);
}
for (const auto row : bv_expr) {
for (const auto& row : bv_expr) {
retval.insert_once(row);
}
return retval;

View File

@ -1199,7 +1199,7 @@ log_cursor::string_constraint::string_constraint(unsigned char op,
: sc_op(op), sc_value(std::move(value))
{
if (op == SQLITE_INDEX_CONSTRAINT_REGEXP) {
auto compile_res = lnav::pcre2pp::code::from(value);
auto compile_res = lnav::pcre2pp::code::from(this->sc_value);
if (compile_res.isErr()) {
auto ce = compile_res.unwrapErr();

View File

@ -427,7 +427,7 @@ add_config_possibilities()
if (named_caps.empty()) {
rc->add_possibility(ln_mode_t::COMMAND, "config-option", path);
}
for (const auto named_cap : named_caps) {
for (const auto& named_cap : named_caps) {
if (visited.count(named_cap.get_name().to_string()) == 0) {
rc->clear_possibilities(ln_mode_t::COMMAND,
named_cap.get_name().to_string());

View File

@ -106,7 +106,7 @@ CREATE TABLE regexp_capture (
this->c_match_index += 1;
}
if (this->c_pattern == nullptr || !this->c_matched) {
if (!this->c_matched) {
return SQLITE_OK;
}
@ -329,7 +329,7 @@ CREATE TABLE regexp_capture_into_json (
this->c_matched = match_res.has_value();
this->c_match_index += 1;
if (this->c_pattern == nullptr || !this->c_matched) {
if (!this->c_matched) {
return SQLITE_OK;
}

View File

@ -150,7 +150,7 @@ public:
if (this->rt_previous) {
return true;
}
for (auto rtf : this->rt_field) {
for (const auto& rtf : this->rt_field) {
if (rtf.value < 0) {
return true;
}
@ -179,7 +179,7 @@ public:
if (!this->rt_included_days.empty()) {
return false;
}
for (auto rtf : this->rt_field) {
for (const auto& rtf : this->rt_field) {
if (rtf.is_set) {
return false;
}

View File

@ -50,7 +50,7 @@ unique_path_generator::generate()
while (!this->upg_unique_paths.empty()) {
std::vector<std::shared_ptr<unique_path_source>> collisions;
for (auto pair : this->upg_unique_paths) {
for (const auto& pair : this->upg_unique_paths) {
if (pair.second.size() == 1) {
if (loop_count > 0) {
std::shared_ptr<unique_path_source> src = pair.second[0];

View File

@ -127,10 +127,8 @@ handle_map_key(void* ctx, const unsigned char* key, size_t len)
} else {
auto fully_encoded_key = (char*) alloca(required_len);
json_ptr::encode(fully_encoded_key,
sizeof(fully_encoded_key),
(const char*) key,
len);
json_ptr::encode(
fully_encoded_key, required_len, (const char*) key, len);
jpw->jpw_keys.emplace_back(&fully_encoded_key[0], required_len);
}

View File

@ -1382,6 +1382,7 @@ pattern_property_handler(const T (&path)[N])
{
return {lnav::pcre2pp::code::from_const(path).to_shared()};
}
} // namespace yajlpp
#endif