Skip to contentSkip to conversation

mm:Make the function set_recommended_min_free_kbytes have a return type of void

PATCH In review Nicholas Krause 2 participants 3 messages Jul 1, 2015 – Jul 2, 2015

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

PATCH 1/1 mm:Make the function set_recommended_min_free_kbytes have a return type of void

This makes the function set_recommended_min_free_kbytes have a return type of void now due to this particular function never needing to signal it's call if it fails due to this function always completing successfully without issue.

---
 mm/huge_memory.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
mm/huge_memory.c +1 -2
index c107094..914a72a 100644
@@ -104,7 +104,7 @@ static struct khugepaged_scan khugepaged_scan = {
 };
 
 
-static int set_recommended_min_free_kbytes(void)
+static void set_recommended_min_free_kbytes(void)
 {
 	struct zone *zone;
 	int nr_zones = 0;
@@ -139,7 +139,6 @@ static int set_recommended_min_free_kbytes(void)
 		min_free_kbytes = recommended_min;
 	}
 	setup_per_zone_wmarks();
-	return 0;
 }
 
 static int start_stop_khugepaged(void)
Signature · 7 lines
2.1.4

--
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>
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Nicholas Krause

This makes the function set_recommended_min_free_kbytes have a return type of void now due to this particular function never needing to signal it's call if it fails due to this function always completing successfully without issue.

The changelog is hard to read for me.
"
The function cannot possibly fail so it doesn't make much sense to have a return value. Make it void.
"
Would sound much easier to parse for me.

I doubt this would help the compiler to generate a better code but in general it is better to have void return type when there is no failure possible - which is the case here.

Quoted 1 line
Quoted 28 lines
---
 mm/huge_memory.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
mm/huge_memory.c +1 -2
index c107094..914a72a 100644
@@ -104,7 +104,7 @@ static struct khugepaged_scan khugepaged_scan = {
 };
 
 
-static int set_recommended_min_free_kbytes(void)
+static void set_recommended_min_free_kbytes(void)
 {
 	struct zone *zone;
 	int nr_zones = 0;
@@ -139,7 +139,6 @@ static int set_recommended_min_free_kbytes(void)
 		min_free_kbytes = recommended_min;
 	}
 	setup_per_zone_wmarks();
-	return 0;
 }
 
 static int start_stop_khugepaged(void)
Signature · 1 line
2.1.4
Signature · 8 lines
Michal Hocko
SUSE Labs

--
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>
author
#2 lore raw
Quoted 45 lines · Michal Hocko
Quoted 4 lines · Nicholas Krause

This makes the function set_recommended_min_free_kbytes have a return type of void now due to this particular function never needing to signal it's call if it fails due to this function always completing successfully without issue.

The changelog is hard to read for me.
"
The function cannot possibly fail so it doesn't make much sense to have a return value. Make it void.
"
Would sound much easier to parse for me.

I doubt this would help the compiler to generate a better code but in general it is better to have void return type when there is no failure possible - which is the case here.

Quoted 1 line
Quoted 24 lines
---
 mm/huge_memory.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
mm/huge_memory.c +1 -2
index c107094..914a72a 100644
@@ -104,7 +104,7 @@ static struct khugepaged_scan khugepaged_scan = {
 };
 
 
-static int set_recommended_min_free_kbytes(void)
+static void set_recommended_min_free_kbytes(void)
 {
 	struct zone *zone;
 	int nr_zones = 0;
@@ -139,7 +139,6 @@ static int set_recommended_min_free_kbytes(void)
 		min_free_kbytes = recommended_min;
 	}
 	setup_per_zone_wmarks();
-	return 0;
 }
 
Quoted 5 lines
Quoted 4 lines
mm/huge_memory.c +0 -0
 static int start_stop_khugepaged(void)
Signature · 1 line
2.1.4

That was exactly my point with these patches readability not compiler improvements. Otherwise I would have stated that in my commit messages and would argue readability improvements are important too for the kernel.
Nick

--
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>