Skip to contentSkip to conversation

Fix up slabinfo code

PATCH New Brian Gerst 1 participant 1 message Feb 22, 2003 Memory management

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix up slabinfo code

Move printing the header to s_start, removing the need for the special pointer value.

--
Brian Gerst

mm/slab.c +12 -19
diff -urN linux-2.5.62-bk2/mm/slab.c linux/mm/slab.c
@@ -2194,10 +2194,19 @@
 	struct list_head *p;
 
 	down(&cache_chain_sem);
-	if (!n)
-		return (void *)1;
+	if (!n) {
+		/*
+		 * Output format version, so at least we can change it
+		 * without _too_ many complaints.
+		 */
+		seq_puts(m, "slabinfo - version: 1.2"
+#if STATS
+				" (statistics)"
+#endif
+				"\n");
+	}
 	p = cache_chain.next;
-	while (--n) {
+	while (n--) {
 		p = p->next;
 		if (p == &cache_chain)
 			return NULL;
@@ -2209,8 +2218,6 @@
 {
 	kmem_cache_t *cachep = p;
 	++*pos;
-	if (p == (void *)1)
-		return list_entry(cache_chain.next, kmem_cache_t, next);
 	return cachep->next.next == &cache_chain ? NULL
 		: list_entry(cachep->next.next, kmem_cache_t, next);
 }
@@ -2234,20 +2241,6 @@
 	mm_segment_t old_fs;
 	char tmp; 
 
-
-	if (p == (void*)1) {
-		/*
-		 * Output format version, so at least we can change it
-		 * without _too_ many complaints.
-		 */
-		seq_puts(m, "slabinfo - version: 1.2"
-#if STATS
-				" (statistics)"
-#endif
-				"\n");
-		return 0;
-	}
-
 	check_irq_on();
 	spin_lock_irq(&cachep->spinlock);
 	active_objs = 0;