dboxinfo: avoid unnecessary 64bit math

The kernel uses 'unsigned long' for those values anyway,
so there is no need for 'long long' in userspace.


Origin commit data
------------------
Commit: 77c07386e6
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2014-01-05 (Sun, 05 Jan 2014)
This commit is contained in:
Stefan Seyfried
2014-01-05 19:01:59 +01:00
parent 9f88583a81
commit bc811dabe8

View File

@@ -230,15 +230,14 @@ void CDBoxInfoWidget::paint()
#define MEMINFO_RAM 0
#define MEMINFO_SWAP 1
#define MEMINFO_ROWS 2
unsigned long long memstat[MEMINFO_ROWS][MEMINFO_COLUMNS] = { { 0, 0, 0 }, { 0, 0, 0 } }; // total, used, free
unsigned long memstat[MEMINFO_ROWS][MEMINFO_COLUMNS] = { { 0, 0, 0 }, { 0, 0, 0 } }; // total, used, free
const char *memtype[MEMINFO_ROWS] = { "RAM", "Swap" };
FILE *procmeminfo = fopen("/proc/meminfo", "r");
if (procmeminfo) {
char buf[80], a[80];
long long unsigned v;
unsigned long v;
while (fgets(buf, sizeof(buf), procmeminfo)) {
if (2 == sscanf(buf, "%[^:]: %llu", a, &v)) {
v <<= 10;
if (2 == sscanf(buf, "%[^:]: %lu", a, &v)) {
if (!strcasecmp(a, "MemTotal"))
memstat[MEMINFO_RAM][MEMINFO_TOTAL] += v;
else if (!strcasecmp(a, "MemFree"))
@@ -468,13 +467,13 @@ void CDBoxInfoWidget::paint()
tmp = memtype[row];
break;
case 1:
tmp = bytes2string(memstat[row][MEMINFO_TOTAL]);
tmp = bytes2string(memstat[row][MEMINFO_TOTAL] << 10);
break;
case 2:
tmp = bytes2string(memstat[row][MEMINFO_USED]);
tmp = bytes2string(memstat[row][MEMINFO_USED] << 10);
break;
case 3:
tmp = bytes2string(memstat[row][MEMINFO_FREE]);
tmp = bytes2string(memstat[row][MEMINFO_FREE] << 10);
break;
case 4:
tmp = to_string(memstat[row][MEMINFO_TOTAL] ? (memstat[row][MEMINFO_USED] * 100) / memstat[row][MEMINFO_TOTAL] : 0) + "%";