From 1b475f8666accd02f2705aecf163c741b193267d Mon Sep 17 00:00:00 2001 From: snow Date: Sat, 30 May 2020 20:06:38 -0700 Subject: [PATCH] cputnik: use %lld instead of %Ld when getting meminfo --- cputnik/src/Makefile | 4 ++-- cputnik/src/cputnik.c | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cputnik/src/Makefile b/cputnik/src/Makefile index e610131..5121295 100644 --- a/cputnik/src/Makefile +++ b/cputnik/src/Makefile @@ -1,7 +1,7 @@ CFLAGS = -Wall -Os -INCS = -I/usr/X11R6/include/X11 -LIBS = -L/usr/X11R6/lib -lXpm -lXext -lX11 +INCS = -I/usr/X11R7/include/ +LIBS = -L/usr/X11R7/lib -lXpm -lXext -lX11 -R/usr/X11R7/lib INSTALL_PREFIX = /usr/local diff --git a/cputnik/src/cputnik.c b/cputnik/src/cputnik.c index 9a233b3..70d79b7 100644 --- a/cputnik/src/cputnik.c +++ b/cputnik/src/cputnik.c @@ -41,15 +41,17 @@ char temp[BUFFER_SIZE]; while(fscanf(fp_memory, "%s", temp)!=EOF) { if(!strncmp(temp,"MemTotal:", 9)) - fscanf(fp_memory, "%Ld", &m_total); + fscanf(fp_memory, "%lld", &m_total); if(!strncmp(temp,"MemFree:", 8)) - fscanf(fp_memory, "%Ld", &m_free); + fscanf(fp_memory, "%lld", &m_free); if(!strncmp(temp,"Cached:", 7)) - fscanf(fp_memory, "%Ld", &m_cached); + fscanf(fp_memory, "%lld", &m_cached); } + printf("m_total: %ld, m_free: %ld, m_cached: %ld\n", m_total, m_free, m_cached); + *free = (int)(((float)(m_total - m_free - m_cached) / m_total) * 100.0); }