diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 5959262..66584da 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -12,13 +12,19 @@ + + - - - - - + + + + + + + + + + + + - + @@ -127,23 +145,25 @@ + - - diff --git a/general/CMakeLists.txt b/general/CMakeLists.txt index a8444ff..44a9a26 100644 --- a/general/CMakeLists.txt +++ b/general/CMakeLists.txt @@ -8,6 +8,13 @@ message( "current compiler " ${CMAKE_CXX_COMPILER_ID}) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") # using Clang elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + add_compile_options(-Wall) + add_compile_options(-Wsign-compare) + add_compile_options(-Werror) + add_compile_options(-Wno-unused-function) + add_compile_options(-Wno-misleading-indentation) + add_compile_options(-Wno-format-overflow) + # using GCC elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") # using Intel C++ @@ -28,7 +35,7 @@ aux_source_directory(src/pattern PaternSrc) add_library(General OBJECT ${DIRSRCS} ${PaternSrc} src/pattern/signleton.hpp src/pattern/Observer.hpp src/pattern/stratergy.hpp src/pattern/adapter.hpp src/encrypt/base64.cpp src/encrypt/base64.h src/encrypt/aes.cpp src/encrypt/aes.h src/encrypt/rsa.cpp - src/math/BigInt.hpp src/net/TcpClient.cpp src/net/TcpClient.h src/net/PackageReceiver.cpp src/net/PackageReceiver.h) + src/math/BigInt.hpp src/net/TcpClient.cpp src/net/TcpClient.h src/net/PackageReceiver.cpp src/net/PackageReceiver.h src/function/btree.cpp src/function/btree.h) set(COPYITEM inc) file(GLOB INCLUDES ${PROJECT_SOURCE_DIR}/inc/*) diff --git a/general/src/debug.cpp b/general/src/debug.cpp index 27ddbeb..606d19a 100644 --- a/general/src/debug.cpp +++ b/general/src/debug.cpp @@ -5,16 +5,12 @@ int PrintDumpObjvoid (void *dst,int rowNum,int num,bool ifAsii){ char out [2048] = {0}; - if (NULL == out) { - return -1; - } int row = num / rowNum; int left = num %rowNum; if (left != 0){ row += 1; } - char lineStr[5]; - sprintf(out,"LN: ",strlen("LN: ")); + snprintf(out,strlen("LN: "),"LN: "); //char out[10240] = "LN: " ; for (int z = 1;z < rowNum + 1; z++) { char tmp[4] = {0}; @@ -100,9 +96,7 @@ int dumpObj(void *dst,int rowNum,int num,bool ifAsii,char *out) { if (left != 0){ row += 1; } - char lineStr[5]; - sprintf(out,"LN: ",strlen("LN: ")); - //char out[10240] = "LN: " ; + sprintf(out,"LN: "); for (int z = 1;z < rowNum + 1; z++) { char tmp[4] = {0}; sprintf(tmp,"%02d ",z); diff --git a/general/src/encrypt/aes.cpp b/general/src/encrypt/aes.cpp index 1259c2a..e7da967 100644 --- a/general/src/encrypt/aes.cpp +++ b/general/src/encrypt/aes.cpp @@ -1054,7 +1054,7 @@ void AES::Encrypt(char const* in, char* result, size_t n, int iMode) //n should be > 0 and multiple of m_blockSize if (0 == n || n % m_blockSize != 0) return; - int i; + size_t i; char const* pin; char* presult; if (CBC == iMode) //CBC mode, using the Chain @@ -1097,7 +1097,7 @@ void AES::Decrypt(char const* in, char* result, size_t n, int iMode) //n should be > 0 and multiple of m_blockSize if (0 == n || n % m_blockSize != 0) return; - int i; + size_t i; char const* pin; char* presult; if (CBC == iMode) //CBC mode, using the Chain diff --git a/general/src/encrypt/rsa.cpp b/general/src/encrypt/rsa.cpp index 0c32df3..b32eaed 100644 --- a/general/src/encrypt/rsa.cpp +++ b/general/src/encrypt/rsa.cpp @@ -71,7 +71,7 @@ const static int PrimeTable[550]= // 判断两个数是否为互素 static int Mod(BigInt p1,BigInt p2){ - + return 0; } /* 目前的做法是基于费马素性检测 diff --git a/general/src/function/btree.cpp b/general/src/function/btree.cpp new file mode 100644 index 0000000..1d4c909 --- /dev/null +++ b/general/src/function/btree.cpp @@ -0,0 +1,5 @@ +// +// Created by 29019 on 2020/5/6. +// + +#include "btree.h" diff --git a/general/src/function/btree.h b/general/src/function/btree.h new file mode 100644 index 0000000..fcea42f --- /dev/null +++ b/general/src/function/btree.h @@ -0,0 +1,14 @@ +// +// Created by 29019 on 2020/5/6. +// + +#ifndef GENERAL_BTREE_H +#define GENERAL_BTREE_H + + +class btree { + +}; + + +#endif //GENERAL_BTREE_H diff --git a/general/src/loger.cpp b/general/src/loger.cpp index 86f6da7..7586814 100644 --- a/general/src/loger.cpp +++ b/general/src/loger.cpp @@ -61,7 +61,7 @@ _C_Loger::_C_Loger(string path) { this->mCurrentPath = path + this->mCurrentDate; this->mFile = fopen(this->mCurrentPath.c_str(),"a+"); if(! this->mFile){ - fprintf(stderr,"error open log files %s code %d,please check file path",this->mCurrentPath.c_str(),this->mFile,errno); + fprintf(stderr,"error open log files %s code %d,please check file path",this->mCurrentPath.c_str(),errno); exit(0); }else{ diff --git a/general/src/net/PackageReceiver.cpp b/general/src/net/PackageReceiver.cpp index 3bf1d67..ec6bd72 100644 --- a/general/src/net/PackageReceiver.cpp +++ b/general/src/net/PackageReceiver.cpp @@ -65,8 +65,8 @@ int PackageReceiver::SortPack(uint8_t * inData, uint32_t size) if ((this->mUnsortData[0] != 0x40 || this->mUnsortData[1] != 0x41)) { return -1; } - uint32_t len = mUnsortData[2] << 24 + mUnsortData[3] << 16 + mUnsortData[4] - << 8 + mUnsortData[0]; // 长度 + uint32_t len = mUnsortData[2] << (24 + mUnsortData[3]) << (16 + mUnsortData[4]) + << (8 + mUnsortData[0]); // 长度 if (len > size + mUnsortLen) { //大包还需要重组 memcpy(mUnsortData + mUnsortLen, inData, size); mUnsortLen += size; diff --git a/general/src/net/TcpClient.cpp b/general/src/net/TcpClient.cpp index 13277ff..264ea96 100644 --- a/general/src/net/TcpClient.cpp +++ b/general/src/net/TcpClient.cpp @@ -42,6 +42,8 @@ int ThreadRun(TcpClientLibevent *p) { if (nullptr != p) { p->mStatus = TcpClientLibevent::UNCONNECTED; int ret = p->Dispatch(); + if (0 > ret){ + } while ((p->mStatus != TcpClientLibevent::UNCONNECTED )) { if (p->mStatus == TcpClientLibevent::FAIL) { //连接失败,如果有设置自动重连就一直重连 @@ -117,9 +119,8 @@ bool TcpClientLibevent::Connected() { } TcpClientLibevent::TcpClientLibevent(std::string addrinfo, int port, TcpClientLibevent::TcpClientObserver *p) : - mObserver(nullptr), mStatus(UNCONNECTED), - mReConnect(false) + mObserver(nullptr) { memset(&mSrv, 0, sizeof(mSrv)); mSrv.sin_addr.S_un.S_addr = inet_addr(addrinfo.c_str()); diff --git a/general/src/net/TcpClient.h b/general/src/net/TcpClient.h index 3a0ecae..b409dde 100644 --- a/general/src/net/TcpClient.h +++ b/general/src/net/TcpClient.h @@ -39,13 +39,13 @@ public: int Dispatch(); int OnTCPPackage(uint8_t *, uint16_t); int SetReconnect(bool); - int SetObserver(TcpClientObserver*); + int Close(); Status mStatus; PackageReceiver mPack; TcpClientObserver *mObserver; private: - bool mReConnect; + bool mReConnect = false; int sendData(void*,size_t); struct event_base *mBase; struct bufferevent* bev;