Skip to contentSkip to conversation

Removed compilation warnings from mountd/cache.c

PATCH In review Steve Dickson 3 participants 5 messages May 16, 2011 – May 17, 2011

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

PATCH 1/1 Removed compilation warnings from mountd/cache.c

Commit 5604b35a6 introduced a number of missing initializer warnings that were missed. This patch removes those warnings.

---
 utils/mountd/cache.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
utils/mountd/cache.c +4 -2
index df6b38f..86a2790 100644
@@ -825,7 +825,6 @@ struct {
 	char *cache_name;
 	void (*cache_handle)(FILE *f);
 	FILE *f;
-	char vbuf[RPC_CHAN_BUF_SIZE];
 } cachelist[] = {
 	{ "auth.unix.ip", auth_unix_ip, NULL},
 	{ "auth.unix.gid", auth_unix_gid, NULL},
@@ -833,6 +832,9 @@ struct {
 	{ "nfsd.fh", nfsd_fh, NULL},
 	{ NULL, NULL, NULL }
 };
+struct vbs {
+	char vbuf[RPC_CHAN_BUF_SIZE];
+} vbufs [(sizeof(cachelist)/sizeof(cachelist[0])) - 1];
 
 extern int manage_gids;
 
@@ -850,7 +852,7 @@ void cache_open(void)
 		sprintf(path, "/proc/net/rpc/%s/channel", cachelist[i].cache_name);
 		cachelist[i].f = fopen(path, "r+");
 		if (cachelist[i].f != NULL) {
-			setvbuf(cachelist[i].f, cachelist[i].vbuf, _IOLBF, 
+			setvbuf(cachelist[i].f, vbufs[i].vbuf, _IOLBF, 
 				RPC_CHAN_BUF_SIZE);
 		}
 	}
Signature · 1 line
1.7.4.4
#1 lore raw
Quoted 21 lines · Steve Dickson

Commit 5604b35a6 introduced a number of missing initializer warnings that were missed. This patch removes those warnings.

---
 utils/mountd/cache.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
utils/mountd/cache.c +0 -1
index df6b38f..86a2790 100644
@@ -825,7 +825,6 @@ struct {
 	char *cache_name;
 	void (*cache_handle)(FILE *f);
 	FILE *f;
-	char vbuf[RPC_CHAN_BUF_SIZE];
 } cachelist[] = {
 	{ "auth.unix.ip", auth_unix_ip, NULL},
 	{ "auth.unix.gid", auth_unix_gid, NULL},

utils/mountd/cache.c struct { · line 837

Quoted 6 lines
utils/mountd/cache.c +3 -0
@@ -833,6 +832,9 @@ struct {
 	{ "nfsd.fh", nfsd_fh, NULL},
 	{ NULL, NULL, NULL }
 };
+struct vbs {
+	char vbuf[RPC_CHAN_BUF_SIZE];
+} vbufs [(sizeof(cachelist)/sizeof(cachelist[0])) - 1];

Weird--why does that make a difference? It's statically initialized memory either way, isn't it?

I prefer the way it is now. The buffer belongs logically with the other data associated with its cache file.

--b.

Quoted 19 lines
utils/mountd/cache.c +1 -1
 extern int manage_gids;
 
@@ -850,7 +852,7 @@ void cache_open(void)
 		sprintf(path, "/proc/net/rpc/%s/channel", cachelist[i].cache_name);
 		cachelist[i].f = fopen(path, "r+");
 		if (cachelist[i].f != NULL) {
-			setvbuf(cachelist[i].f, cachelist[i].vbuf, _IOLBF, 
+			setvbuf(cachelist[i].f, vbufs[i].vbuf, _IOLBF, 
 				RPC_CHAN_BUF_SIZE);
 		}
 	}
Signature · 6 lines
1.7.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

J. Bruce Fields wrote:

  On Mon, May 16, 2011 at 11:50:14AM -0400, Steve Dickson wrote:
  > Commit 5604b35a6 introduced a number of missing initializer
  > warnings that were missed. This patch removes those warnings.
  > 
  > Signed-off-by: Steve Dickson <[email protected]>
  > ---
  >  utils/mountd/cache.c |    6 ++++--
  >  1 files changed, 4 insertions(+), 2 deletions(-)
  > 
  > diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
  > index df6b38f..86a2790 100644
  > --- a/utils/mountd/cache.c
  > +++ b/utils/mountd/cache.c
  > @@ -825,7 +825,6 @@ struct {
  >  	char *cache_name;
  >  	void (*cache_handle)(FILE *f);
  >  	FILE *f;
  > -	char vbuf[RPC_CHAN_BUF_SIZE];
  >  } cachelist[] = {
  >  	{ "auth.unix.ip", auth_unix_ip, NULL},
  >  	{ "auth.unix.gid", auth_unix_gid, NULL},
  > @@ -833,6 +832,9 @@ struct {
  >  	{ "nfsd.fh", nfsd_fh, NULL},
  >  	{ NULL, NULL, NULL }
  >  };
  > +struct vbs {
  > +	char vbuf[RPC_CHAN_BUF_SIZE];
  > +} vbufs [(sizeof(cachelist)/sizeof(cachelist[0])) - 1];

Weird--why does that make a difference? It's statically initialized memory either way, isn't it?

The problem is the vbuf item was added to the struct but no initializer was given for it. It could also have been fixed by supplying the missing initializer:

	{ "auth.unix.ip", auth_unix_ip, NULL, ""}, ...
#3 lore raw
Quoted 31 lines · Jim Rees

J. Bruce Fields wrote:

  On Mon, May 16, 2011 at 11:50:14AM -0400, Steve Dickson wrote:
  > Commit 5604b35a6 introduced a number of missing initializer
  > warnings that were missed. This patch removes those warnings.
  > 
  > Signed-off-by: Steve Dickson <[email protected]>
  > ---
  >  utils/mountd/cache.c |    6 ++++--
  >  1 files changed, 4 insertions(+), 2 deletions(-)
  > 
  > diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
  > index df6b38f..86a2790 100644
  > --- a/utils/mountd/cache.c
  > +++ b/utils/mountd/cache.c
  > @@ -825,7 +825,6 @@ struct {
  >  	char *cache_name;
  >  	void (*cache_handle)(FILE *f);
  >  	FILE *f;
  > -	char vbuf[RPC_CHAN_BUF_SIZE];
  >  } cachelist[] = {
  >  	{ "auth.unix.ip", auth_unix_ip, NULL},
  >  	{ "auth.unix.gid", auth_unix_gid, NULL},
  > @@ -833,6 +832,9 @@ struct {
  >  	{ "nfsd.fh", nfsd_fh, NULL},
  >  	{ NULL, NULL, NULL }
  >  };
  > +struct vbs {
  > +	char vbuf[RPC_CHAN_BUF_SIZE];
  > +} vbufs [(sizeof(cachelist)/sizeof(cachelist[0])) - 1];
Quoted 8 lines

Weird--why does that make a difference? It's statically initialized memory either way, isn't it?

The problem is the vbuf item was added to the struct but no initializer was given for it. It could also have been fixed by supplying the missing initializer:

	{ "auth.unix.ip", auth_unix_ip, NULL, ""}, ...

Oh, OK. Then could we do that, Steve, instead of moving the buffer to a separate structure?

--b.

#4 lore raw
Quoted 35 lines · J. Bruce Fields
Quoted 34 lines · Jim Rees

J. Bruce Fields wrote:

  On Mon, May 16, 2011 at 11:50:14AM -0400, Steve Dickson wrote:
  > Commit 5604b35a6 introduced a number of missing initializer
  > warnings that were missed. This patch removes those warnings.
  > 
  > Signed-off-by: Steve Dickson <[email protected]>
  > ---
  >  utils/mountd/cache.c |    6 ++++--
  >  1 files changed, 4 insertions(+), 2 deletions(-)
  > 
  > diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
  > index df6b38f..86a2790 100644
  > --- a/utils/mountd/cache.c
  > +++ b/utils/mountd/cache.c
  > @@ -825,7 +825,6 @@ struct {
  >  	char *cache_name;
  >  	void (*cache_handle)(FILE *f);
  >  	FILE *f;
  > -	char vbuf[RPC_CHAN_BUF_SIZE];
  >  } cachelist[] = {
  >  	{ "auth.unix.ip", auth_unix_ip, NULL},
  >  	{ "auth.unix.gid", auth_unix_gid, NULL},
  > @@ -833,6 +832,9 @@ struct {
  >  	{ "nfsd.fh", nfsd_fh, NULL},
  >  	{ NULL, NULL, NULL }
  >  };
  > +struct vbs {
  > +	char vbuf[RPC_CHAN_BUF_SIZE];
  > +} vbufs [(sizeof(cachelist)/sizeof(cachelist[0])) - 1];

Weird--why does that make a difference? It's statically initialized memory either way, isn't it?

Quoted 8 lines
Quoted 5 lines

The problem is the vbuf item was added to the struct but no initializer was given for it. It could also have been fixed by supplying the missing initializer:

	{ "auth.unix.ip", auth_unix_ip, NULL, ""}, ...

Oh, OK. Then could we do that, Steve, instead of moving the buffer to a separate structure?

Good point... I thought I tried added a "" and it warnings still appeared, which was the reason for the extra structure.... I guess I was a bit confused... because by far adding "" is a much better fix....

thanks!

steved.