code style
This commit is contained in:
@@ -57,7 +57,7 @@ static FILE* s_logFile = stdout;
|
||||
|
||||
bool setLogFacilities(const char* facilities) {
|
||||
char *input = strdup(facilities);
|
||||
char *opt = (char*)input, *value = NULL;
|
||||
char *opt = reinterpret_cast<char*>(input), *value = NULL;
|
||||
int newFacilites = 0;
|
||||
while (*opt) {
|
||||
int val = getsubopt(&opt, (char *const *)facilityNames, &value);
|
||||
@@ -97,7 +97,7 @@ bool getLogFacilities(char* buffer) {
|
||||
|
||||
bool setLogLevel(const char* level) {
|
||||
char *input = strdup(level);
|
||||
char *opt = (char*)input, *value = NULL;
|
||||
char *opt = reinterpret_cast<char*>(input), *value = NULL;
|
||||
int newLevel = 0;
|
||||
if (*opt) {
|
||||
int val = getsubopt(&opt, (char *const *)levelNames, &value);
|
||||
|
||||
@@ -77,7 +77,7 @@ void RotateFile::write(unsigned char* value, unsigned int size, bool received) {
|
||||
if ((m_fileSize%1024) == 0) {
|
||||
fflush(m_stream);
|
||||
}
|
||||
if (m_fileSize >= m_maxSize * 1024) {
|
||||
if (m_fileSize >= m_maxSize * 1024LL) {
|
||||
string oldfile = string(m_fileName)+".old";
|
||||
if (rename(m_fileName.c_str(), oldfile.c_str()) == 0) {
|
||||
fclose(m_stream);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#define LIB_UTILS_ROTATEFILE_H_
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
@@ -41,7 +42,7 @@ class RotateFile {
|
||||
* @param maxSize the maximum size of the file to write to.
|
||||
* @param textMode whether to write each byte with prefixed timestamp and direction as text.
|
||||
*/
|
||||
RotateFile(const string fileName, const unsigned long maxSize, const bool textMode = false)
|
||||
RotateFile(const string fileName, const unsigned int maxSize, const bool textMode = false)
|
||||
: m_enabled(false), m_fileName(fileName), m_maxSize(maxSize), m_textMode(textMode), m_stream(), m_fileSize(0) {}
|
||||
|
||||
/**
|
||||
@@ -79,7 +80,7 @@ class RotateFile {
|
||||
const string m_fileName;
|
||||
|
||||
/** the maximum size of @a m_file, or 0 for infinite. */
|
||||
const unsigned long m_maxSize;
|
||||
const unsigned int m_maxSize;
|
||||
|
||||
/** whether to write each byte with prefixed timestamp and direction as text. */
|
||||
const bool m_textMode;
|
||||
@@ -88,7 +89,7 @@ class RotateFile {
|
||||
FILE* m_stream;
|
||||
|
||||
/** the number of bytes already written to the @a m_file. */
|
||||
unsigned long m_fileSize;
|
||||
uint64_t m_fileSize;
|
||||
};
|
||||
|
||||
#endif // LIB_UTILS_ROTATEFILE_H_
|
||||
|
||||
@@ -39,7 +39,7 @@ TCPSocket* TCPClient::connect(const string& server, const uint16_t& port) {
|
||||
struct sockaddr_in address;
|
||||
int ret;
|
||||
|
||||
memset((char*) &address, 0, sizeof(address));
|
||||
memset(reinterpret_cast<char*>(&address), 0, sizeof(address));
|
||||
|
||||
if (inet_addr(server.c_str()) == INADDR_NONE) {
|
||||
struct hostent* he;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "clock.h"
|
||||
|
||||
void* Thread::runThread(void* arg) {
|
||||
((Thread*)arg)->enter();
|
||||
reinterpret_cast<Thread*>(arg)->enter();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user