From: Sascha Wildner Date: Sat, 30 Apr 2011 22:27:05 +0000 (+0200) Subject: swapon(8): Fix "swapctl -l". X-Git-Tag: v2.12.0~702 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/ebd20800f90101c7f35180985899fb1c94af5021 swapon(8): Fix "swapctl -l". Without -s, swapctl -l would report 0 for swap size and used swap because some variables were initialized only for the -s case. Just remove the "if (sflag)" around the calculation. Reported-by: Joachim de Groot Taken-from: FreeBSD --- diff --git a/sbin/swapon/swapon.c b/sbin/swapon/swapon.c index 8fcefeee5f..7dbfcf9aae 100644 --- a/sbin/swapon/swapon.c +++ b/sbin/swapon/swapon.c @@ -33,7 +33,6 @@ * @(#) Copyright (c) 1980, 1993 The Regents of the University of California. All rights reserved. * @(#)swapon.c 8.1 (Berkeley) 6/5/93 * $FreeBSD: src/sbin/swapon/swapon.c,v 1.8.2.2 2001/07/30 10:30:11 dd Exp $ - * $DragonFly: src/sbin/swapon/swapon.c,v 1.5 2005/11/06 12:50:21 swildner Exp $ */ #include @@ -306,13 +305,10 @@ swaplist(int lflag, int sflag, int hflag) if (xsw->xsw_nblks == 0) continue; - if (sflag) { - tmp_total = (long long)xsw->xsw_nblks * pagesize; - tmp_used = (long long)xsw->xsw_used * pagesize; - total += tmp_total; - used += tmp_used; - } - + tmp_total = (long long)xsw->xsw_nblks * pagesize; + tmp_used = (long long)xsw->xsw_used * pagesize; + total += tmp_total; + used += tmp_used; if (lflag) { sizetobuf(buf, sizeof(buf), hflag, tmp_total, hlen, blocksize);