Fix segfault when there is no swap.

This commit is contained in:
Roman Bogorodskiy 2005-04-07 16:52:56 +00:00
parent 6f2eb4bfb6
commit a34a6612a4
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=132705
2 changed files with 14 additions and 4 deletions

View file

@ -7,7 +7,7 @@
PORTNAME= torsmo
PORTVERSION= 0.18
PORTREVISION= 3
PORTREVISION= 4
CATEGORIES= sysutils
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= ${PORTNAME}

View file

@ -1,5 +1,5 @@
--- torsmo.c.orig Wed Dec 22 01:14:46 2004
+++ torsmo.c Wed Dec 22 21:49:27 2004
+++ torsmo.c Thu Apr 7 20:51:01 2005
@@ -272,7 +272,7 @@
snprintf(buf, 255, "%.1fM", m);
}
@ -18,7 +18,17 @@
}
OBJ(freq) {
snprintf(p, n, "%s", get_freq());
@@ -2223,8 +2223,8 @@
@@ -1126,7 +1126,8 @@
human_readable(cur->swapmax*1024, p);
}
OBJ(swapperc) {
- snprintf(p, 255, "%*u", pad_percents, (cur->swap*100) / cur->swapmax);
+ snprintf(p, 255, "%*u", pad_percents,
+ cur->swapmax ? (cur->swap*100) / cur->swapmax : 0);
}
OBJ(swapbar) {
new_bar(p, obj->data.pair.a, obj->data.pair.b,
@@ -2223,8 +2224,8 @@
/* handle other command line arguments */
@ -29,7 +39,7 @@
while (1) {
int c = getopt(argc, argv, getopt_string);
if(c == -1) break;
@@ -2319,8 +2319,7 @@
@@ -2319,8 +2320,7 @@
default:
fprintf(stderr, "torsmo: forked to background, pid is %d\n", ret);