Skip to contentSkip to conversation

efs: make a struct static

PATCH In review Adrian Bunk 2 participants 3 messages Oct 30, 2004 – Dec 12, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efs: make a struct static

The patch below makes a struct in the efs code static.

include/linux/efs_vh.h renamed from include/linux/efs_vh.h.old +1 -1
@@ -44,7 +44,7 @@
 #define SGI_EFS		0x07
 #define IS_EFS(x)	(((x) == SGI_EFS) || ((x) == SGI_SYSV))
 
-struct pt_types {
+static struct pt_types {
 	int	pt_type;
 	char	*pt_name;
 } sgi_pt_types[] = {
#1 lore raw
Quoted 8 lines · Adrian Bunk

The patch below makes a struct in the efs code static.

include/linux/efs_vh.h line 50

Quoted 8 lines
include/linux/efs_vh.h renamed from include/linux/efs_vh.h.old +1 -1
@@ -44,7 +44,7 @@
 #define SGI_EFS		0x07
 #define IS_EFS(x)	(((x) == SGI_EFS) || ((x) == SGI_SYSV))
 
-struct pt_types {
+static struct pt_types {
 	int	pt_type;
 	char	*pt_name;
 } sgi_pt_types[] = {

You made a variable in .h file static. This is a no-no.

Only fs/efs/super.c includes linux/efs_vh.h now, but if it will be ever included into another files, you will get silent data duplication.

Unless I miss something, you really wanted to do:

.h file:

struct pt_types {
	int     pt_type;
	char    *pt_name;
};

extern struct pt_types sgi_pt_types[];

.c file:

struct pt_types sgi_pt_types[] = {
	{0x00,          "SGI vh"},
....
	{0,             NULL}
};

--
vda

#2 lore raw

PATCH 1/1 efs: make a struct static

Quoted 12 lines · Denis Vlasenko
Quoted 11 lines · Adrian Bunk

The patch below makes a struct in the efs code static.

include/linux/efs_vh.h renamed from include/linux/efs_vh.h.old +0 -0
@@ -44,7 +44,7 @@
 #define SGI_EFS		0x07
 #define IS_EFS(x)	(((x) == SGI_EFS) || ((x) == SGI_SYSV))
 
Quoted 7 lines

include/linux/efs_vh.h line 50

Quoted 5 lines
include/linux/efs_vh.h renamed from include/linux/efs_vh.h.old +1 -1
-struct pt_types {
+static struct pt_types {
 	int	pt_type;
 	char	*pt_name;
 } sgi_pt_types[] = {

You made a variable in .h file static. This is a no-no.

Not that the previous code was much better...

Quoted 6 lines

Only fs/efs/super.c includes linux/efs_vh.h now, but if it will be ever included into another files, you will get silent data duplication.

Unless I miss something, you really wanted to do:
...

Sounds good, updated patch below.

The patch below makes a needessly global struct in the efs code static.

diffstat output:

 fs/efs/super.c         |   20 ++++++++++++++++++++
 include/linux/efs_vh.h |   17 -----------------
 2 files changed, 20 insertions(+), 17 deletions(-)
include/linux/efs_vh.h renamed from include/linux/efs_vh.h.old +0 -17
@@ -47,23 +47,6 @@
 struct pt_types {
 	int	pt_type;
 	char	*pt_name;
-} sgi_pt_types[] = {
-	{0x00,		"SGI vh"},
-	{0x01,		"SGI trkrepl"},
-	{0x02,		"SGI secrepl"},
-	{0x03,		"SGI raw"},
-	{0x04,		"SGI bsd"},
-	{SGI_SYSV,	"SGI sysv"},
-	{0x06,		"SGI vol"},
-	{SGI_EFS,	"SGI efs"},
-	{0x08,		"SGI lv"},
-	{0x09,		"SGI rlv"},
-	{0x0A,		"SGI xfs"},
-	{0x0B,		"SGI xfslog"},
-	{0x0C,		"SGI xlv"},
-	{0x82,		"Linux swap"},
-	{0x83,		"Linux native"},
-	{0,		NULL}
 };
 
 #endif /* __EFS_VH_H__ */
fs/efs/super.c renamed from fs/efs/super.c.old +20 -0
@@ -32,6 +32,26 @@
 	.fs_flags	= FS_REQUIRES_DEV,
 };
 
+static struct pt_types sgi_pt_types[] = {
+	{0x00,		"SGI vh"},
+	{0x01,		"SGI trkrepl"},
+	{0x02,		"SGI secrepl"},
+	{0x03,		"SGI raw"},
+	{0x04,		"SGI bsd"},
+	{SGI_SYSV,	"SGI sysv"},
+	{0x06,		"SGI vol"},
+	{SGI_EFS,	"SGI efs"},
+	{0x08,		"SGI lv"},
+	{0x09,		"SGI rlv"},
+	{0x0A,		"SGI xfs"},
+	{0x0B,		"SGI xfslog"},
+	{0x0C,		"SGI xlv"},
+	{0x82,		"Linux swap"},
+	{0x83,		"Linux native"},
+	{0,		NULL}
+};
+
+
 static kmem_cache_t * efs_inode_cachep;
 
 static struct inode *efs_alloc_inode(struct super_block *sb)