Skip to content

Commit

Permalink
Merge pull request #32 from jtxa/clang-tidy-fixes-step1
Browse files Browse the repository at this point in the history
Clang tidy fixes step 1
  • Loading branch information
sierrafoxtrot authored Jan 22, 2023
2 parents cf963da + a18500b commit 66914e1
Show file tree
Hide file tree
Showing 201 changed files with 673 additions and 609 deletions.
58 changes: 55 additions & 3 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -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: "*"
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ language: "en-GB"
ignorePaths:
# Configuration files and dictionaries
- /.git
- .clang-tidy
- .gitignore
- .mega-linter.yml
- .vscode
Expand Down Expand Up @@ -182,6 +183,7 @@ words:
- globbing
- gsub
- gumph
- howto
- htdocs
- ifndef
- incl
Expand Down Expand Up @@ -222,6 +224,7 @@ words:
- PDFEXE
- pirlen
- productbuild
- progname
- psselect
- radixes
- readmemh
Expand Down
10 changes: 5 additions & 5 deletions srec_info/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ 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;

//
// 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)
Expand Down Expand Up @@ -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<uint32_t>(hi - 1U);
const auto hi_address = static_cast<uint32_t>(hi - 1U);
std::cout
<< std::setw(prec) << lo
<< " - "
<< std::setw(prec) << hi_address;
const uint32_t interval_size = static_cast<uint32_t>(hi - lo);
const auto interval_size = static_cast<uint32_t>(hi - lo);
if(verbose)
{
std::cout << " (" << std::setw(prec) << interval_size<< ")";
Expand All @@ -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<uint32_t>(range_highest - range_lowest);
const double real_number_bytes
= (number_bytes == 0UL) ? 4294967296.0 : number_bytes;
Expand Down
1 change: 1 addition & 0 deletions srecord/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion srecord/adler16.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion srecord/adler32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
36 changes: 18 additions & 18 deletions srecord/arglex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

#include <cassert>
#include <cctype>
#include <cstring>
#include <cerrno>
#include <cstdio>
#include <cstdlib>
#include <errno.h>
#include <cstring>
#include <iostream>
#include <unistd.h>

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
);
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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());
}
}
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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;
Expand All @@ -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
)
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -676,7 +676,7 @@ srecord::arglex::help(const char *name)


void
srecord::arglex::version(void)
srecord::arglex::version()
const
{
print_version();
Expand All @@ -685,15 +685,15 @@ srecord::arglex::version(void)


void
srecord::arglex::license(void)
srecord::arglex::license()
const
{
help("srec_license");
}


void
srecord::arglex::bad_argument(void)
srecord::arglex::bad_argument()
const
{
switch (token_cur())
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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_)
Expand All @@ -780,7 +780,7 @@ srecord::arglex::usage_tail_get(void)


void
srecord::arglex::usage(void)
srecord::arglex::usage()
const
{
std::cerr << "Usage: " << progname_get() << " [ <option>... ] "
Expand All @@ -794,7 +794,7 @@ srecord::arglex::usage(void)


void
srecord::arglex::default_command_line_processing(void)
srecord::arglex::default_command_line_processing()
{
bad_argument();
}
Expand Down
Loading

0 comments on commit 66914e1

Please sign in to comment.