diff --git a/.clang-tidy b/.clang-tidy index d43d665c..fd998f0d 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,12 +1,64 @@ --- +# Enable relevant check categories first. +# Disable single checks not desired. +# Temporarily at the end (after the single comma): +# Disable those checks that have not been discussed/fixed yet. Checks: >- - -*, - abseil-*, - portability-*, + bugprone-*, + cert-*, + clang-analyzer-*, + -clang-analyzer-osx.*, + concurrency-*, misc-*, + modernize-*, + performance-*, + portability-*, + readability-*, + -modernize-use-trailing-return-type, + -modernize-use-using, + -modernize-pass-by-value, + , + -bugprone-branch-clone, + -bugprone-easily-swappable-parameters, + -bugprone-implicit-widening-of-multiplication-result, + -bugprone-misplaced-widening-cast, + -bugprone-narrowing-conversions, + -cert-dcl50-cpp, + -cert-err33-c, + -cert-err58-cpp, + -cert-msc30-c, + -cert-msc50-cpp, + -cert-oop54-cpp, + -clang-analyzer-core.CallAndMessage, + -clang-analyzer-core.DivideZero, + -clang-analyzer-core.UndefinedBinaryOperatorResult, + -clang-analyzer-cplusplus.NewDeleteLeaks, + -clang-analyzer-deadcode.DeadStores, + -clang-analyzer-optin.cplusplus.VirtualCall, + -concurrency-mt-unsafe, -misc-no-recursion, -misc-non-private-member-variables-in-classes, -misc-redundant-expression, + -modernize-avoid-c-arrays, + -modernize-loop-convert, + -modernize-use-default-member-init, + -modernize-use-equals-default, + -modernize-use-equals-delete, + -modernize-use-nullptr, + -modernize-use-override, + -performance-unnecessary-copy-initialization, + -performance-unnecessary-value-param, + -readability-braces-around-statements, + -readability-convert-member-functions-to-static, + -readability-else-after-return, + -readability-function-cognitive-complexity, + -readability-identifier-length, + -readability-implicit-bool-conversion, + -readability-inconsistent-declaration-parameter-name, + -readability-magic-numbers, + -readability-named-parameter, + -readability-redundant-member-init, + -readability-redundant-string-init, # All enabled checks shall be reported as error. WarningsAsErrors: "*" diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 88fd8acf..f2a91ef8 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -20,6 +20,9 @@ jobs: - clang-14 steps: + - name: Update system + run: sudo apt-get update + - name: Install prerequisites run: >- sudo apt-get install -y diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml index 40e49758..280fd77c 100644 --- a/.github/workflows/qa.yml +++ b/.github/workflows/qa.yml @@ -8,6 +8,9 @@ jobs: runs-on: ubuntu-22.04 steps: + - name: Update system + run: sudo apt-get update + - name: Install prerequisites run: >- sudo apt-get install -y @@ -54,13 +57,16 @@ jobs: - name: clang-tidy if: always() - run: run-clang-tidy-14 -p build + run: run-clang-tidy-14 -p build -header-filter=.* build-gcc: name: Check source with gcc runs-on: ubuntu-22.04 steps: + - name: Update system + run: sudo apt-get update + - name: Install prerequisites run: >- sudo apt-get install -y @@ -110,6 +116,9 @@ jobs: runs-on: ubuntu-22.04 steps: + - name: Update system + run: sudo apt-get update + - name: Install prerequisites run: >- sudo apt-get install -y diff --git a/cspell.config.yaml b/cspell.config.yaml index b95f1684..cac07d34 100644 --- a/cspell.config.yaml +++ b/cspell.config.yaml @@ -10,6 +10,7 @@ language: "en-GB" ignorePaths: # Configuration files and dictionaries - /.git + - .clang-tidy - .gitignore - .mega-linter.yml - .vscode @@ -182,6 +183,7 @@ words: - globbing - gsub - gumph + - howto - htdocs - ifndef - incl @@ -222,6 +224,7 @@ words: - PDFEXE - pirlen - productbuild + - progname - psselect - radixes - readmemh diff --git a/srec_info/main.cc b/srec_info/main.cc index a7db7279..51a9939a 100644 --- a/srec_info/main.cc +++ b/srec_info/main.cc @@ -62,7 +62,7 @@ main(int argc, char **argv) } cmdline.token_next(); } - if (infile.size() == 0U) + if (infile.empty()) infile.push_back(cmdline.get_input()); std::cout << std::hex << std::uppercase; @@ -70,7 +70,7 @@ main(int argc, char **argv) // // Read each file and emit informative gumph. // - for (infile_t::iterator it = infile.begin(); it != infile.end(); ++it) + for (auto it = infile.begin(); it != infile.end(); ++it) { srecord::input::pointer ifp = *it; if (infile.size() > 1U) @@ -157,12 +157,12 @@ main(int argc, char **argv) } const uint32_t lo = tmp.get_lowest(); const uint32_t hi = tmp.get_highest(); - const uint32_t hi_address = static_cast(hi - 1U); + const auto hi_address = static_cast(hi - 1U); std::cout << std::setw(prec) << lo << " - " << std::setw(prec) << hi_address; - const uint32_t interval_size = static_cast(hi - lo); + const auto interval_size = static_cast(hi - lo); if(verbose) { std::cout << " (" << std::setw(prec) << interval_size<< ")"; @@ -184,7 +184,7 @@ main(int argc, char **argv) std::cout << std::setw(prec) << number_bytes; std::cout << std::endl; - const uint32_t range_size + const auto range_size = static_cast(range_highest - range_lowest); const double real_number_bytes = (number_bytes == 0UL) ? 4294967296.0 : number_bytes; diff --git a/srecord/CMakeLists.txt b/srecord/CMakeLists.txt index 01b9876f..f8c1aae7 100644 --- a/srecord/CMakeLists.txt +++ b/srecord/CMakeLists.txt @@ -22,6 +22,7 @@ file(GLOB_RECURSE LIB_SRECORD_HDR "*.h") message(STATUS "gcrypt location ${LIB_GCRYPT}") add_library(lib_srecord STATIC ${LIB_SRECORD_SRC} ${LIB_SRECORD_HDR} ${LIB_GCRYPT}) +target_compile_features(lib_srecord PUBLIC cxx_std_11) # Install the library install(TARGETS lib_srecord diff --git a/srecord/adler16.cc b/srecord/adler16.cc index fab1f558..0b81b3d8 100644 --- a/srecord/adler16.cc +++ b/srecord/adler16.cc @@ -70,7 +70,7 @@ srecord::adler16::next(unsigned char c) void srecord::adler16::nextbuf(const void *data, size_t nbytes) { - const unsigned char *dp = (const unsigned char *)data; + const auto *dp = (const unsigned char *)data; while (nbytes > 0) { next(*dp); diff --git a/srecord/adler32.cc b/srecord/adler32.cc index 54edab57..45f2500b 100644 --- a/srecord/adler32.cc +++ b/srecord/adler32.cc @@ -70,7 +70,7 @@ srecord::adler32::next(unsigned char c) void srecord::adler32::nextbuf(const void *data, size_t nbytes) { - const unsigned char *dp = (const unsigned char *)data; + const auto *dp = (const unsigned char *)data; while (nbytes > 0) { next(*dp); diff --git a/srecord/arglex.cc b/srecord/arglex.cc index 66320e32..34882297 100644 --- a/srecord/arglex.cc +++ b/srecord/arglex.cc @@ -18,10 +18,10 @@ #include #include -#include +#include #include #include -#include +#include #include #include @@ -65,7 +65,7 @@ srecord::arglex::arglex(int ac, char **av) : if (av[j][0] == '@') read_arguments_file(av[j] + 1); else - arguments.push_back(av[j]); + arguments.emplace_back(av[j]); } table_set(default_table); } @@ -125,7 +125,7 @@ srecord::arglex::read_arguments_file(const char *filename) if (buffer[0] == '@') read_arguments_file(buffer + 1); else - arguments.push_back(std::string(buffer, bp - buffer)); + arguments.emplace_back(buffer, bp - buffer); } fclose(fp); } @@ -391,7 +391,7 @@ deprecated_warning(const char *deprecated_name, const char *preferred_name) { srecord::quit_default.warning ( - "option \"%s\" is deprecated, please use \"%s\" instead", + R"(option "%s" is deprecated, please use "%s" instead)", deprecated_name, preferred_name ); @@ -422,7 +422,7 @@ deprecated_warning(const char *deprecated_name, const char *preferred_name) // int -srecord::arglex::token_next(void) +srecord::arglex::token_next() { const table_ty *tp; const table_ty *hit[20]; @@ -458,7 +458,7 @@ srecord::arglex::token_next(void) const char *eqp = strchr(arg.c_str(), '='); if (eqp) { - pushback.push_back(eqp + 1); + pushback.emplace_back(eqp + 1); arg = std::string(arg.c_str(), eqp - arg.c_str()); } } @@ -497,7 +497,7 @@ srecord::arglex::token_next(void) partial = 0; for ( - table_ptr_vec_t::iterator it = tables.begin(); + auto it = tables.begin(); it != tables.end(); ++it ) @@ -582,7 +582,7 @@ srecord::arglex::token_next(void) case 1: if (partial) { - pushback.push_back(partial); + pushback.emplace_back(partial); partial = 0; } value_string_ = hit[0]->name; @@ -607,7 +607,7 @@ srecord::arglex::check_deprecated(const std::string &actual) { for ( - deprecated_options_t::const_iterator it = deprecated_options.begin(); + auto it = deprecated_options.begin(); it != deprecated_options.end(); ++it ) @@ -647,7 +647,7 @@ srecord::arglex::token_name(int n) } for ( - table_ptr_vec_t::const_iterator it = tables.begin(); + auto it = tables.begin(); it != tables.end(); ++it ) @@ -676,7 +676,7 @@ srecord::arglex::help(const char *name) void -srecord::arglex::version(void) +srecord::arglex::version() const { print_version(); @@ -685,7 +685,7 @@ srecord::arglex::version(void) void -srecord::arglex::license(void) +srecord::arglex::license() const { help("srec_license"); @@ -693,7 +693,7 @@ srecord::arglex::license(void) void -srecord::arglex::bad_argument(void) +srecord::arglex::bad_argument() const { switch (token_cur()) @@ -727,7 +727,7 @@ srecord::arglex::bad_argument(void) int -srecord::arglex::token_first(void) +srecord::arglex::token_first() { #if 1 // We probably don't need to do this all the time. @@ -770,7 +770,7 @@ srecord::arglex::usage_tail_set(const char *s) const char * -srecord::arglex::usage_tail_get(void) +srecord::arglex::usage_tail_get() const { if (!usage_tail_) @@ -780,7 +780,7 @@ srecord::arglex::usage_tail_get(void) void -srecord::arglex::usage(void) +srecord::arglex::usage() const { std::cerr << "Usage: " << progname_get() << " [