fixed compiler warnings
authorVictor Kirhenshtein <victor@netxms.org>
Fri, 10 Nov 2017 15:52:01 +0000 (17:52 +0200)
committerVictor Kirhenshtein <victor@netxms.org>
Fri, 10 Nov 2017 15:52:01 +0000 (17:52 +0200)
src/agent/core/policy.cpp
src/agent/core/session.cpp

index 0ebfaae..a7e27fa 100644 (file)
@@ -136,12 +136,12 @@ static UINT32 DeployConfig(AbstractCommSession *session, const uuid& guid, NXCPM
        fh = _topen(path, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, S_IRUSR | S_IWUSR);
        if (fh != -1)
        {
-               UINT32 size = msg->getFieldAsBinary(VID_CONFIG_FILE_DATA, NULL, 0);
+               size_t size = msg->getFieldAsBinary(VID_CONFIG_FILE_DATA, NULL, 0);
                BYTE *data = (BYTE *)malloc(size);
                if (data != NULL)
                {
                        msg->getFieldAsBinary(VID_CONFIG_FILE_DATA, data, size);
-                       if (_write(fh, data, size) == size)
+                       if (_write(fh, data, static_cast<unsigned int>(size)) == static_cast<int>(size))
                        {
                      session->debugPrintf(3, _T("Configuration file %s saved successfully"), path);
                                rcc = ERR_SUCCESS;
@@ -182,12 +182,12 @@ static UINT32 DeployLogParser(AbstractCommSession *session, const uuid& guid, NX
        fh = _topen(path, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, S_IRUSR | S_IWUSR);
        if (fh != -1)
        {
-               UINT32 size = msg->getFieldAsBinary(VID_CONFIG_FILE_DATA, NULL, 0);
+               size_t size = msg->getFieldAsBinary(VID_CONFIG_FILE_DATA, NULL, 0);
                BYTE *data = (BYTE *)malloc(size);
                if (data != NULL)
                {
                        msg->getFieldAsBinary(VID_CONFIG_FILE_DATA, data, size);
-                       if (_write(fh, data, size) == size)
+                       if (_write(fh, data, static_cast<unsigned int>(size)) == static_cast<int>(size))
                        {
                      session->debugPrintf(3, _T("Log parser file %s saved successfully"), path);
                                rcc = ERR_SUCCESS;
index 930a7cc..dbcac4e 100644 (file)
@@ -1005,16 +1005,12 @@ void CommSession::updateConfig(NXCPMessage *pRequest, NXCPMessage *pMsg)
 {
    if (m_masterServer)
    {
-      BYTE *pConfig;
-      int hFile;
-      UINT32 size;
-
       if (pRequest->isFieldExist(VID_CONFIG_FILE))
       {
-         size = pRequest->getFieldAsBinary(VID_CONFIG_FILE, NULL, 0);
-         pConfig = (BYTE *)malloc(size);
+         size_t size = pRequest->getFieldAsBinary(VID_CONFIG_FILE, NULL, 0);
+         BYTE *pConfig = (BYTE *)malloc(size);
          pRequest->getFieldAsBinary(VID_CONFIG_FILE, pConfig, size);
-         hFile = _topen(g_szConfigFile, O_CREAT | O_TRUNC | O_WRONLY, 0644);
+         int hFile = _topen(g_szConfigFile, O_CREAT | O_TRUNC | O_WRONLY, 0644);
          if (hFile != -1)
          {
             if (size > 0)
@@ -1027,7 +1023,7 @@ void CommSession::updateConfig(NXCPMessage *pRequest, NXCPMessage *pMsg)
                                                        i--;
                   }
             }
-            if (_write(hFile, pConfig, size) == size)
+            if (_write(hFile, pConfig, static_cast<unsigned int>(size)) == size)
                pMsg->setField(VID_RCC, ERR_SUCCESS);
             else
                pMsg->setField(VID_RCC, ERR_IO_FAILURE);