[TRIVIAL] beautify nr_free_pages()

From: Rusty Russell (rusty@rustcorp.com.au)
Date: Thu Jun 20 2002 - 15:02:46 EST


From: (via Rusty) William Lee Irwin III <wli@holomorphy.com>
  nr_free_pages() is overly verbose. The following is perhaps clearer and
  gets to the point with fewer lines of code and inside of 80 columns.
  
  Against 2.5.21
  
  
  Cheers,
  Bill
  
  
  
  ===== mm/page_alloc.c 1.67 vs edited =====

--- trivial-2.5.23/mm/page_alloc.c.orig Fri Jun 21 05:33:30 2002
+++ trivial-2.5.23/mm/page_alloc.c Fri Jun 21 05:33:30 2002
@@ -495,16 +495,13 @@
  */
 unsigned int nr_free_pages(void)
 {
- unsigned int sum;
- zone_t *zone;
- pg_data_t *pgdat = pgdat_list;
+ unsigned int i, sum = 0;
+ pg_data_t *pgdat;
+
+ for (pgdat = pgdat_list; pgdat; pgdat = pgdat->node_next)
+ for (i = 0; i < MAX_NR_ZONES; ++i)
+ sum += pgdat->node_zones[i].free_pages;
 
- sum = 0;
- while (pgdat) {
- for (zone = pgdat->node_zones; zone < pgdat->node_zones + MAX_NR_ZONES; zone++)
- sum += zone->free_pages;
- pgdat = pgdat->node_next;
- }
         return sum;
 }
 

--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
-
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/



This archive was generated by hypermail 2b29 : Sun Jun 23 2002 - 22:00:23 EST