patch-2.3.24 linux/mm/swapfile.c

Next file: linux/mm/vmalloc.c
Previous file: linux/mm/swap_state.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.23/linux/mm/swapfile.c linux/mm/swapfile.c
@@ -779,23 +779,26 @@
 
 void si_swapinfo(struct sysinfo *val)
 {
-	unsigned int i, j;
+	unsigned int i;
+	unsigned long freeswap = 0;
+	unsigned long totalswap = 0;
 
-	val->freeswap = val->totalswap = 0;
 	for (i = 0; i < nr_swapfiles; i++) {
+		unsigned int j;
 		if ((swap_info[i].flags & SWP_WRITEOK) != SWP_WRITEOK)
 			continue;
-		for (j = 0; j < swap_info[i].max; ++j)
+		for (j = 0; j < swap_info[i].max; ++j) {
 			switch (swap_info[i].swap_map[j]) {
 				case SWAP_MAP_BAD:
 					continue;
 				case 0:
-					++val->freeswap;
+					freeswap++;
 				default:
-					++val->totalswap;
+					totalswap++;
 			}
+		}
 	}
-	val->freeswap <<= PAGE_SHIFT;
-	val->totalswap <<= PAGE_SHIFT;
+	val->freeswap = freeswap;
+	val->totalswap = totalswap;
 	return;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)