Skip to contentSkip to conversation

mmzone.h: constify some zone access functions

PATCH In review Luiz Capitulino 2 participants 3 messages Nov 22, 2013

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

PATCH 1/1 mmzone.h: constify some zone access functions

---
 include/linux/mmzone.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/mmzone.h +3 -3
index bd791e4..5e202d6 100644
@@ -560,12 +560,12 @@ static inline bool zone_spans_pfn(const struct zone *zone, unsigned long pfn)
 	return zone->zone_start_pfn <= pfn && pfn < zone_end_pfn(zone);
 }
 
-static inline bool zone_is_initialized(struct zone *zone)
+static inline bool zone_is_initialized(const struct zone *zone)
 {
 	return !!zone->wait_table;
 }
 
-static inline bool zone_is_empty(struct zone *zone)
+static inline bool zone_is_empty(const struct zone *zone)
 {
 	return zone->spanned_pages == 0;
 }
@@ -843,7 +843,7 @@ unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long);
  */
 #define zone_idx(zone)		((zone) - (zone)->zone_pgdat->node_zones)
 
-static inline int populated_zone(struct zone *zone)
+static inline int populated_zone(const struct zone *zone)
 {
 	return (!!zone->present_pages);
 }
Signature · 7 lines
1.8.3.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
maintainer
#1 lore raw
Quoted 25 lines · On Fri, 22 Nov 2013 12:01:06 -0500 Luiz Capitulino <[email protected]>…
---
 include/linux/mmzone.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/mmzone.h +2 -2
index bd791e4..5e202d6 100644
@@ -560,12 +560,12 @@ static inline bool zone_spans_pfn(const struct zone *zone, unsigned long pfn)
 	return zone->zone_start_pfn <= pfn && pfn < zone_end_pfn(zone);
 }
 
-static inline bool zone_is_initialized(struct zone *zone)
+static inline bool zone_is_initialized(const struct zone *zone)
 {
 	return !!zone->wait_table;
 }
 
-static inline bool zone_is_empty(struct zone *zone)
+static inline bool zone_is_empty(const struct zone *zone)
 {
 	return zone->spanned_pages == 0;
 }

include/linux/mmzone.h unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long); · line 849

Quoted 8 lines
include/linux/mmzone.h +1 -1
@@ -843,7 +843,7 @@ unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long);
  */
 #define zone_idx(zone)		((zone) - (zone)->zone_pgdat->node_zones)
 
-static inline int populated_zone(struct zone *zone)
+static inline int populated_zone(const struct zone *zone)
 {
 	return (!!zone->present_pages);
 }

hm, why? I counted ten similarly constifyable functions in mm.h and stopped only 1/4 of the way through. What's so special about these three?

#2 lore raw
Quoted 30 lines · On Fri, 22 Nov 2013 14:30:47 -0800 Andrew Morton <[email protected]>…
Quoted 28 lines · On Fri, 22 Nov 2013 12:01:06 -0500 Luiz Capitulino <[email protected]>…
---
 include/linux/mmzone.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/mmzone.h +2 -2
index bd791e4..5e202d6 100644
@@ -560,12 +560,12 @@ static inline bool zone_spans_pfn(const struct zone *zone, unsigned long pfn)
 	return zone->zone_start_pfn <= pfn && pfn < zone_end_pfn(zone);
 }
 
-static inline bool zone_is_initialized(struct zone *zone)
+static inline bool zone_is_initialized(const struct zone *zone)
 {
 	return !!zone->wait_table;
 }
 
-static inline bool zone_is_empty(struct zone *zone)
+static inline bool zone_is_empty(const struct zone *zone)
 {
 	return zone->spanned_pages == 0;
 }
@@ -843,7 +843,7 @@ unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long);
  */
 #define zone_idx(zone)		((zone) - (zone)->zone_pgdat->node_zones)
 
Quoted 8 lines

include/linux/mmzone.h unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long); · line 849

Quoted 5 lines
include/linux/mmzone.h +1 -1
-static inline int populated_zone(struct zone *zone)
+static inline int populated_zone(const struct zone *zone)
 {
 	return (!!zone->present_pages);
 }

hm, why? I counted ten similarly constifyable functions in mm.h and stopped only 1/4 of the way through. What's so special about these three?

I spotted them while reading code. If you want to me convert the others, I can do that.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>