Skip to contentSkip to conversation

enums

PATCH Manik Raina 1 participant 3 messages Jun 27, 2002 – Jun 28, 2002

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

is there a particular reason we dislike constructs as attached in the diffs below ?
with enums, we dont have to increment MAX_NR_ZONES everytime a new one is added .

include/linux/mmzone.h +9 -4
diff -u -r -U 6 cmp/include/linux/mmzone.h linux-2.5.24/include/linux/mmzone.h
@@ -88,16 +88,21 @@
 	 * rarely used fields:
 	 */
 	char			*name;
 	unsigned long		size;
 } zone_t;
 
-#define ZONE_DMA		0
-#define ZONE_NORMAL		1
-#define ZONE_HIGHMEM		2
-#define MAX_NR_ZONES		3
+enum zone_type {
+
+     ZONE_DMA,
+     ZONE_NORMAL,
+     ZONE_HIGHMEM,		
+     MAX_NR_ZONES,	
+
+};
+
 
 /*
  * One allocation request operates on a zonelist. A zonelist
  * is a list of zones, the first one is the 'goal' of the
  * allocation, the other zones are fallback zones, in decreasing
  * priority.
#1 lore raw
Quoted 1 line · Manik Raina

with enums, we dont have to increment MAX_NR_ZONES everytime a new one

s/one/zonetype

Quoted 2 lines

is added .

#2 lore raw
In reply to Manik Raina

If no one has any objections, Can this be applied as a patch ?

Quoted 36 lines · Manik Raina

is there a particular reason we dislike constructs as attached in the diffs below ?
with enums, we dont have to increment MAX_NR_ZONES everytime a new one is added .

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
diff -u -r -U 6 cmp/include/linux/mmzone.h linux-2.5.24/include/linux/mmzone.h

include/linux/mmzone.h Thu Jun 27 18:00:25 2002 renamed from include/linux/mmzone.h Fri Jun 21 04:23:42 2002 +9 -4
@@ -88,16 +88,21 @@
         * rarely used fields:
         */
        char                    *name;
        unsigned long           size;
 } zone_t;
 
-#define ZONE_DMA               0
-#define ZONE_NORMAL            1
-#define ZONE_HIGHMEM           2
-#define MAX_NR_ZONES           3
+enum zone_type {
+
+     ZONE_DMA,
+     ZONE_NORMAL,
+     ZONE_HIGHMEM,
+     MAX_NR_ZONES,
+
+};
+
 
 /*
  * One allocation request operates on a zonelist. A zonelist
  * is a list of zones, the first one is the 'goal' of the
  * allocation, the other zones are fallback zones, in decreasing
  * priority.