]> granicus.if.org Git - icinga2/commitdiff
Apply clang-tidy fix 'modernize-use-auto'
authorGunnar Beutner <gunnar.beutner@icinga.com>
Thu, 4 Jan 2018 08:07:03 +0000 (09:07 +0100)
committerGunnar Beutner <gunnar.beutner@icinga.com>
Thu, 4 Jan 2018 11:24:57 +0000 (12:24 +0100)
42 files changed:
icinga-studio/icinga-studio.cpp
lib/base/base64.cpp
lib/base/configobject.cpp
lib/base/configobject.hpp
lib/base/configtype.cpp
lib/base/exception.cpp
lib/base/fifo.cpp
lib/base/filelogger.cpp
lib/base/json.cpp
lib/base/objectlock.cpp
lib/base/process.cpp
lib/base/scriptutils.cpp
lib/base/tlsstream.cpp
lib/base/tlsutility.cpp
lib/base/utility.cpp
lib/base/value.hpp
lib/cli/troubleshootcommand.cpp
lib/compat/compatlogger.cpp
lib/config/configcompilercontext.cpp
lib/config/configitem.cpp
lib/config/configitembuilder.cpp
lib/config/expression.cpp
lib/config/vmops.hpp
lib/db_ido/dbconnection.cpp
lib/db_ido/idochecktask.cpp
lib/db_ido_mysql/idomysqlconnection.cpp
lib/db_ido_pgsql/idopgsqlconnection.cpp
lib/icinga/checkable-dependency.cpp
lib/icinga/checkable.cpp
lib/icinga/macroprocessor.cpp
lib/livestatus/statustable.cpp
lib/methods/pluginnotificationtask.cpp
lib/perfdata/elasticsearchwriter.cpp
lib/remote/apilistener-configsync.cpp
lib/remote/apilistener.cpp
lib/remote/authority.cpp
lib/remote/configobjectutility.cpp
lib/remote/createobjecthandler.cpp
lib/remote/filterutility.cpp
test/base-array.cpp
test/base-dictionary.cpp
tools/mkclass/classcompiler.cpp

index 1d3e657a3cfeb4a81f684bdce2c3bda1dec82847..d6e85662feec9ff892d9cde0def9959656edd563 100644 (file)
@@ -56,7 +56,7 @@ public:
                        pUrl = new Url(argv[1].ToStdString());
                }
 
-               MainForm *m = new MainForm(nullptr, pUrl);
+               auto *m = new MainForm(nullptr, pUrl);
                m->Show();
 
                return true;
index 896f92934b3fd3da3290cfc704786b341cefeec0..368dca8783c38e927b71eda59276e3a532e8671b 100644 (file)
@@ -51,7 +51,7 @@ String Base64::Decode(const String& input)
        BIO_push(bio64, biomem);
        BIO_set_flags(bio64, BIO_FLAGS_BASE64_NO_NL);
 
-       char *outbuf = new char[input.GetLength()];
+       auto *outbuf = new char[input.GetLength()];
 
        size_t len = 0;
        int rc;
index 3f24c36ca97ff98012a5f44b8ee94a700413e7a6..a4370d6df8ffa0ac02ab96f022800dce8cd4a1ed 100644 (file)
@@ -97,7 +97,7 @@ public:
        bool ValidateName(const String& type, const String& name) const override
        {
                Type::Ptr ptype = Type::GetByName(type);
-               ConfigType *dtype = dynamic_cast<ConfigType *>(ptype.get());
+               auto *dtype = dynamic_cast<ConfigType *>(ptype.get());
 
                if (!dtype)
                        return false;
@@ -503,7 +503,7 @@ void ConfigObject::DumpObjects(const String& filename, int attributeTypes)
        StdioStream::Ptr sfp = new StdioStream(&fp, false);
 
        for (const Type::Ptr& type : Type::GetAllTypes()) {
-               ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
+               auto *dtype = dynamic_cast<ConfigType *>(type.get());
 
                if (!dtype)
                        continue;
@@ -605,7 +605,7 @@ void ConfigObject::RestoreObjects(const String& filename, int attributeTypes)
        unsigned long no_state = 0;
 
        for (const Type::Ptr& type : Type::GetAllTypes()) {
-               ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
+               auto *dtype = dynamic_cast<ConfigType *>(type.get());
 
                if (!dtype)
                        continue;
@@ -627,7 +627,7 @@ void ConfigObject::RestoreObjects(const String& filename, int attributeTypes)
 void ConfigObject::StopObjects()
 {
        for (const Type::Ptr& type : Type::GetAllTypes()) {
-               ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
+               auto *dtype = dynamic_cast<ConfigType *>(type.get());
 
                if (!dtype)
                        continue;
@@ -641,7 +641,7 @@ void ConfigObject::StopObjects()
 void ConfigObject::DumpModifiedAttributes(const std::function<void(const ConfigObject::Ptr&, const String&, const Value&)>& callback)
 {
        for (const Type::Ptr& type : Type::GetAllTypes()) {
-               ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
+               auto *dtype = dynamic_cast<ConfigType *>(type.get());
 
                if (!dtype)
                        continue;
@@ -703,7 +703,7 @@ void ConfigObject::DumpModifiedAttributes(const std::function<void(const ConfigO
 ConfigObject::Ptr ConfigObject::GetObject(const String& type, const String& name)
 {
        Type::Ptr ptype = Type::GetByName(type);
-       ConfigType *ctype = dynamic_cast<ConfigType *>(ptype.get());
+       auto *ctype = dynamic_cast<ConfigType *>(ptype.get());
 
        if (!ctype)
                return nullptr;
index abb4e01202c54af1047c47b8514c824c8e917cb9..8ff068fc56d623494718b459694c2fb7b5d194fe 100644 (file)
@@ -82,7 +82,7 @@ public:
        static intrusive_ptr<T> GetObject(const String& name)
        {
                typedef TypeImpl<T> ObjType;
-               ObjType *ptype = static_cast<ObjType *>(T::TypeInstance.get());
+               auto *ptype = static_cast<ObjType *>(T::TypeInstance.get());
                return static_pointer_cast<T>(ptype->GetObject(name));
        }
 
index 4306df1bd2fdaf928f66841660b855c947c61fb4..0c3aa68ed4a3b0dce7ff0330fbf79c2615d3f06e 100644 (file)
@@ -51,7 +51,7 @@ void ConfigType::RegisterObject(const ConfigObject::Ptr& object)
                        if (it->second == object)
                                return;
 
-                       Type *type = dynamic_cast<Type *>(this);
+                       auto *type = dynamic_cast<Type *>(this);
 
                        BOOST_THROW_EXCEPTION(ScriptError("An object with type '" + type->GetName() + "' and name '" + name + "' already exists (" +
                                Convert::ToString(it->second->GetDebugInfo()) + "), new declaration: " + Convert::ToString(object->GetDebugInfo()),
index ceddeecbe18941b1d31d2e554ef41e5d55848326..46927d66e6d5bfd7078924463e5cf77a15b236b2 100644 (file)
@@ -58,8 +58,8 @@ inline void *cast_exception(void *obj, const std::type_info *src, const std::typ
        else
                return nullptr;
 #else /* __GLIBCXX__ */
-       const libcxx_type_info *srcInfo = static_cast<const libcxx_type_info *>(src);
-       const libcxx_type_info *dstInfo = static_cast<const libcxx_type_info *>(dst);
+       const auto *srcInfo = static_cast<const libcxx_type_info *>(src);
+       const auto *dstInfo = static_cast<const libcxx_type_info *>(dst);
 
        void *adj = obj;
 
@@ -104,7 +104,7 @@ void icinga::RethrowUncaughtException()
 extern "C"
 void __cxa_throw(void *obj, TYPEINFO_TYPE *pvtinfo, void (*dest)(void *))
 {
-       std::type_info *tinfo = static_cast<std::type_info *>(pvtinfo);
+       auto *tinfo = static_cast<std::type_info *>(pvtinfo);
 
        typedef void (*cxa_throw_fn)(void *, std::type_info *, void (*)(void *)) __attribute__((noreturn));
        static cxa_throw_fn real_cxa_throw;
@@ -120,7 +120,7 @@ void __cxa_throw(void *obj, TYPEINFO_TYPE *pvtinfo, void (*dest)(void *))
 
 #ifndef NO_CAST_EXCEPTION
        void *uex = cast_exception(obj, tinfo, &typeid(user_error));
-       boost::exception *ex = reinterpret_cast<boost::exception *>(cast_exception(obj, tinfo, &typeid(boost::exception)));
+       auto *ex = reinterpret_cast<boost::exception *>(cast_exception(obj, tinfo, &typeid(boost::exception)));
 
        if (!uex) {
 #endif /* NO_CAST_EXCEPTION */
@@ -171,14 +171,14 @@ String icinga::DiagnosticInformation(const std::exception& ex, bool verbose, Sta
 
        String message = ex.what();
 
-       const ValidationError *vex = dynamic_cast<const ValidationError *>(&ex);
+       const auto *vex = dynamic_cast<const ValidationError *>(&ex);
 
        if (message.IsEmpty())
                result << boost::diagnostic_information(ex) << "\n";
        else
                result << "Error: " << message << "\n";
 
-       const ScriptError *dex = dynamic_cast<const ScriptError *>(&ex);
+       const auto *dex = dynamic_cast<const ScriptError *>(&ex);
 
        if (dex && !dex->GetDebugInfo().Path.IsEmpty())
                ShowCodeLocation(result, dex->GetDebugInfo());
@@ -223,8 +223,8 @@ String icinga::DiagnosticInformation(const std::exception& ex, bool verbose, Sta
                        ShowCodeLocation(result, di);
        }
 
-       const user_error *uex = dynamic_cast<const user_error *>(&ex);
-       const posix_error *pex = dynamic_cast<const posix_error *>(&ex);
+       const auto *uex = dynamic_cast<const user_error *>(&ex);
+       const auto *pex = dynamic_cast<const posix_error *>(&ex);
 
        if (!uex && !pex && verbose) {
                const StackTrace *st = boost::get_error_info<StackTraceErrorInfo>(ex);
index b5a3fa0faa736e808c2f1d02b4bbc4ffa8c39581..e4912ce78725650ac6d5711ecf7762f6a52e620a 100644 (file)
@@ -51,7 +51,7 @@ void FIFO::ResizeBuffer(size_t newSize, bool decrease)
        if (newSize == m_AllocSize)
                return;
 
-       char *newBuffer = static_cast<char *>(realloc(m_Buffer, newSize));
+       auto *newBuffer = static_cast<char *>(realloc(m_Buffer, newSize));
 
        if (!newBuffer)
                BOOST_THROW_EXCEPTION(std::bad_alloc());
index 1047290cef244534e8ae2657735f818ef3e2e242..3216ae1ec6cc24d3382b4e47a6c8c69d35d82a23 100644 (file)
@@ -55,7 +55,7 @@ void FileLogger::Start(bool runtimeCreated)
 
 void FileLogger::ReopenLogFile()
 {
-       std::ofstream *stream = new std::ofstream();
+       auto *stream = new std::ofstream();
 
        String path = GetPath();
 
index 505d0bea22f090b46459850539928faa5f97c91d..0f4f5453ef31088888a267f2eb0fa8a1c5391b06 100644 (file)
@@ -205,7 +205,7 @@ private:
 
 static int DecodeNull(void *ctx)
 {
-       JsonContext *context = static_cast<JsonContext *>(ctx);
+       auto *context = static_cast<JsonContext *>(ctx);
 
        try {
                context->AddValue(Empty);
@@ -219,7 +219,7 @@ static int DecodeNull(void *ctx)
 
 static int DecodeBoolean(void *ctx, int value)
 {
-       JsonContext *context = static_cast<JsonContext *>(ctx);
+       auto *context = static_cast<JsonContext *>(ctx);
 
        try {
                context->AddValue(static_cast<bool>(value));
@@ -233,7 +233,7 @@ static int DecodeBoolean(void *ctx, int value)
 
 static int DecodeNumber(void *ctx, const char *str, yajl_size len)
 {
-       JsonContext *context = static_cast<JsonContext *>(ctx);
+       auto *context = static_cast<JsonContext *>(ctx);
 
        try {
                String jstr = String(str, str + len);
@@ -248,7 +248,7 @@ static int DecodeNumber(void *ctx, const char *str, yajl_size len)
 
 static int DecodeString(void *ctx, const unsigned char *str, yajl_size len)
 {
-       JsonContext *context = static_cast<JsonContext *>(ctx);
+       auto *context = static_cast<JsonContext *>(ctx);
 
        try {
                context->AddValue(String(str, str + len));
@@ -262,7 +262,7 @@ static int DecodeString(void *ctx, const unsigned char *str, yajl_size len)
 
 static int DecodeStartMap(void *ctx)
 {
-       JsonContext *context = static_cast<JsonContext *>(ctx);
+       auto *context = static_cast<JsonContext *>(ctx);
 
        try {
                context->Push(new Dictionary());
@@ -276,7 +276,7 @@ static int DecodeStartMap(void *ctx)
 
 static int DecodeEndMapOrArray(void *ctx)
 {
-       JsonContext *context = static_cast<JsonContext *>(ctx);
+       auto *context = static_cast<JsonContext *>(ctx);
 
        try {
                context->AddValue(context->Pop().EValue);
@@ -290,7 +290,7 @@ static int DecodeEndMapOrArray(void *ctx)
 
 static int DecodeStartArray(void *ctx)
 {
-       JsonContext *context = static_cast<JsonContext *>(ctx);
+       auto *context = static_cast<JsonContext *>(ctx);
 
        try {
                context->Push(new Array());
index a156820253fc314de234a48024ca4515feaf658b..a1b4a8ae65d2faac84415db295c2f0c73aeac1d1 100644 (file)
@@ -62,7 +62,7 @@ void ObjectLock::LockMutex(const Object *object)
        while (likely(!__sync_bool_compare_and_swap(&object->m_Mutex, I2MUTEX_UNLOCKED, I2MUTEX_LOCKED))) {
 #endif /* _WIN32 */
                if (likely(object->m_Mutex > I2MUTEX_LOCKED)) {
-                       boost::recursive_mutex *mtx = reinterpret_cast<boost::recursive_mutex *>(object->m_Mutex);
+                       auto *mtx = reinterpret_cast<boost::recursive_mutex *>(object->m_Mutex);
                        mtx->lock();
 
                        return;
@@ -72,7 +72,7 @@ void ObjectLock::LockMutex(const Object *object)
                it++;
        }
 
-       boost::recursive_mutex *mtx = new boost::recursive_mutex();
+       auto *mtx = new boost::recursive_mutex();
        mtx->lock();
 #ifdef _WIN32
 #      ifdef _WIN64
index c9cced61020ec19645542f0a5fd291cc5790c827..fbd7d19288d0d5748ff3f7f608166a3827f240c0 100644 (file)
@@ -93,14 +93,14 @@ static Value ProcessSpawnImpl(struct msghdr *msgh, const Dictionary::Ptr& reques
                return Empty;
        }
 
-       int *fds = (int *)CMSG_DATA(cmsg);
+       auto *fds = (int *)CMSG_DATA(cmsg);
 
        Array::Ptr arguments = request->Get("arguments");
        Dictionary::Ptr extraEnvironment = request->Get("extraEnvironment");
        bool adjustPriority = request->Get("adjustPriority");
 
        // build argv
-       char **argv = new char *[arguments->GetLength() + 1];
+       auto **argv = new char *[arguments->GetLength() + 1];
 
        for (unsigned int i = 0; i < arguments->GetLength(); i++) {
                String arg = arguments->Get(i);
@@ -116,7 +116,7 @@ static Value ProcessSpawnImpl(struct msghdr *msgh, const Dictionary::Ptr& reques
        while (environ[envc])
                envc++;
 
-       char **envp = new char *[envc + (extraEnvironment ? extraEnvironment->GetLength() : 0) + 2];
+       auto **envp = new char *[envc + (extraEnvironment ? extraEnvironment->GetLength() : 0) + 2];
 
        for (int i = 0; i < envc; i++)
                envp[i] = strdup(environ[i]);
@@ -281,7 +281,7 @@ static void ProcessHandler()
                        break;
                }
 
-               char *mbuf = new char[length];
+               auto *mbuf = new char[length];
 
                size_t count = 0;
                while (count < length) {
index c9521dc7fc77f75fd06f4e95788086ffd9e53e60..6dd27b4647343e2dba6f66a1fed26daa52126135 100644 (file)
@@ -310,7 +310,7 @@ Array::Ptr ScriptUtils::Intersection(const std::vector<Value>& arguments)
                Array::SizeType len;
                {
                        ObjectLock olock(arr1), xlock(arr2), ylock(result);
-                       Array::Iterator it = std::set_intersection(arr1->Begin(), arr1->End(), arr2->Begin(), arr2->End(), result->Begin());
+                       auto it = std::set_intersection(arr1->Begin(), arr1->End(), arr2->Begin(), arr2->End(), result->Begin());
                        len = it - result->Begin();
                }
                result->Resize(len);
@@ -334,7 +334,7 @@ void ScriptUtils::Log(const std::vector<Value>& arguments)
                facility = "config";
                message = arguments[0];
        } else {
-               int sval = static_cast<int>(arguments[0]);
+               auto sval = static_cast<int>(arguments[0]);
                severity = static_cast<LogSeverity>(sval);
                facility = arguments[1];
                message = arguments[2];
@@ -410,7 +410,7 @@ ConfigObject::Ptr ScriptUtils::GetObject(const Value& vtype, const String& name)
        else
                ptype = Type::GetByName(vtype);
 
-       ConfigType *ctype = dynamic_cast<ConfigType *>(ptype.get());
+       auto *ctype = dynamic_cast<ConfigType *>(ptype.get());
 
        if (!ctype)
                return nullptr;
@@ -423,7 +423,7 @@ Array::Ptr ScriptUtils::GetObjects(const Type::Ptr& type)
        if (!type)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid type: Must not be null"));
 
-       ConfigType *ctype = dynamic_cast<ConfigType *>(type.get());
+       auto *ctype = dynamic_cast<ConfigType *>(type.get());
 
        if (!ctype)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid type: Type must inherit from 'ConfigObject'"));
index cced491dd1bbd782b5e5bb4aa53352d9413aecf6..029c9b446f960a26b975d527858f41b2748062e6 100644 (file)
@@ -89,8 +89,8 @@ TlsStream::~TlsStream()
 
 int TlsStream::ValidateCertificate(int preverify_ok, X509_STORE_CTX *ctx)
 {
-       SSL *ssl = static_cast<SSL *>(X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx()));
-       TlsStream *stream = static_cast<TlsStream *>(SSL_get_ex_data(ssl, m_SSLIndex));
+       auto *ssl = static_cast<SSL *>(X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx()));
+       auto *stream = static_cast<TlsStream *>(SSL_get_ex_data(ssl, m_SSLIndex));
 
        if (!preverify_ok) {
                stream->m_VerifyOK = false;
index 9529919ac203317ad4db97434b2485e689478dd3..4746d8e83235beba8d5da15c1a6d87b096764828 100644 (file)
@@ -737,7 +737,7 @@ String SHA256(const String& s)
 
 String RandomString(int length)
 {
-       unsigned char *bytes = new unsigned char[length];
+       auto *bytes = new unsigned char[length];
 
        if (!RAND_bytes(bytes, length)) {
                delete [] bytes;
@@ -751,7 +751,7 @@ String RandomString(int length)
                        << errinfo_openssl_error(ERR_peek_error()));
        }
 
-       char *output = new char[length * 2 + 1];
+       auto *output = new char[length * 2 + 1];
        for (int i = 0; i < length; i++)
                sprintf(output + 2 * i, "%02x", bytes[i]);
 
index f80b42933f7561de11e515e41cfcc39fa80cfe7b..adf5a7bcde22091b6cd4edfb343e5ecfe9ef22c8 100644 (file)
@@ -1012,7 +1012,7 @@ String Utility::FormatDuration(double duration)
 String Utility::FormatDateTime(const char *format, double ts)
 {
        char timestamp[128];
-       time_t tempts = (time_t)ts; /* We don't handle sub-second timestamps here just yet. */
+       auto tempts = (time_t)ts; /* We don't handle sub-second timestamps here just yet. */
        tm tmthen;
 
 #ifdef _MSC_VER
index ab848da0e931002d0af82ff878276f4a9dd7822b..bff889ec875223e36062cdb27cc14ee8b94e1b49 100644 (file)
@@ -114,7 +114,7 @@ public:
                if (!IsObject())
                        BOOST_THROW_EXCEPTION(std::runtime_error("Cannot convert value of type '" + GetTypeName() + "' to an object."));
 
-               const Object::Ptr& object = Get<Object::Ptr>();
+               const auto& object = Get<Object::Ptr>();
 
                ASSERT(object);
 
index e86454225316fb9c9c47b1d59d072edd0fe67cdd..aabd9e41a4df28b5a9f50b78aa4fe5ac6e751dd8 100644 (file)
@@ -69,7 +69,7 @@ public:
 #endif /*_WIN32*/
                }
                else {
-                       std::ofstream *ofs = new std::ofstream();
+                       auto *ofs = new std::ofstream();
                        ofs->open(path.CStr(), std::ios::out | std::ios::trunc);
                        m_Stream = ofs;
                }
@@ -550,7 +550,7 @@ void TroubleshootCommand::CheckObjectFile(const String& objectfile, InfoLog& log
 
 bool TroubleshootCommand::PrintVarsFile(const String& path, const bool console) {
        if (!console) {
-               std::ofstream *ofs = new std::ofstream();
+               auto *ofs = new std::ofstream();
                ofs->open((path+"-vars").CStr(), std::ios::out | std::ios::trunc);
                if (!ofs->is_open())
                        return false;
index ddcbf1f86aabd852a223a1934a86b948efcab2aa..d618b6caab6257dfb7ada9db65f1bbfb3d715a67 100644 (file)
@@ -533,7 +533,7 @@ void CompatLogger::ReopenFile(bool rotate)
 
 void CompatLogger::ScheduleNextRotation()
 {
-       time_t now = (time_t)Utility::GetTime();
+       auto now = (time_t)Utility::GetTime();
        String method = GetRotationMethod();
 
        tm tmthen;
index 011ae68a2bf8ca80e8754dc95233ddcec7719d4f..e6596c601050be7df603abbbd34e335e11bd4df1 100644 (file)
@@ -39,7 +39,7 @@ void ConfigCompilerContext::OpenObjectsFile(const String& filename)
 {
        m_ObjectsPath = filename;
 
-       std::fstream *fp = new std::fstream();
+       auto *fp = new std::fstream();
        try {
                m_ObjectsTempFile = Utility::CreateTempFile(filename + ".XXXXXX", 0600, *fp);
        } catch (const std::exception& ex) {
index 6b30bc094154fbfef53897e7f8be679fda56df42..0bc70f50d742faa64a7d70f0f5502bf8e4036ec8 100644 (file)
@@ -231,7 +231,7 @@ ConfigObject::Ptr ConfigItem::Commit(bool discard)
 
        String name = item_name;
 
-       NameComposer *nc = dynamic_cast<NameComposer *>(type.get());
+       auto *nc = dynamic_cast<NameComposer *>(type.get());
 
        if (nc) {
                if (name.IsEmpty())
index 6d120a3ce5d89d72311365b84e74f9900277eb0f..b017daafec4c4596848b8d02cdc763d6b2f279af 100644 (file)
@@ -96,7 +96,7 @@ ConfigItem::Ptr ConfigItemBuilder::Compile()
                BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), m_DebugInfo));
        }
 
-       ConfigType *ctype = dynamic_cast<ConfigType *>(m_Type.get());
+       auto *ctype = dynamic_cast<ConfigType *>(m_Type.get());
 
        if (!ctype) {
                std::ostringstream msgbuf;
@@ -133,7 +133,7 @@ ConfigItem::Ptr ConfigItemBuilder::Compile()
        }
 #endif /* I2_DEBUG */
 
-       DictExpression *dexpr = new DictExpression(std::move(m_Expressions), m_DebugInfo);
+       auto *dexpr = new DictExpression(std::move(m_Expressions), m_DebugInfo);
        dexpr->MakeInline();
        exprs.emplace_back(dexpr);
 
index bb7fe22486904e806ef1b9c7b7da155a93d729b3..f355509e5497cd71150ec41df4b561db2c683442 100644 (file)
@@ -685,7 +685,7 @@ bool IndexerExpression::GetReference(ScriptFrame& frame, bool init_dict, Value *
 
 void icinga::BindToScope(std::unique_ptr<Expression>& expr, ScopeSpecifier scopeSpec)
 {
-       DictExpression *dexpr = dynamic_cast<DictExpression *>(expr.get());
+       auto *dexpr = dynamic_cast<DictExpression *>(expr.get());
 
        if (dexpr) {
                for (auto& expr : dexpr->m_Expressions)
@@ -694,7 +694,7 @@ void icinga::BindToScope(std::unique_ptr<Expression>& expr, ScopeSpecifier scope
                return;
        }
 
-       SetExpression *aexpr = dynamic_cast<SetExpression *>(expr.get());
+       auto *aexpr = dynamic_cast<SetExpression *>(expr.get());
 
        if (aexpr) {
                BindToScope(aexpr->m_Operand1, scopeSpec);
@@ -702,21 +702,21 @@ void icinga::BindToScope(std::unique_ptr<Expression>& expr, ScopeSpecifier scope
                return;
        }
 
-       IndexerExpression *iexpr = dynamic_cast<IndexerExpression *>(expr.get());
+       auto *iexpr = dynamic_cast<IndexerExpression *>(expr.get());
 
        if (iexpr) {
                BindToScope(iexpr->m_Operand1, scopeSpec);
                return;
        }
 
-       LiteralExpression *lexpr = dynamic_cast<LiteralExpression *>(expr.get());
+       auto *lexpr = dynamic_cast<LiteralExpression *>(expr.get());
 
        if (lexpr && lexpr->GetValue().IsString()) {
                std::unique_ptr<Expression> scope{new GetScopeExpression(scopeSpec)};
                expr.reset(new IndexerExpression(std::move(scope), std::move(expr), lexpr->GetDebugInfo()));
        }
 
-       VariableExpression *vexpr = dynamic_cast<VariableExpression *>(expr.get());
+       auto *vexpr = dynamic_cast<VariableExpression *>(expr.get());
 
        if (vexpr) {
                std::unique_ptr<Expression> scope{new GetScopeExpression(scopeSpec)};
index 13bac82b7f447190330bdd0ab3aac0ae678549ad..4d8dd0e55f4942869b467e42692ea3aaf03670da 100644 (file)
@@ -151,7 +151,7 @@ public:
                String checkName = name;
 
                if (!abstract) {
-                       NameComposer *nc = dynamic_cast<NameComposer *>(type.get());
+                       auto *nc = dynamic_cast<NameComposer *>(type.get());
 
                        if (nc)
                                checkName = nc->MakeName(name, nullptr);
index ddbf76ff36643ea63c069b5632862527327f06ab..215846f2ffa07d2f7fbaa9677704cf735ad610b6 100644 (file)
@@ -206,7 +206,7 @@ void DbConnection::UpdateProgramStatus()
 
 void DbConnection::CleanUpHandler()
 {
-       long now = static_cast<long>(Utility::GetTime());
+       auto now = static_cast<long>(Utility::GetTime());
 
        struct {
                String name;
@@ -426,7 +426,7 @@ void DbConnection::UpdateObject(const ConfigObject::Ptr& object)
 void DbConnection::UpdateAllObjects()
 {
        for (const Type::Ptr& type : Type::GetAllTypes()) {
-               ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
+               auto *dtype = dynamic_cast<ConfigType *>(type.get());
 
                if (!dtype)
                        continue;
index 93d47fecee2549bcb6e32e6275c5baf7fb2a71ca..f53741a600340aabe6481e55c806cb818d13bf12 100644 (file)
@@ -83,7 +83,7 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
                return;
        }
 
-       ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
+       auto *dtype = dynamic_cast<ConfigType *>(type.get());
        VERIFY(dtype);
 
        DbConnection::Ptr conn = static_pointer_cast<DbConnection>(dtype->GetObject(idoName));
index af337e660ce5934a920c1c5e1fe6cb0003cae10a..fbc9ede9935f305c3e13cad1906c825df667d61e 100644 (file)
@@ -671,7 +671,7 @@ String IdoMysqlConnection::Escape(const String& s)
        String utf8s = Utility::ValidateUTF8(s);
 
        size_t length = utf8s.GetLength();
-       char *to = new char[utf8s.GetLength() * 2 + 1];
+       auto *to = new char[utf8s.GetLength() * 2 + 1];
 
        m_Mysql->real_escape_string(&m_Connection, to, utf8s.CStr(), length);
 
@@ -838,7 +838,7 @@ bool IdoMysqlConnection::FieldToEscapedString(const String& key, const Value& va
        } else if (DbValue::IsTimestampNow(value)) {
                *result = "NOW()";
        } else if (DbValue::IsObjectInsertID(value)) {
-               long id = static_cast<long>(rawvalue);
+               auto id = static_cast<long>(rawvalue);
 
                if (id <= 0)
                        return false;
index 2a896285362674ccf8cc17518eaa7ea49e579c97..63d896aa34865712b6c50487dc09bc2f3414e627 100644 (file)
@@ -515,7 +515,7 @@ String IdoPgsqlConnection::Escape(const String& s)
        String utf8s = Utility::ValidateUTF8(s);
 
        size_t length = utf8s.GetLength();
-       char *to = new char[utf8s.GetLength() * 2 + 1];
+       auto *to = new char[utf8s.GetLength() * 2 + 1];
 
        m_Pgsql->escapeStringConn(m_Connection, to, utf8s.CStr(), length, nullptr);
 
@@ -660,7 +660,7 @@ bool IdoPgsqlConnection::FieldToEscapedString(const String& key, const Value& va
        } else if (DbValue::IsTimestampNow(value)) {
                *result = "NOW()";
        } else if (DbValue::IsObjectInsertID(value)) {
-               long id = static_cast<long>(rawvalue);
+               auto id = static_cast<long>(rawvalue);
 
                if (id <= 0)
                        return false;
index ffad0cba8a1cb6e35b62bd3939a38b41c824316d..2b6b50f911542d2e9782b60dc22c09fe3537ccf0 100644 (file)
@@ -74,7 +74,7 @@ bool Checkable::IsReachable(DependencyType dt, Dependency::Ptr *failedDependency
        }
 
        /* implicit dependency on host if this is a service */
-       const Service *service = dynamic_cast<const Service *>(this);
+       const auto *service = dynamic_cast<const Service *>(this);
        if (service && (dt == DependencyState || dt == DependencyNotification)) {
                Host::Ptr host = service->GetHost();
 
index 8494e2c89b9e7dbac3c32d83bdd09f64db7c39ee..31532f73a58046968f887fd33da449d267d052ed 100644 (file)
@@ -85,7 +85,7 @@ void Checkable::AddGroup(const String& name)
        boost::mutex::scoped_lock lock(m_CheckableMutex);
 
        Array::Ptr groups;
-       Host *host = dynamic_cast<Host *>(this);
+       auto *host = dynamic_cast<Host *>(this);
 
        if (host)
                groups = host->GetGroups();
@@ -103,7 +103,7 @@ void Checkable::AddGroup(const String& name)
 
 AcknowledgementType Checkable::GetAcknowledgement()
 {
-       AcknowledgementType avalue = static_cast<AcknowledgementType>(GetAcknowledgementRaw());
+       auto avalue = static_cast<AcknowledgementType>(GetAcknowledgementRaw());
 
        if (avalue != AcknowledgementNone) {
                double expiry = GetAcknowledgementExpiry();
index 14c5e6000f7f08ff2181614d8bd0cff09374d4b6..c5bc72e1c39ec2cc542f4e035b40113e0a018dee 100644 (file)
@@ -121,7 +121,7 @@ bool MacroProcessor::ResolveMacro(const String& macro, const ResolverList& resol
                        }
                }
 
-               MacroResolver *mresolver = dynamic_cast<MacroResolver *>(resolver.second.get());
+               auto *mresolver = dynamic_cast<MacroResolver *>(resolver.second.get());
 
                if (mresolver && mresolver->ResolveMacro(boost::algorithm::join(tokens, "."), cr, result))
                        return true;
index c7f9f97714971816479fed246a99793f26a34334..135e15e99878562aef0aec2d0494899ff6413bbd 100644 (file)
@@ -132,25 +132,25 @@ Value StatusTable::ConnectionsRateAccessor(const Value&)
 
 Value StatusTable::HostChecksAccessor(const Value&)
 {
-       long timespan = static_cast<long>(Utility::GetTime() - Application::GetStartTime());
+       auto timespan = static_cast<long>(Utility::GetTime() - Application::GetStartTime());
        return CIB::GetActiveHostChecksStatistics(timespan);
 }
 
 Value StatusTable::HostChecksRateAccessor(const Value&)
 {
-       long timespan = static_cast<long>(Utility::GetTime() - Application::GetStartTime());
+       auto timespan = static_cast<long>(Utility::GetTime() - Application::GetStartTime());
        return (CIB::GetActiveHostChecksStatistics(timespan) / (Utility::GetTime() - Application::GetStartTime()));
 }
 
 Value StatusTable::ServiceChecksAccessor(const Value&)
 {
-       long timespan = static_cast<long>(Utility::GetTime() - Application::GetStartTime());
+       auto timespan = static_cast<long>(Utility::GetTime() - Application::GetStartTime());
        return CIB::GetActiveServiceChecksStatistics(timespan);
 }
 
 Value StatusTable::ServiceChecksRateAccessor(const Value&)
 {
-       long timespan = static_cast<long>(Utility::GetTime() - Application::GetStartTime());
+       auto timespan = static_cast<long>(Utility::GetTime() - Application::GetStartTime());
        return (CIB::GetActiveServiceChecksStatistics(timespan) / (Utility::GetTime() - Application::GetStartTime()));
 }
 
index cbb0fae3e121e1afeacb20a0ed451581a1e9e56d..4fa3ea71fcefd153b6bc5f2917ee18c7bc5b8bf1 100644 (file)
@@ -41,7 +41,7 @@ void PluginNotificationTask::ScriptFunc(const Notification::Ptr& notification,
 {
        NotificationCommand::Ptr commandObj = notification->GetCommand();
 
-       NotificationType type = static_cast<NotificationType>(itype);
+       auto type = static_cast<NotificationType>(itype);
 
        Checkable::Ptr checkable = notification->GetCheckable();
 
index 4711cd9ac57b6566039bccf51deec59560bd16c2..c5e689f27306633ac0b50f904d3f835be88d31f4 100644 (file)
@@ -592,7 +592,7 @@ String ElasticsearchWriter::FormatTimestamp(double ts)
         * https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html
         * https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html
         */
-       int milliSeconds = static_cast<int>((ts - static_cast<int>(ts)) * 1000);
+       auto milliSeconds = static_cast<int>((ts - static_cast<int>(ts)) * 1000);
 
        return Utility::FormatDateTime("%Y-%m-%dT%H:%M:%S", ts) + "." + Convert::ToString(milliSeconds) + Utility::FormatDateTime("%z", ts);
 }
index e1f5eb5baf969b146490829376ebb1eff76d6b9c..8107c971ab611fd8ea7e44be8eef3da526946c13 100644 (file)
@@ -98,7 +98,7 @@ Value ApiListener::ConfigUpdateObjectAPIHandler(const MessageOrigin::Ptr& origin
        double objVersion = params->Get("version");
 
        Type::Ptr ptype = Type::GetByName(objType);
-       ConfigType *ctype = dynamic_cast<ConfigType *>(ptype.get());
+       auto *ctype = dynamic_cast<ConfigType *>(ptype.get());
 
        if (!ctype) {
                Log(LogCritical, "ApiListener")
@@ -234,7 +234,7 @@ Value ApiListener::ConfigDeleteObjectAPIHandler(const MessageOrigin::Ptr& origin
 
        /* delete the object */
        Type::Ptr ptype = Type::GetByName(params->Get("type"));
-       ConfigType *ctype = dynamic_cast<ConfigType *>(ptype.get());
+       auto *ctype = dynamic_cast<ConfigType *>(ptype.get());
 
        if (!ctype) {
                Log(LogCritical, "ApiListener")
@@ -414,7 +414,7 @@ void ApiListener::SendRuntimeConfigObjects(const JsonRpcConnection::Ptr& aclient
                << "Syncing runtime objects to endpoint '" << endpoint->GetName() << "'.";
 
        for (const Type::Ptr& type : Type::GetAllTypes()) {
-               ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
+               auto *dtype = dynamic_cast<ConfigType *>(type.get());
 
                if (!dtype)
                        continue;
index 0bf2500508a2414a4f18d0cdbb9e1c5ce0290c92..a3051b8748d05e292d4979eab65be8ba0e960cac 100644 (file)
@@ -992,7 +992,7 @@ void ApiListener::OpenLogFile()
 
        Utility::MkDirP(Utility::DirName(path), 0750);
 
-       std::fstream *fp = new std::fstream(path.CStr(), std::fstream::out | std::ofstream::app);
+       auto *fp = new std::fstream(path.CStr(), std::fstream::out | std::ofstream::app);
 
        if (!fp->good()) {
                Log(LogWarning, "ApiListener")
@@ -1102,7 +1102,7 @@ void ApiListener::ReplayLog(const JsonRpcConnection::Ptr& client)
                        Log(LogNotice, "ApiListener")
                                << "Replaying log: " << path;
 
-                       std::fstream *fp = new std::fstream(path.CStr(), std::fstream::in | std::fstream::binary);
+                       auto *fp = new std::fstream(path.CStr(), std::fstream::in | std::fstream::binary);
                        StdioStream::Ptr logStream = new StdioStream(fp, true);
 
                        String message;
index ecb24ea706b8a01241116983be3aea8b099fa017..0be53b1568865c64d89d1c8c188833237f788909 100644 (file)
@@ -58,7 +58,7 @@ void ApiListener::UpdateObjectAuthority()
        }
 
        for (const Type::Ptr& type : Type::GetAllTypes()) {
-               ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
+               auto *dtype = dynamic_cast<ConfigType *>(type.get());
 
                if (!dtype)
                        continue;
index 224c70fabfb66d2eb3cfb535d8ec6337b3e669e3..5cafca9bb5cf0ef01cd65d3847c4d29360158d75 100644 (file)
@@ -55,7 +55,7 @@ String ConfigObjectUtility::EscapeName(const String& name)
 String ConfigObjectUtility::CreateObjectConfig(const Type::Ptr& type, const String& fullName,
        bool ignoreOnError, const Array::Ptr& templates, const Dictionary::Ptr& attrs)
 {
-       NameComposer *nc = dynamic_cast<NameComposer *>(type.get());
+       auto *nc = dynamic_cast<NameComposer *>(type.get());
        Dictionary::Ptr nameParts;
        String name;
 
index 6decb564d6e514877de80b1708d59c77a5338afb..d0a846d628000d4c10f459de7e1294133416d5b1 100644 (file)
@@ -114,7 +114,7 @@ bool CreateObjectHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& r
                return true;
        }
 
-       ConfigType *ctype = dynamic_cast<ConfigType *>(type.get());
+       auto *ctype = dynamic_cast<ConfigType *>(type.get());
        ConfigObject::Ptr obj = ctype->GetObject(name);
 
        result1->Set("code", 200);
index 826e5e827a5fceb998e4f79e956d62eae4b75c01..c24152d5da7cdb3faf0a4f6b1172d63efdfd0a2b 100644 (file)
@@ -47,7 +47,7 @@ Type::Ptr FilterUtility::TypeFromPluralName(const String& pluralName)
 void ConfigObjectTargetProvider::FindTargets(const String& type, const std::function<void (const Value&)>& addTarget) const
 {
        Type::Ptr ptype = Type::GetByName(type);
-       ConfigType *ctype = dynamic_cast<ConfigType *>(ptype.get());
+       auto *ctype = dynamic_cast<ConfigType *>(ptype.get());
 
        if (ctype) {
                for (const ConfigObject::Ptr& object : ctype->GetObjects()) {
index f199e5aa366c63c484068d1ed17306461a5d60fd..86be0f510e0c84aab36a9dc7704ed4a01885b044 100644 (file)
@@ -91,7 +91,7 @@ BOOST_AUTO_TEST_CASE(remove)
 
        {
                ObjectLock olock(array);
-               Array::Iterator it = array->Begin();
+               auto it = array->Begin();
                array->Remove(it);
        }
 
index 466892dc7ebb8e63af13d1ce49a39f68f2bec1bd..92146c8791da01783d00e0d110092dbd9543190b 100644 (file)
@@ -133,7 +133,7 @@ BOOST_AUTO_TEST_CASE(remove)
        {
                ObjectLock olock(dictionary);
 
-               Dictionary::Iterator it = dictionary->Begin();
+               auto it = dictionary->Begin();
                dictionary->Remove(it);
        }
 
index dca909ae0fcf4ccfa4e98347bb397b0546bcbbeb..10069f91b5863030ee334b37ebdf138a94a36b12 100644 (file)
@@ -289,7 +289,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
                collisions = 0;
 
                for (const Field& field : klass.Fields) {
-                       int hash = static_cast<int>(SDBM(field.Name, hlen));
+                       auto hash = static_cast<int>(SDBM(field.Name, hlen));
                        jumptable[hash].push_back(std::make_pair(num, field.Name));
                        num++;
 
@@ -846,7 +846,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
 
                                if (field.Type.IsName || !field.TrackAccessor.empty()) {
                                        if (field.Name != "active") {
-                                               m_Impl << "\t" << "ConfigObject *dobj = dynamic_cast<ConfigObject *>(this);" << std::endl
+                                               m_Impl << "\t" << "auto *dobj = dynamic_cast<ConfigObject *>(this);" << std::endl
                                                        << "\t" << "if (!dobj || dobj->IsActive())" << std::endl
                                                        << "\t";
                                        }
@@ -1009,7 +1009,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
                                << "{" << std::endl;
 
                        if (field.Name != "active") {
-                               m_Impl << "\t" << "ConfigObject *dobj = dynamic_cast<ConfigObject *>(this);" << std::endl
+                               m_Impl << "\t" << "auto *dobj = dynamic_cast<ConfigObject *>(this);" << std::endl
                                        << "\t" << "if (!dobj || dobj->IsActive())" << std::endl
                                        << "\t";
                        }