~fixed all clang-tidy erros

This commit is contained in:
Johannes Theiner 2019-11-13 15:42:04 +01:00
parent c8569eb3b4
commit c1c08ca546
12 changed files with 29 additions and 41 deletions

View File

@ -9,7 +9,7 @@ filelist="$(find . -not \( -path './*build*' -prune \) -not \( -path './include'
for file in $filelist; do
if echo "$file" | grep -q -E ".*(\.cpp|\.h|\.hpp)$" ; then
#Extra check missing dependencies due to clang-tidy doesn't toggle exit code.
clang_tidy_lib_check="$(clang-tidy -warnings-as-errors='*' -header-filter='.*,-cpptoml.hpp' -checks='*,-llvm-header-guard,-fuchsia-statically-constructed-objects,-fuchsia*,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-constant-array-index,-bugprone-narrowing-conversions,-cppcoreguidelines-narrowing-conversions,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-hicpp-signed-bitwise,-bugprone-exception-escape,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-cstyle-cast,-hicpp-member-init,-google-readability-namespace-comments,-llvm-namespace-comment' "$file" -- -I. -std=c++14 2>&1)"
clang_tidy_lib_check="$(clang-tidy -warnings-as-errors='*' --color -header-filter='.*,-cpptoml.hpp' "$file" -- -I. -std=c++14 2>&1)"
for tidy_line in $clang_tidy_lib_check; do
echo "$tidy_line" | grep -q -v -E "^Error while processing*"
if [ $? -eq 1 ]; then

2
.clang-tidy Normal file
View File

@ -0,0 +1,2 @@
Checks: '*,-llvm-header-guard,-fuchsia*,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-constant-array-index,-bugprone-narrowing-conversions,-cppcoreguidelines-narrowing-conversions,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-hicpp-signed-bitwise,-bugprone-exception-escape,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-cstyle-cast,-hicpp-member-init,-google-readability-namespace-comments,-llvm-namespace-comment,-cppcoreguidelines-pro-type-vararg,-hicpp-vararg'
WarningsAsErrors: 'true'

View File

@ -13,7 +13,7 @@ set(CMAKE_CXX_STANDARD 14)
# enable clang_tidy
set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-checks=*")
set(CMAKE_CXX_CLANG_TIDY clang-tidy;-header-filter=.;-checks=*;)
set(CMAKE_CXX_CLANG_TIDY clang-tidy;-header-filter=.;)
file(GLOB_RECURSE SOURCES src/*.cpp)

View File

@ -2,11 +2,7 @@
namespace vkvm {
FontType::FontType(int id, std::string name, int height, int width) noexcept {
this->id = id;
this->name = std::move(name);
this->height = height;
this->width = width;
FontType::FontType(int id, const char * name, int height, int width) noexcept : id(id), name(name), height(height), width(width) {
}
auto FontType::getId() const -> int {
@ -14,7 +10,7 @@ namespace vkvm {
}
auto FontType::getName() const -> std::string {
return name;
return std::string(name);
}
auto FontType::getHeight() const -> int {

View File

@ -10,12 +10,12 @@ namespace vkvm {
class FontType {
private:
int id;
std::string name;
const char * name;
int height;
int width;
public:
FontType(int id, std::string name, int height, int width) noexcept;
FontType(int id, const char * name, int height, int width) noexcept;
auto getId() const -> int;
@ -27,9 +27,7 @@ namespace vkvm {
};
const static FontType font_1 = FontType(1, "DummyFont", 10, 5);
static const FontType font_1 = FontType(1, "DummyFont", 10, 5);
}
#endif

View File

@ -12,7 +12,7 @@ namespace vkvm {
Text = 1,
TwoColors = 2,
Gray_256 = 3,
TrueColor = 4,
RGB = 4
};
}

View File

@ -61,26 +61,17 @@ namespace vkvm {
}
auto getSharedMemory() -> char * {
bool useLocal = false;
if(!useLocal){
int shmId = shmget(impl.sharedMemoryKey, NULL, 0);
int shmId = shmget(impl.sharedMemoryKey, 0, 0);
if (shmId < 0) {
//no shared memory found
useLocal = true;
} else {
return (char *) shmat(shmId, NULL, 0);
}
}
if(useLocal) {
//using a local buffer for shared memory testing
if (localSharedMemory.empty()) {
initSemaphore();
localSharedMemory.resize(impl.sharedMemorySize * 1024);
constexpr int kilo = 1024;
localSharedMemory.resize(impl.sharedMemorySize * kilo);
}
return &localSharedMemory[0];
}
return static_cast<char *>(shmat(shmId, nullptr, 0));
}
auto getSharedMemory(char *address, int size, int offset) -> void {

View File

@ -3,8 +3,6 @@
#include "vkvm.hpp"
#include <csignal>
#include <sys/shm.h>
namespace vkvm {

View File

@ -1,14 +1,14 @@
#ifndef LIBRARY_INTERNAL_HPP
#define LIBRARY_INTERNAL_HPP
#include "Color.hpp"
#include "EventType.hpp"
#include "GraphicMode.hpp"
#include "KeyCode.hpp"
#include "LayoutVersion.hpp"
#include "GraphicMode.hpp"
#include "Color.hpp"
#include <functional>
#include <sys/types.h>
#include <vector>
#include <functional>
namespace vkvm {
@ -17,6 +17,9 @@ namespace vkvm {
* @author Julian Hinxlage
* @since 0.1.0
*/
constexpr int keyboardBufferSize = 16;
struct Registers {
int layout_version;
int trigger_reset;
@ -34,7 +37,7 @@ namespace vkvm {
int textMode_font_height;
int mouse_pos_x;
int mouse_pos_y;
short keyboardBuffer[16];
std::array<int16_t, keyboardBufferSize> keyboardBuffer;
int keyboardBuffer_index_write;
int keyboardBuffer_index_read;
};
@ -51,8 +54,8 @@ namespace vkvm {
int sharedMemoryPid;
key_t sharedMemoryKey;
int sharedMemorySize;
int interruptEntyCount = 64;
int reservedSize = 1024;
int interruptEntyCount = 64; //NOLINT
int reservedSize = 1024; //NOLINT
std::vector<std::function<void()>> eventTable;
};

View File

@ -1,8 +1,8 @@
#ifndef LIBRARY_LOG_HPP
#define LIBRARY_LOG_HPP
#include <string>
#include <sstream>
#include <string>
namespace vkvm {
enum LogLevel{

View File

@ -25,7 +25,7 @@ namespace vkvm {
setMousePosition(42, 42);// NOLINT
setBackgroundColor(Color(200, 50, 20));// NOLINT
setForegroundColor(Color(20, 200, 50));// NOLINT
setMode(GraphicMode::TrueColor);// NOLINT
setMode(GraphicMode::RGB);// NOLINT
setRedrawInterval(20);// NOLINT
setTimerInterruptInterval(10);// NOLINT
}

View File

@ -3,8 +3,8 @@
#include "Color.hpp"
#include "EventType.hpp"
#include "GraphicMode.hpp"
#include "FontType.hpp"
#include "GraphicMode.hpp"
#include "KeyCode.hpp"
#include "LayoutVersion.hpp"
#include "log.hpp"