[tidy] some more tidying

This commit is contained in:
Timothy Stack 2022-04-03 22:10:20 -07:00
parent 99c1688c2e
commit 531c35158c
5 changed files with 40 additions and 25 deletions

View File

@ -1,18 +1,24 @@
--- ---
# Enable ALL the things! Except not really # Enable ALL the things! Except not really
# misc-non-private-member-variables-in-classes: the options don't do anything # misc-non-private-member-variables-in-classes: the options don't do anything
Checks: "*,\ Checks: >
-google-readability-todo,\ *,
-altera-unroll-loops,\ -google-readability-todo,
-altera-id-dependent-backward-branch,\ -altera-unroll-loops,
-altera-struct-pack-align,\ -altera-id-dependent-backward-branch,
-fuchsia-*,\ -altera-struct-pack-align,
fuchsia-multiple-inheritance,\ -fuchsia-*,
-llvm-header-guard,\ fuchsia-multiple-inheritance,
-llvm-include-order,\ -llvm-header-guard,
-llvmlibc-*,\ -llvm-include-order,
-modernize-use-trailing-return-type,\ -llvmlibc-*,
-misc-non-private-member-variables-in-classes" -modernize-use-trailing-return-type,
-misc-non-private-member-variables-in-classes,
-cppcoreguidelines-pro-type-vararg,
-hicpp-vararg,
-cppcoreguidelines-avoid-c-arrays,
-hicpp-avoid-c-arrays,
-modernize-avoid-c-arrays
WarningsAsErrors: '' WarningsAsErrors: ''
CheckOptions: CheckOptions:
- key: 'bugprone-argument-comment.StrictMode' - key: 'bugprone-argument-comment.StrictMode'

View File

@ -169,7 +169,8 @@ template<typename T>
struct string_attr_wrapper { struct string_attr_wrapper {
explicit string_attr_wrapper(const string_attr* sa) : saw_string_attr(sa) {} explicit string_attr_wrapper(const string_attr* sa) : saw_string_attr(sa) {}
const T& get() const template<typename U = T>
std::enable_if_t<!std::is_void<U>::value, const U&> get() const
{ {
return this->saw_string_attr->sa_value.template get<T>(); return this->saw_string_attr->sa_value.template get<T>();
} }

View File

@ -95,7 +95,7 @@ public:
false); false);
}; };
std::string to_string(const struct line_range& lr) std::string to_string(const struct line_range& lr) const
{ {
const char* start = this->lh_msg_buffer.get_data(); const char* start = this->lh_msg_buffer.get_data();

View File

@ -1464,12 +1464,18 @@ logfile_sub_source::eval_sql_filter(sqlite3_stmt* stmt,
continue; continue;
} }
if (strcmp(name, ":log_body") == 0) { if (strcmp(name, ":log_body") == 0) {
auto iter = find_string_attr(sa, &SA_BODY); auto body_attr_opt = get_string_attr(sa, SA_BODY);
sqlite3_bind_text(stmt, if (body_attr_opt) {
lpc + 1, auto& sar = body_attr_opt.value().saw_string_attr->sa_range;
&(sbr.get_data()[iter->sa_range.lr_start]),
iter->sa_range.length(), sqlite3_bind_text(stmt,
SQLITE_STATIC); lpc + 1,
sbr.get_data_at(sar.lr_start),
sar.length(),
SQLITE_STATIC);
} else {
sqlite3_bind_null(stmt, lpc + 1);
}
continue; continue;
} }
if (strcmp(name, ":log_raw_text") == 0) { if (strcmp(name, ":log_raw_text") == 0) {
@ -1485,7 +1491,7 @@ logfile_sub_source::eval_sql_filter(sqlite3_stmt* stmt,
} }
continue; continue;
} }
for (auto& lv : values) { for (const auto& lv : values) {
if (lv.lv_meta.lvm_name != &name[1]) { if (lv.lv_meta.lvm_name != &name[1]) {
continue; continue;
} }

View File

@ -43,12 +43,14 @@ static const char* GOOD_TIMES[] = {
"05/18/2018 12:00:53 AM", "05/18/2018 12:00:53 AM",
}; };
static const char* BAD_TIMES[] = {"1-2-3 1:2:3", static const char* BAD_TIMES[] = {
"1-2-3 1:2:3",
"2013-22-01 12:01:22", "2013-22-01 12:01:22",
"2013-00-01 12:01:22", "2013-00-01 12:01:22",
"@4000000043"}; "@4000000043",
};
int int
main(int argc, char* argv[]) main(int argc, char* argv[])