Skip to content

Atomic lint evp

hgratten requested to merge atomic_lint_evp into master

this merge request introduces the clang-tidied eigen value problem (Evp) chapter

LectureCodes/Evp/*

  • removed cmake_minimum_required(VERSION 2.8), since the cmake version is better handled by the global CMakeLists.txt file
  • excluded check concurrency-mt-unsafe locally: dirname is multi-threading-unsafe, but this is a single-threaded program
  • inlined functions in header file to avoid potential ODR (one-definition-rule) violations: since functions are defined directly in the header, including it from multiple translation units would cause multiple definitions, which inlining avoids by duplicating the definition per translation unit
  • put functions in header files in a separate namespace if there are using directives, to avoid clutter in the global namespace and clarify dependencies in main files
  • introduced const wherever possible
  • integer type hygiene (use Eigen::Index for indexing)
  • replaced c-style cast with static cast (C++ style casts are checked by the compiler. C style casts aren't and can fail at runtime.)
  • explicitly casted between integer types (narrowing, different signedness)
  • explicitly casted integer types to double
  • avoided pointer arithmetic, instead used span (e.g. for command line arguments), which is safe to index
  • avoided unitialized variables, instead used NAN to initialize doubles or -1 to initialize indices. this is more likely to show up as an error than accidentally using unitialized memory
  • reordered includes as good practice (user header first, then system headers, ordered alphabetically
  • wrapped body statement of for, do while, and while in braces. increases readability and forgetting braces is a common source of bugs for students.
  • removed unused variables
  • avoided multiple declarations in a single line for readability
  • used emplace_back instead of push_back to avoid copies of temporary objects in the worst case
  • avoided else after return since it reduces readability of code flow when it comes to main and exit error codes and quickly causes bugs
  • replaced if/else with only assignment statements with ternary operator to allow constness of assigned variable
  • used explicit integer constants, (i.e. 0L instead of 0) to fit std::max and similar templates where the other is an Eigen::Index

LectureCodes/Evp/imread.hpp

  • more verbose/readable code which explains in more detail how the bmp file format is read
  • made file raw pointer ownership safe by wrapping it in the gsl::owner class (this signals to the static checker that a resource/dynamic memory has a unique owner and will only be deleted/closed by that owner)
  • excluded check altera-struct-pack-align locally: headers for existing file formats must, of course, be read as they come, thus we must do without 64-byte alignment
  • static cast to void to explicitly ignore return values
  • replaced c array with std::vector to benefit from bounds checking
Edited by hgratten

Merge request reports

Loading