[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-kernel
Subject:    [PATCH] mm/swapfile.c/get_swaparea_info - a cosmetic change
From:       Denis Zaitsev <zzz () cd-club ! ru>
Date:       2001-11-30 21:32:52
[Download RAW message or body]

The header line of /proc/swaps does not match the consequence ones in
case of devfs' names.  These names are too long in comparison with the
<Filename> header's part.  So, I've added one tab into the header and
made the path's part of other lines to be of length 40-1 vs. 32-1.

Also, I've changed three calls for sprintf with one...

Linus, please, apply this cosmetic patch (it is against 2.4.16).


--- mm/swapfile.c.orig	Sat Dec  1 02:10:17 2001
+++ mm/swapfile.c	Wed Nov 28 22:05:00 2001
@@ -804,25 +804,17 @@ int get_swaparea_info(char *buf)
 {
 	char * page = (char *) __get_free_page(GFP_KERNEL);
 	struct swap_info_struct *ptr = swap_info;
-	int i, j, len = 0, usedswap;
+	int i, len;
 
 	if (!page)
 		return -ENOMEM;
 
-	len += sprintf(buf, "Filename\t\t\tType\t\tSize\tUsed\tPriority\n");
+	len = sprintf(buf, "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
 	for (i = 0 ; i < nr_swapfiles ; i++, ptr++) {
 		if ((ptr->flags & SWP_USED) && ptr->swap_map) {
 			char * path = d_path(ptr->swap_file, ptr->swap_vfsmnt,
 						page, PAGE_SIZE);
-
-			len += sprintf(buf + len, "%-31s ", path);
-
-			if (!ptr->swap_device)
-				len += sprintf(buf + len, "file\t\t");
-			else
-				len += sprintf(buf + len, "partition\t");
-
-			usedswap = 0;
+			int j, usedswap = 0;
 			for (j = 0; j < ptr->max; ++j)
 				switch (ptr->swap_map[j]) {
 					case SWAP_MAP_BAD:
@@ -831,8 +823,12 @@ int get_swaparea_info(char *buf)
 					default:
 						usedswap++;
 				}
-			len += sprintf(buf + len, "%d\t%d\t%d\n", ptr->pages << (PAGE_SHIFT - 10), 
-				usedswap << (PAGE_SHIFT - 10), ptr->prio);
+			len += sprintf(buf + len, "%-39s %s\t%d\t%d\t%d\n",
+				       path,
+				       ptr->swap_device ? "partition" : "file\t",
+				       ptr->pages << (PAGE_SHIFT - 10),
+				       usedswap << (PAGE_SHIFT - 10),
+				       ptr->prio);
 		}
 	}
 	free_page((unsigned long) page);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic