From: Amos Jeffries Date: Tue, 14 Feb 2017 19:15:23 +0000 (+1300) Subject: Cleanup: convert class ErrorState to C++11 initilization X-Git-Tag: M-staged-PR71~271 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fc94fd660adfe8bd4085fdf0aaea3ccf1a3491f1;p=thirdparty%2Fsquid.git Cleanup: convert class ErrorState to C++11 initilization --- diff --git a/src/errorpage.cc b/src/errorpage.cc index 0460082876..8f0dd0d929 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -561,34 +561,13 @@ ErrorState::NewForwarding(err_type type, HttpRequest *request) ErrorState::ErrorState(err_type t, Http::StatusCode status, HttpRequest * req) : type(t), page_id(t), - err_language(NULL), httpStatus(status), -#if USE_AUTH - auth_user_request (NULL), -#endif - request(NULL), - url(NULL), - xerrno(0), - port(0), - dnsError(), - ttl(0), - src_addr(), - redirect_url(NULL), - callback(NULL), - callback_data(NULL), - request_hdrs(NULL), - err_msg(NULL), -#if USE_OPENSSL - detail(NULL), -#endif - detailCode(ERR_DETAIL_NONE) + callback(nullptr) { - memset(&ftp, 0, sizeof(ftp)); - if (page_id >= ERR_MAX && ErrorDynamicPages[page_id - ERR_MAX]->page_redirect != Http::scNone) httpStatus = ErrorDynamicPages[page_id - ERR_MAX]->page_redirect; - if (req != NULL) { + if (req) { request = req; HTTPMSGLOCK(request); src_addr = req->client_addr; @@ -683,9 +662,6 @@ ErrorState::~ErrorState() wordlistDestroy(&ftp.server_msg); safe_free(ftp.request); safe_free(ftp.reply); -#if USE_AUTH - auth_user_request = NULL; -#endif safe_free(err_msg); #if USE_ERR_LOCALES if (err_language != Config.errorDefaultLanguage) diff --git a/src/errorpage.h b/src/errorpage.h index 60518449b1..81f3a24d1b 100644 --- a/src/errorpage.h +++ b/src/errorpage.h @@ -15,6 +15,7 @@ #include "comm/forward.h" #include "err_detail_type.h" #include "err_type.h" +#include "http/forward.h" #include "http/StatusCode.h" #include "ip/Address.h" #include "SquidString.h" @@ -69,8 +70,6 @@ typedef void ERCB(int fd, void *, size_t); \endverbatim */ -class HttpReply; -class HttpRequest; class MemBuf; class StoreEntry; class wordlist; @@ -82,7 +81,7 @@ class ErrorState public: ErrorState(err_type type, Http::StatusCode, HttpRequest * request); - ErrorState(); // not implemented. + ErrorState() = delete; // not implemented. ~ErrorState(); /// Creates a general request forwarding error with the right http_status. @@ -137,42 +136,42 @@ private: int Dump(MemBuf * mb); public: - err_type type; - int page_id; - char *err_language; + err_type type = ERR_NONE; + int page_id = ERR_NONE; + char *err_language = nullptr; Http::StatusCode httpStatus; #if USE_AUTH Auth::UserRequest::Pointer auth_user_request; #endif - HttpRequest *request; - char *url; - int xerrno; - unsigned short port; + HttpRequest *request = nullptr; + char *url = nullptr; + int xerrno = 0; + unsigned short port = 0; String dnsError; ///< DNS lookup error message - time_t ttl; + time_t ttl = 0; Ip::Address src_addr; - char *redirect_url; + char *redirect_url = nullptr; ERCB *callback; - void *callback_data; + void *callback_data = nullptr; struct { - wordlist *server_msg; - char *request; - char *reply; - char *cwd_msg; - MemBuf *listing; + wordlist *server_msg = nullptr; + char *request = nullptr; + char *reply = nullptr; + char *cwd_msg = nullptr; + MemBuf *listing = nullptr; } ftp; - char *request_hdrs; - char *err_msg; /* Preformatted error message from the cache */ + char *request_hdrs = nullptr; + char *err_msg = nullptr; /* Preformatted error message from the cache */ #if USE_OPENSSL - Ssl::ErrorDetail *detail; + Ssl::ErrorDetail *detail = nullptr; #endif /// type-specific detail about the transaction error; /// overwrites xerrno; overwritten by detail, if any. - int detailCode; + int detailCode = ERR_DETAIL_NONE; }; /**