From aa986f900eb11b71d0061b52a1dc5e75a8deea72 Mon Sep 17 00:00:00 2001 From: Julie Stalley Date: Tue, 31 Oct 2017 14:32:47 +0000 Subject: [PATCH] Return -1 when unable to get memory value --- .../plugins/common/memory/MemoryPlugin.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ibmras/monitoring/plugins/common/memory/MemoryPlugin.cpp b/src/ibmras/monitoring/plugins/common/memory/MemoryPlugin.cpp index 7395e72..7dd1eaf 100644 --- a/src/ibmras/monitoring/plugins/common/memory/MemoryPlugin.cpp +++ b/src/ibmras/monitoring/plugins/common/memory/MemoryPlugin.cpp @@ -512,9 +512,9 @@ int64 MemoryPlugin::getTotalPhysicalMemorySize() { num_pages = sysconf(_SC_PHYS_PAGES); if (pagesize == -1 || num_pages == -1) { - return 0; + return -1; } else { - return (int64) pagesize *num_pages; + return (int64) pagesize * num_pages; } /* * There is a bug in OSX Mavericks which may cause the compilation to fail @@ -528,9 +528,9 @@ int64 MemoryPlugin::getTotalPhysicalMemorySize() { int mib[2] = {CTL_HW, HW_MEMSIZE}; unsigned long physicalMemSize; size_t len = sizeof(physicalMemSize); - if(!sysctl(mib, 2, &physicalMemSize, &len, NULL, 0)) { + if (!sysctl(mib, 2, &physicalMemSize, &len, NULL, 0)) { return physicalMemSize; - }else { + } else { aCF.logMessage(debug, strerror(errno)); return -1; } @@ -538,9 +538,9 @@ int64 MemoryPlugin::getTotalPhysicalMemorySize() { int mib[2] = {CTL_HW, HW_PHYSMEM}; unsigned long physicalMemSize; size_t len = sizeof(physicalMemSize); - if(!sysctl(mib, 2, &physicalMemSize, &len, NULL, 0)) { + if (!sysctl(mib, 2, &physicalMemSize, &len, NULL, 0)) { return physicalMemSize; - }else { + } else { aCF.logMessage(debug, strerror(errno)); return -1; }