2004-10-30 17:57:15

by Adrian Bunk

[permalink] [raw]
Subject: [2.6 patch] efs: make a struct static

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


Signed-off-by: Adrian Bunk <[email protected]>

--- linux-2.6.10-rc1-mm2-full/include/linux/efs_vh.h.old 2004-10-30 14:03:58.000000000 +0200
+++ linux-2.6.10-rc1-mm2-full/include/linux/efs_vh.h 2004-10-30 14:04:13.000000000 +0200
@@ -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[] = {


2004-10-30 21:44:16

by Denis Vlasenko

[permalink] [raw]
Subject: Re: [2.6 patch] efs: make a struct static

On Saturday 30 October 2004 20:56, Adrian Bunk wrote:
> The patch below makes a struct in the efs code static.
>
>
> Signed-off-by: Adrian Bunk <[email protected]>
>
> --- linux-2.6.10-rc1-mm2-full/include/linux/efs_vh.h.old 2004-10-30 14:03:58.000000000 +0200
> +++ linux-2.6.10-rc1-mm2-full/include/linux/efs_vh.h 2004-10-30 14:04:13.000000000 +0200
> @@ -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