From b20013873017aa29bf63ae27385df682d0a9dbce Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Mon, 21 Jan 2019 14:43:24 +0100 Subject: [PATCH] data types and format --- .clang-tidy | 7 ++++ .../slsDetector/slsDetector.cpp | 21 +++++------ slsDetectorSoftware/slsDetector/slsDetector.h | 4 +-- slsSupportLib/include/MySocketTCP.h | 35 ++++++++----------- 4 files changed, 34 insertions(+), 33 deletions(-) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000..7c2775daf --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,7 @@ +--- +Checks: '*, -google-runtime-references, -hicpp-no-array-decay, -cppcoreguidelines-pro-bounds-array-to-pointer-decay, -cppcoreguidelines-pro-bounds-pointer-arithmetic, -fuchsia*,-readability-else-after-return,-readability-avoid-const-params-in-decls,-hicpp-signed-bitwise,-cppcoreguidelines-pro-bounds-constant-array-index,-llvm-header-guard,-readability-static-accessed-through-instance,-google-readability-todo' +WarningsAsErrors: '*' +HeaderFilterRegex: '.*' +AnalyzeTemporaryDtors: false +FormatStyle: none +... diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 6b48dde3b..b3fd44e0f 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -11,6 +11,7 @@ #include "versionAPI.h" #include +#include #include #include #include @@ -5258,18 +5259,18 @@ int slsDetector::setCTBPatLoops(int level, int &start, int &stop, int &n) { return ret; } -int slsDetector::setCTBPatWaitAddr(int level, int addr) { +uint64_t slsDetector::setCTBPatWaitAddr(uint64_t level, uint64_t addr) { int fnum = F_SET_CTB_PATTERN; int ret = FAIL; - int mode = 2; // sets loop - uint64_t args[3] = {(uint64_t)mode, (uint64_t)level, (uint64_t)addr}; - uint64_t retval = -1; + uint64_t mode = 2; // sets loop + uint64_t retval = -1; + std::array args{mode, level, addr}; FILE_LOG(logDEBUG1) << "Setting CTB Wait Addr, " "level: " << level << ", addr: 0x" << std::hex << addr << std::dec; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { - ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); + ret = thisDetectorControl->Client_Send(fnum, args.data(), sizeof(args), &retval, sizeof(retval)); disconnectControl(); // handle ret @@ -5285,16 +5286,16 @@ int slsDetector::setCTBPatWaitAddr(int level, int addr) { return retval; } -int slsDetector::setCTBPatWaitTime(int level, uint64_t t) { +uint64_t slsDetector::setCTBPatWaitTime(uint64_t level, uint64_t t) { int fnum = F_SET_CTB_PATTERN; int ret = FAIL; - int mode = 3; // sets loop - uint64_t args[3] = {(uint64_t)mode, (uint64_t)level, t}; - uint64_t retval = -1; + uint64_t mode = 3; // sets loop + uint64_t retval = -1; //TODO! is this what we want? + std::array args{mode, level, t}; FILE_LOG(logDEBUG1) << "Setting CTB Wait Time, level: " << level << ", t: " << t; if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { - ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); + ret = thisDetectorControl->Client_Send(fnum, args.data(), sizeof(args), &retval, sizeof(retval)); disconnectControl(); // handle ret diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index f33bcac3f..586bbcb2e 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -1612,7 +1612,7 @@ public: * @param addr wait address, -1 gets * @returns actual value */ - int setCTBPatWaitAddr(int level, int addr=-1); + uint64_t setCTBPatWaitAddr(uint64_t level, uint64_t addr=-1); /** * Sets the wait time in the CTB @@ -1620,7 +1620,7 @@ public: * @param t wait time, -1 gets * @returns actual value */ - int setCTBPatWaitTime(int level, uint64_t t=-1); + uint64_t setCTBPatWaitTime(uint64_t level, uint64_t t=-1); private: diff --git a/slsSupportLib/include/MySocketTCP.h b/slsSupportLib/include/MySocketTCP.h index 910528dcb..9597b5a0c 100644 --- a/slsSupportLib/include/MySocketTCP.h +++ b/slsSupportLib/include/MySocketTCP.h @@ -12,38 +12,31 @@ /* canceled SetupParameters() and varaibles intialized in the constructors' headers; defined SEND_REC_MAX_SIZE (for compatibilty with mythen (and possibly other) pure C servers (i would move it to the common header file) - added #ifndef C_ONLY... to cutout class definition when including in pure C servers (can be removed if SEND_REC_MAX_SIZE is moved to the common header file) - defined private variables char hostname[1000] and int portno to store connection informations; - defined public functions int getHostname(char *name) and int getPortNumber() to retrieve connection informations - added public function int getErrorStatus() returning 1 if socketDescriptor<0 - remove exits in the constructors and replace them with socketDescriptor=-1 - replaced the argument of send/receive data with void (to avoid too much casting or compiler errors/warnings) - added a function which really does not close the socket between send/receive (senddataonly, receivedataonly) -*/ -/* Modified by Anna on 31.10.2012 - -developed and - -*/ - + Modified by Anna on 31.10.2012 developed and + */ #include "genericSocket.h" #define TCP_PACKET_SIZE 4096 -class MySocketTCP: public genericSocket { - - public: - MySocketTCP(const char* const host_ip_or_name, unsigned short int const port_number): genericSocket(host_ip_or_name, port_number,TCP){setPacketSize(TCP_PACKET_SIZE);}; // sender (client): where to? ip - MySocketTCP(unsigned short int const port_number):genericSocket(port_number,TCP) {setPacketSize(TCP_PACKET_SIZE);}; // receiver (server) local no need for ip +class MySocketTCP : public genericSocket { + public: + // sender (client): where to? ip + MySocketTCP(const char *const host_ip_or_name, uint64_t port_number) + : genericSocket(host_ip_or_name, port_number, TCP) { + setPacketSize(TCP_PACKET_SIZE); + } + // receiver (server) local no need for ip + MySocketTCP(uint16_t port_number) + : genericSocket(port_number, TCP) { + setPacketSize(TCP_PACKET_SIZE); + } virtual ~MySocketTCP(){}; - }; -