Skip to content

Commit

Permalink
lib: reworked some class initializations
Browse files Browse the repository at this point in the history
  • Loading branch information
franku committed Nov 20, 2018
1 parent 02c9444 commit 20a3731
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
4 changes: 3 additions & 1 deletion core/src/dird/dird_conf.h
Expand Up @@ -144,7 +144,9 @@ class DirectorResource: public TlsResource {
char *log_timestamp_format; /* Timestamp format to use in generic logging messages */
s_password keyencrkey; /* Key Encryption Key */

DirectorResource() : TlsResource() {}
DirectorResource()
: TlsResource()
, DIRaddrs(nullptr) {}
};

/*
Expand Down
19 changes: 17 additions & 2 deletions core/src/lib/address_conf.cc
Expand Up @@ -42,8 +42,21 @@
//#include <resolv.h>
#endif

IPADDR::IPADDR(const IPADDR &src) : type(src.type)
IPADDR::IPADDR()
: type(R_UNDEFINED)
, saddr(nullptr)
, saddr4(nullptr)
#ifdef HAVE_IPV6
, saddr6(nullptr)
#endif
{
memset(&saddrbuf, 0, sizeof(saddrbuf));
}

IPADDR::IPADDR(const IPADDR &src)
: IPADDR()
{
type = src.type;
memcpy(&saddrbuf, &src.saddrbuf, sizeof(saddrbuf));
saddr = &saddrbuf.dontuse;
saddr4 = &saddrbuf.dontuse4;
Expand All @@ -52,8 +65,10 @@ IPADDR::IPADDR(const IPADDR &src) : type(src.type)
#endif
}

IPADDR::IPADDR(int af) : type(R_EMPTY)
IPADDR::IPADDR(int af)
: IPADDR()
{
type = R_EMPTY;
#ifdef HAVE_IPV6
if (!(af == AF_INET6 || af == AF_INET)) {
Emsg1(M_ERROR_TERM, 0, _("Only ipv4 and ipv6 are supported (%d)\n"), af);
Expand Down
4 changes: 2 additions & 2 deletions core/src/lib/address_conf.h
Expand Up @@ -30,12 +30,12 @@
class IPADDR : public SmartAlloc {
public:
typedef enum { R_SINGLE, R_SINGLE_PORT, R_SINGLE_ADDR, R_MULTIPLE,
R_DEFAULT, R_EMPTY
R_DEFAULT, R_EMPTY, R_UNDEFINED
} i_type;
IPADDR(int af);
IPADDR(const IPADDR & src);
private:
IPADDR() { /* block this construction */ }
IPADDR();
i_type type;
union {
struct sockaddr dontuse;
Expand Down
13 changes: 11 additions & 2 deletions core/src/lib/dlist.h
Expand Up @@ -52,6 +52,10 @@
struct dlink {
void *next;
void *prev;
dlink() {
next = nullptr;
prev = nullptr;
}
};

class dlist : public SmartAlloc {
Expand Down Expand Up @@ -105,7 +109,7 @@ inline void dlist::init(void *item, dlink *link)

inline void dlist::init()
{
head = tail = NULL;
head = tail = nullptr;
loffset = 0;
num_items = 0;
}
Expand All @@ -125,8 +129,13 @@ inline dlist::dlist(void *item, dlink *link)
}

/* Constructor with link at head of item */
inline dlist::dlist(void) : head(0), tail(0), loffset(0), num_items(0)
inline dlist::dlist(void)
: head(nullptr)
, tail(nullptr)
, loffset(0)
, num_items(0)
{
return;
}

inline void dlist::SetPrev(void *item, void *prev)
Expand Down

0 comments on commit 20a3731

Please sign in to comment.