mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-27 17:18:33 +00:00
fix reported memory var overflow by using unsigned long long
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@775 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
358abc96c0
commit
d9cc831fdd
@ -5,6 +5,8 @@
|
|||||||
* Add new timed thread abstraction file.
|
* Add new timed thread abstraction file.
|
||||||
* Convert thread activity to timed threads, including
|
* Convert thread activity to timed threads, including
|
||||||
texeci, imap, pop3, audacious.
|
texeci, imap, pop3, audacious.
|
||||||
|
* Change memory vars from unsigned long to unsigned long long
|
||||||
|
to fix reported overflow, e.g. swapmax >= 4Gb.
|
||||||
|
|
||||||
2006-11-13
|
2006-11-13
|
||||||
* Use pthread_cond_timedwait() instead of sleep() in audacious
|
* Use pthread_cond_timedwait() instead of sleep() in audacious
|
||||||
|
@ -3991,12 +3991,12 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
|
|||||||
OBJ(memperc) {
|
OBJ(memperc) {
|
||||||
if (cur->memmax) {
|
if (cur->memmax) {
|
||||||
if (!use_spacer)
|
if (!use_spacer)
|
||||||
snprintf(p, p_max_size, "%*lu",
|
snprintf(p, p_max_size, "%*Lu",
|
||||||
pad_percents,
|
pad_percents,
|
||||||
(cur->mem * 100) /
|
(cur->mem * 100) /
|
||||||
(cur->memmax));
|
(cur->memmax));
|
||||||
else
|
else
|
||||||
snprintf(p, 4, "%*lu ",
|
snprintf(p, 4, "%*Lu ",
|
||||||
pad_percents,
|
pad_percents,
|
||||||
(cur->mem * 100) /
|
(cur->mem * 100) /
|
||||||
(cur->memmax));
|
(cur->memmax));
|
||||||
@ -4099,13 +4099,13 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
|
|||||||
strncpy(p, "No swap", 255);
|
strncpy(p, "No swap", 255);
|
||||||
} else {
|
} else {
|
||||||
if (!use_spacer)
|
if (!use_spacer)
|
||||||
snprintf(p, 255, "%*lu",
|
snprintf(p, 255, "%*Lu",
|
||||||
pad_percents,
|
pad_percents,
|
||||||
(cur->swap *
|
(cur->swap *
|
||||||
100) /
|
100) /
|
||||||
cur->swapmax);
|
cur->swapmax);
|
||||||
else
|
else
|
||||||
snprintf(p, 4, "%*lu ",
|
snprintf(p, 4, "%*Lu ",
|
||||||
pad_percents,
|
pad_percents,
|
||||||
(cur->swap *
|
(cur->swap *
|
||||||
100) /
|
100) /
|
||||||
|
@ -242,8 +242,8 @@ struct information {
|
|||||||
double uptime;
|
double uptime;
|
||||||
|
|
||||||
/* memory information in kilobytes */
|
/* memory information in kilobytes */
|
||||||
unsigned long mem, memmax, swap, swapmax;
|
unsigned long long mem, memmax, swap, swapmax;
|
||||||
unsigned long bufmem, buffers, cached;
|
unsigned long long bufmem, buffers, cached;
|
||||||
|
|
||||||
unsigned short procs;
|
unsigned short procs;
|
||||||
unsigned short run_procs;
|
unsigned short run_procs;
|
||||||
|
12
src/linux.c
12
src/linux.c
@ -113,17 +113,17 @@ void update_meminfo()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if (strncmp(buf, "MemTotal:", 9) == 0) {
|
if (strncmp(buf, "MemTotal:", 9) == 0) {
|
||||||
sscanf(buf, "%*s %lu", &info.memmax);
|
sscanf(buf, "%*s %Lu", &info.memmax);
|
||||||
} else if (strncmp(buf, "MemFree:", 8) == 0) {
|
} else if (strncmp(buf, "MemFree:", 8) == 0) {
|
||||||
sscanf(buf, "%*s %lu", &info.mem);
|
sscanf(buf, "%*s %Lu", &info.mem);
|
||||||
} else if (strncmp(buf, "SwapTotal:", 10) == 0) {
|
} else if (strncmp(buf, "SwapTotal:", 10) == 0) {
|
||||||
sscanf(buf, "%*s %lu", &info.swapmax);
|
sscanf(buf, "%*s %Lu", &info.swapmax);
|
||||||
} else if (strncmp(buf, "SwapFree:", 9) == 0) {
|
} else if (strncmp(buf, "SwapFree:", 9) == 0) {
|
||||||
sscanf(buf, "%*s %lu", &info.swap);
|
sscanf(buf, "%*s %Lu", &info.swap);
|
||||||
} else if (strncmp(buf, "Buffers:", 8) == 0) {
|
} else if (strncmp(buf, "Buffers:", 8) == 0) {
|
||||||
sscanf(buf, "%*s %lu", &info.buffers);
|
sscanf(buf, "%*s %Lu", &info.buffers);
|
||||||
} else if (strncmp(buf, "Cached:", 7) == 0) {
|
} else if (strncmp(buf, "Cached:", 7) == 0) {
|
||||||
sscanf(buf, "%*s %lu", &info.cached);
|
sscanf(buf, "%*s %Lu", &info.cached);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user