swapon(8): Fix "swapctl -l".
authorSascha Wildner <saw@online.de>
Sat, 30 Apr 2011 22:27:05 +0000 (00:27 +0200)
committerSascha Wildner <saw@online.de>
Sat, 30 Apr 2011 22:27:33 +0000 (00:27 +0200)
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 <jdegroot@web.de>
Taken-from:  FreeBSD

sbin/swapon/swapon.c

index 8fcefee..7dbfcf9 100644 (file)
@@ -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 <sys/param.h>
@@ -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);