Skip to contentSkip to conversation

loop.c: make two functions static

PATCH In review Adrian Bunk 3 participants 3 messages Jan 23, 2005 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 loop.c: make two functions static

This patch makes two needlessly global functions static.

---

 drivers/block/loop.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

This patch was already sent on:
- 29 Nov 2004

drivers/block/loop.c renamed from drivers/block/loop.c.old +2 -2
@@ -1114,7 +1114,7 @@
 EXPORT_SYMBOL(loop_register_transfer);
 EXPORT_SYMBOL(loop_unregister_transfer);
 
-int __init loop_init(void)
+static int __init loop_init(void)
 {
 	int	i;
 
@@ -1189,7 +1189,7 @@
 	return -ENOMEM;
 }
 
-void loop_exit(void)
+static void loop_exit(void)
 {
 	int i;
 
#1 lore raw

hi, adrian

i always see patches which set functions and variables to static. what's the main difference between static and non-static things?

Quoted 38 lines · Adrian Bunk

This patch makes two needlessly global functions static.

---

 drivers/block/loop.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

This patch was already sent on:
- 29 Nov 2004

drivers/block/loop.c 2004-11-06 20:09:31.000000000 +0100 renamed from drivers/block/loop.c.old 2004-11-06 20:09:10.000000000 +0100 +2 -3
@@ -1114,7 +1114,7 @@
 EXPORT_SYMBOL(loop_register_transfer);
 EXPORT_SYMBOL(loop_unregister_transfer);
 
-int __init loop_init(void)
+static int __init loop_init(void)
 {
        int     i;
 
@@ -1189,7 +1189,7 @@
        return -ENOMEM;
 }
 
-void loop_exit(void)
+static void loop_exit(void)
 {
        int i;
 
-

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 1 line
Yours andyliu
#2 lore raw
Quoted 4 lines · andyliu

hi, adrian

i always see patches which set functions and variables to static. what's the main difference between static and non-static things?

1) namespace; static functions/variables are not visible name wise to other .c files
2) optimisation: because of 1), gcc can know that there are no outside users (assuming also no address-off is taken, which gcc also knows), and in that case gcc can do a series of extra optimisations (such as more agressive inlining, since gcc knows the exact user count of the function now, but also gcc 3.4 will do things like make the function be regparm=3 equivalent, tail/head optimisations are possible (eg partial inlining)