summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2012-08-29 23:19:09 -0700
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2012-08-29 23:48:58 -0700
commit38833205e4011a8a318b8dc6809621a89ad9f446 (patch)
treeeb1c8c8a4b9b6a9718b87df5cf13832ba0fecf68
parent3f1b0920d697afff0f3e938cb7eca0aacfd75a91 (diff)
Using true C++11 initializers in classes.
-rw-r--r--includes/BStream.h6
-rw-r--r--includes/Input.h6
-rw-r--r--includes/Output.h6
-rw-r--r--includes/Printer.h4
-rw-r--r--includes/SimpleMustache.h6
-rw-r--r--includes/Socket.h6
-rw-r--r--includes/TaskMan.h6
-rw-r--r--includes/Threads.h6
-rw-r--r--includes/ZHandle.h4
-rw-r--r--src/BStream.cc2
-rw-r--r--src/Input.cc2
-rw-r--r--src/Output.cc2
-rw-r--r--src/Printer.cc2
-rw-r--r--src/Socket.cc5
-rw-r--r--src/TaskMan.cc2
-rw-r--r--src/ZHandle.cc2
16 files changed, 34 insertions, 33 deletions
diff --git a/includes/BStream.h b/includes/BStream.h
index 86b0e0f..d412782 100644
--- a/includes/BStream.h
+++ b/includes/BStream.h
@@ -21,10 +21,10 @@ class BStream : public Handle {
private:
IO<Handle> m_h;
uint8_t * m_buffer;
- size_t m_availBytes;
- size_t m_cursor;
+ size_t m_availBytes = 0;
+ size_t m_cursor = 0;
String m_name;
- bool m_passThru;
+ bool m_passThru = false;
bool m_detached;
bool m_closed;
};
diff --git a/includes/Input.h b/includes/Input.h
index 9d45baa..e0ad329 100644
--- a/includes/Input.h
+++ b/includes/Input.h
@@ -16,11 +16,11 @@ class Input : public SeekableHandle {
virtual time_t getMTime();
const char * getFName() { return m_fname.to_charp(); }
private:
- int m_fd;
+ int m_fd = -1;
String m_name;
String m_fname;
- off_t m_size;
- time_t m_mtime;
+ off_t m_size = -1;
+ time_t m_mtime = -1;
};
};
diff --git a/includes/Output.h b/includes/Output.h
index 59d9d67..d771227 100644
--- a/includes/Output.h
+++ b/includes/Output.h
@@ -16,11 +16,11 @@ class Output : public SeekableHandle {
virtual time_t getMTime();
const char * getFName() { return m_fname.to_charp(); }
private:
- int m_fd;
+ int m_fd = -1;
String m_name;
String m_fname;
- off_t m_size;
- time_t m_mtime;
+ off_t m_size = -1;
+ time_t m_mtime = -1;
};
};
diff --git a/includes/Printer.h b/includes/Printer.h
index b4001f1..e215fc1 100644
--- a/includes/Printer.h
+++ b/includes/Printer.h
@@ -74,8 +74,8 @@ class Printer {
static void setDetailled(bool enable) { getPrinter()->m_detailledLogs = enable; }
private:
- uint32_t m_verbosity;
- bool m_detailledLogs;
+ uint32_t m_verbosity = M_STATUS | M_WARNING | M_ERROR | M_ENGINE_DEBUG;
+ bool m_detailledLogs = false;
};
};
diff --git a/includes/SimpleMustache.h b/includes/SimpleMustache.h
index 2bb0cb1..9d16377 100644
--- a/includes/SimpleMustache.h
+++ b/includes/SimpleMustache.h
@@ -22,7 +22,7 @@ class SimpleMustache {
friend class Context;
};
- Context() : m_type(CONTEXTLIST), m_root(true) { }
+ Context() { }
~Context() { empty(); }
Proxy operator[](ssize_t idx) { ensureList(); return Proxy(this, idx); }
Context & operator[](const char * str);
@@ -55,7 +55,7 @@ class SimpleMustache {
BOOLSEC,
CONTEXTLIST,
LAMBDA,
- } m_type;
+ } m_type = CONTEXTLIST;
Context(ContextType type) : m_type(type), m_root(false) { }
Context(Context & c) { Failure("You can't copy a Context; use references"); }
Context & operator=(Context & c) { Failure("You can't assign a Context; use references"); return *this; }
@@ -64,7 +64,7 @@ class SimpleMustache {
typedef std::map<String, Context *> SubContext;
typedef std::vector<SubContext> ContextList;
ContextList m_contextList;
- bool m_root;
+ bool m_root = true;
void empty(bool skipFirst = false);
void ensureList(bool single = false);
diff --git a/includes/Socket.h b/includes/Socket.h
index 4a73277..981a385 100644
--- a/includes/Socket.h
+++ b/includes/Socket.h
@@ -50,9 +50,9 @@ class Socket : public Handle {
int m_fd;
String m_name;
- bool m_connected;
- bool m_connecting;
- bool m_listening;
+ bool m_connected = false;
+ bool m_connecting = false;
+ bool m_listening = false;
sockaddr_in6 m_localAddr, m_remoteAddr;
SocketEvent * m_evtR, * m_evtW;
};
diff --git a/includes/TaskMan.h b/includes/TaskMan.h
index 6a50491..d675d75 100644
--- a/includes/TaskMan.h
+++ b/includes/TaskMan.h
@@ -53,13 +53,13 @@ class TaskMan {
typedef gnu::hash_set<Task *, taskHasher> taskHash_t;
taskHash_t m_tasks, m_signaledTasks;
Queue<Task> m_pendingAdd;
- bool m_stopped;
+ bool m_stopped = false;
struct ev_loop * m_loop;
- bool m_allowedToSignal;
+ bool m_allowedToSignal = false;
ev::async m_evt;
std::queue<void *> m_stacks;
int m_nStacks;
- int m_stopCode;
+ int m_stopCode = 0;
};
template<class T>
diff --git a/includes/Threads.h b/includes/Threads.h
index 46ea365..13527d5 100644
--- a/includes/Threads.h
+++ b/includes/Threads.h
@@ -98,7 +98,7 @@ class GlobalThread : public Thread, public AtStart, public AtExit {
template<class T>
class Queue {
public:
- Queue() : m_front(NULL), m_back(NULL) { pthread_cond_init(&m_cond, NULL); }
+ Queue() { pthread_cond_init(&m_cond, NULL); }
~Queue() { while (!isEmpty()) pop(); pthread_cond_destroy(&m_cond); }
void push(T * t) {
ScopeLock sl(m_lock);
@@ -142,8 +142,8 @@ class Queue {
Cell * m_next, * m_prev;
T * m_elem;
};
- Cell * volatile m_front;
- Cell * volatile m_back;
+ Cell * volatile m_front = NULL;
+ Cell * volatile m_back = NULL;
pthread_cond_t m_cond;
};
diff --git a/includes/ZHandle.h b/includes/ZHandle.h
index 048e0cb..e972466 100644
--- a/includes/ZHandle.h
+++ b/includes/ZHandle.h
@@ -28,9 +28,9 @@ class ZStream : public Handle {
void doFlush(bool finish);
IO<Handle> m_h;
z_stream m_zin, m_zout;
- bool m_detached, m_closed, m_eof;
+ bool m_detached = false, m_closed = false, m_eof = false;
String m_name;
- uint8_t * m_in;
+ uint8_t * m_in = NULL;
};
};
diff --git a/src/BStream.cc b/src/BStream.cc
index 9420459..6c51c4f 100644
--- a/src/BStream.cc
+++ b/src/BStream.cc
@@ -3,7 +3,7 @@
static const int s_blockSize = 16 * 1024;
-Balau::BStream::BStream(const IO<Handle> & h) : m_h(h), m_buffer((uint8_t *) malloc(s_blockSize)), m_availBytes(0), m_cursor(0), m_passThru(false) {
+Balau::BStream::BStream(const IO<Handle> & h) : m_h(h), m_buffer((uint8_t *) malloc(s_blockSize)) {
AAssert(m_h->canRead(), "You can't create a buffered stream with a Handle that can't read");
m_name.set("Stream(%s)", m_h->getName());
if ((m_h.isA<Buffer>()) || (m_h.isA<BStream>()))
diff --git a/src/Input.cc b/src/Input.cc
index 14aed91..8168231 100644
--- a/src/Input.cc
+++ b/src/Input.cc
@@ -47,7 +47,7 @@ static int eioStatsDone(eio_req * req) {
return 0;
}
-Balau::Input::Input(const char * fname) throw (GeneralException) : m_fd(-1), m_size(-1), m_mtime(-1) {
+Balau::Input::Input(const char * fname) throw (GeneralException) {
m_name.set("Input(%s)", fname);
m_fname = fname;
diff --git a/src/Output.cc b/src/Output.cc
index 6de404e..a4f6275 100644
--- a/src/Output.cc
+++ b/src/Output.cc
@@ -47,7 +47,7 @@ static int eioStatsDone(eio_req * req) {
return 0;
}
-Balau::Output::Output(const char * fname, bool truncate) throw (GeneralException) : m_fd(-1), m_size(-1), m_mtime(-1) {
+Balau::Output::Output(const char * fname, bool truncate) throw (GeneralException) {
m_name.set("Output(%s)", fname);
m_fname = fname;
diff --git a/src/Printer.cc b/src/Printer.cc
index ee6029c..a7fee9f 100644
--- a/src/Printer.cc
+++ b/src/Printer.cc
@@ -16,7 +16,7 @@ static const char * prefixes[] = {
"(**) ",
};
-Balau::Printer::Printer() : m_verbosity(M_STATUS | M_WARNING | M_ERROR | M_ENGINE_DEBUG), m_detailledLogs(false) {
+Balau::Printer::Printer() {
#ifdef DEBUG
m_detailledLogs = true;
#endif
diff --git a/src/Socket.cc b/src/Socket.cc
index 1c3778a..148d0a4 100644
--- a/src/Socket.cc
+++ b/src/Socket.cc
@@ -230,7 +230,7 @@ static DNSRequest resolveName(const char * name, const char * service = NULL, st
}
#endif
-Balau::Socket::Socket() throw (GeneralException) : m_fd(socket(AF_INET6, SOCK_STREAM, 0)), m_connected(false), m_connecting(false), m_listening(false) {
+Balau::Socket::Socket() throw (GeneralException) : m_fd(socket(AF_INET6, SOCK_STREAM, 0)) {
m_name = "Socket(unconnected)";
RAssert(m_fd >= 0, "socket() returned %i", m_fd);
m_evtR = new SocketEvent(m_fd, ev::READ);
@@ -251,8 +251,9 @@ Balau::Socket::Socket() throw (GeneralException) : m_fd(socket(AF_INET6, SOCK_ST
Printer::elog(E_SOCKET, "Creating a socket at %p", this);
}
-Balau::Socket::Socket(int fd) : m_fd(fd), m_connected(true), m_connecting(false), m_listening(false) {
+Balau::Socket::Socket(int fd) : m_fd(fd) {
socklen_t len;
+ m_connected = true;
len = sizeof(m_localAddr);
getsockname(m_fd, (sockaddr *) &m_localAddr, &len);
diff --git a/src/TaskMan.cc b/src/TaskMan.cc
index 8fd6df5..17f0a40 100644
--- a/src/TaskMan.cc
+++ b/src/TaskMan.cc
@@ -125,7 +125,7 @@ void asyncDummy(ev::async & w, int revents) {
Balau::Printer::elog(Balau::E_TASK, "TaskMan is getting woken up...");
}
-Balau::TaskMan::TaskMan() : m_stopped(false), m_allowedToSignal(false), m_stopCode(0) {
+Balau::TaskMan::TaskMan() {
#ifndef _WIN32
coro_create(&m_returnContext, 0, 0, 0, 0);
#else
diff --git a/src/ZHandle.cc b/src/ZHandle.cc
index 7ab0133..e2f22f0 100644
--- a/src/ZHandle.cc
+++ b/src/ZHandle.cc
@@ -1,7 +1,7 @@
#include "ZHandle.h"
#include "Task.h"
-Balau::ZStream::ZStream(const IO<Handle> & h, int level, header_t header) : m_h(h), m_detached(false), m_closed(false), m_eof(false), m_in(NULL) {
+Balau::ZStream::ZStream(const IO<Handle> & h, int level, header_t header) : m_h(h) {
m_zin.zalloc = m_zout.zalloc = NULL;
m_zin.zfree = m_zout.zfree = NULL;
m_zin.opaque = m_zout.opaque = NULL;