~ fixed clang-tidy magic-number errors

This commit is contained in:
Julian Hinxlage 2019-11-12 15:03:17 +01:00
parent eb3c521038
commit a1f9f62f51
2 changed files with 19 additions and 18 deletions

View File

@ -52,17 +52,19 @@ void logTime(){
struct tm *timeinfo; struct tm *timeinfo;
timeinfo = localtime(&rawtime); timeinfo = localtime(&rawtime);
if (timeinfo->tm_hour < 10) { constexpr int decimalBase = 10;
if (timeinfo->tm_hour < decimalBase) {
std::cout << "0"; std::cout << "0";
} }
std::cout << timeinfo->tm_hour; std::cout << timeinfo->tm_hour;
std::cout << ":"; std::cout << ":";
if (timeinfo->tm_min < 10) { if (timeinfo->tm_min < decimalBase) {
std::cout << "0"; std::cout << "0";
} }
std::cout << timeinfo->tm_min; std::cout << timeinfo->tm_min;
std::cout << ":"; std::cout << ":";
if (timeinfo->tm_sec < 10) { if (timeinfo->tm_sec < decimalBase) {
std::cout << "0"; std::cout << "0";
} }
std::cout << timeinfo->tm_sec; std::cout << timeinfo->tm_sec;

View File

@ -5,26 +5,25 @@
#include <csignal> #include <csignal>
#include <unistd.h> #include <unistd.h>
// NOLINT
void initialize(int pid) { void initialize(int pid) {
impl.sharedMemoryPid = pid; impl.sharedMemoryPid = pid;
const int sharedMemoryKey = 12345; impl.sharedMemoryKey = 12345;// NOLINT
impl.sharedMemoryKey = sharedMemoryKey;
const int sharedMemorySize = 8000; impl.sharedMemorySize = 8000;// NOLINT
impl.sharedMemorySize = sharedMemorySize;
//set default values //set default values
setCharactersPerRow(60); setCharactersPerRow(60);// NOLINT
setCharactersPerColumn(20); setCharactersPerColumn(20);// NOLINT
setHeight(600); setHeight(600);// NOLINT
setWidth(800); setWidth(800);// NOLINT
setMousePosition(42,42); setMousePosition(42,42);// NOLINT
setBackgroundColor(Color(200,50,20)); setBackgroundColor(Color(200,50,20));// NOLINT
setForegroundColor(Color(20,200,50)); setForegroundColor(Color(20,200,50));// NOLINT
setMode(GraphicMode::TrueColor); setMode(GraphicMode::TrueColor);// NOLINT
setRedrawInterval(20); setRedrawInterval(20);// NOLINT
setTimerInterruptInterval(10); setTimerInterruptInterval(10);// NOLINT
} }
bool registerEvent(EventType type, const std::function<void()> &handler) { bool registerEvent(EventType type, const std::function<void()> &handler) {
@ -68,7 +67,7 @@ Color getPixel(int x, int y) {
bool setText(std::string text) { bool setText(std::string text) {
lockSharedMemory(); lockSharedMemory();
char *ptr = getTextArea(); char *ptr = getTextArea();
for(int i = 0; i < text.size();i++){ for(int i = 0; i < static_cast<int>(text.size());i++){
if(i >= getCharactersPerColumn() * getCharactersPerRow()){ if(i >= getCharactersPerColumn() * getCharactersPerRow()){
break; break;
} }