2009-12-16 22:23:46

by Randy Dunlap

[permalink] [raw]
Subject: [PATCH -next] nfs: fix ISO C90 warning

From: Randy Dunlap <[email protected]>

Fix gcc ISO C90 warning:

fs/nfs/callback.c:356: warning: ISO C90 forbids mixed declarations and code

Signed-off-by: Randy Dunlap <[email protected]>
---
fs/nfs/callback.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-next-20091215.orig/fs/nfs/callback.c
+++ linux-next-20091215/fs/nfs/callback.c
@@ -352,8 +352,8 @@ static int check_gss_callback_principal(
static int nfs_callback_authenticate(struct svc_rqst *rqstp)
{
struct nfs_client *clp;
- RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);
int ret = SVC_OK;
+ RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);

/* Don't talk to strangers */
clp = nfs_find_client(svc_addr(rqstp), 4);


2009-12-16 22:40:19

by Trond Myklebust

[permalink] [raw]
Subject: Re: [PATCH -next] nfs: fix ISO C90 warning

On Wed, 2009-12-16 at 14:23 -0800, Randy Dunlap wrote:
> From: Randy Dunlap <[email protected]>
>
> Fix gcc ISO C90 warning:
>
> fs/nfs/callback.c:356: warning: ISO C90 forbids mixed declarations and code
>
> Signed-off-by: Randy Dunlap <[email protected]>
> ---
> fs/nfs/callback.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- linux-next-20091215.orig/fs/nfs/callback.c
> +++ linux-next-20091215/fs/nfs/callback.c
> @@ -352,8 +352,8 @@ static int check_gss_callback_principal(
> static int nfs_callback_authenticate(struct svc_rqst *rqstp)
> {
> struct nfs_client *clp;
> - RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);
> int ret = SVC_OK;
> + RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);
>

What version of gcc is giving rise to this warning?

RPC_IFDEBUG is a macro that either evaluates to its argument, or to
nothing, depending on whether or not RPC_DEBUG is defined or not. In
neither case should it evaluate to anything illegal under C90 rules
afaics.

Trond

2009-12-16 22:47:00

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH -next] nfs: fix ISO C90 warning

On Wed, 16 Dec 2009 17:40:19 -0500 Trond Myklebust wrote:

> On Wed, 2009-12-16 at 14:23 -0800, Randy Dunlap wrote:
> > From: Randy Dunlap <[email protected]>
> >
> > Fix gcc ISO C90 warning:
> >
> > fs/nfs/callback.c:356: warning: ISO C90 forbids mixed declarations and code
> >
> > Signed-off-by: Randy Dunlap <[email protected]>
> > ---
> > fs/nfs/callback.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > --- linux-next-20091215.orig/fs/nfs/callback.c
> > +++ linux-next-20091215/fs/nfs/callback.c
> > @@ -352,8 +352,8 @@ static int check_gss_callback_principal(
> > static int nfs_callback_authenticate(struct svc_rqst *rqstp)
> > {
> > struct nfs_client *clp;
> > - RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);
> > int ret = SVC_OK;
> > + RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);
> >
>
> What version of gcc is giving rise to this warning?

> gcc --version
gcc (GCC) 4.2.1 (SUSE Linux)

> RPC_IFDEBUG is a macro that either evaluates to its argument, or to
> nothing, depending on whether or not RPC_DEBUG is defined or not. In
> neither case should it evaluate to anything illegal under C90 rules
> afaics.

Yep. Odd warning.


---
~Randy

2009-12-16 22:58:37

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [PATCH -next] nfs: fix ISO C90 warning

On Wed, 16 Dec 2009, Randy Dunlap wrote:
> On Wed, 16 Dec 2009 17:40:19 -0500 Trond Myklebust wrote:
>
> > On Wed, 2009-12-16 at 14:23 -0800, Randy Dunlap wrote:
> > > From: Randy Dunlap <[email protected]>
> > >
> > > Fix gcc ISO C90 warning:
> > >
> > > fs/nfs/callback.c:356: warning: ISO C90 forbids mixed declarations and code
> > >
> > > Signed-off-by: Randy Dunlap <[email protected]>
> > > ---
> > > fs/nfs/callback.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > --- linux-next-20091215.orig/fs/nfs/callback.c
> > > +++ linux-next-20091215/fs/nfs/callback.c
> > > @@ -352,8 +352,8 @@ static int check_gss_callback_principal(
> > > static int nfs_callback_authenticate(struct svc_rqst *rqstp)
> > > {
> > > struct nfs_client *clp;
> > > - RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);
> > > int ret = SVC_OK;
> > > + RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);
> > >
> >
> > What version of gcc is giving rise to this warning?
>
> > gcc --version
> gcc (GCC) 4.2.1 (SUSE Linux)
>
> > RPC_IFDEBUG is a macro that either evaluates to its argument, or to
> > nothing, depending on whether or not RPC_DEBUG is defined or not. In
> > neither case should it evaluate to anything illegal under C90 rules
> > afaics.
>
> Yep. Odd warning.

Not really. If the debug macro evaluates to nothing then you have:

struct nfs_client *clp;
;
int ret = SVC_OK;

So you have a stray semicolon, which is interpreted as an empty code
line. That qualifies for the mixed declaration and code case :)

I know it's nitpicking, but ...

Thanks,

tglx

2009-12-16 23:01:37

by Trond Myklebust

[permalink] [raw]
Subject: Re: [PATCH -next] nfs: fix ISO C90 warning

On Wed, 2009-12-16 at 23:58 +0100, Thomas Gleixner wrote:
> On Wed, 16 Dec 2009, Randy Dunlap wrote:
> > On Wed, 16 Dec 2009 17:40:19 -0500 Trond Myklebust wrote:
> >
> > > On Wed, 2009-12-16 at 14:23 -0800, Randy Dunlap wrote:
> > > > From: Randy Dunlap <[email protected]>
> > > >
> > > > Fix gcc ISO C90 warning:
> > > >
> > > > fs/nfs/callback.c:356: warning: ISO C90 forbids mixed declarations and code
> > > >
> > > > Signed-off-by: Randy Dunlap <[email protected]>
> > > > ---
> > > > fs/nfs/callback.c | 2 +-
> > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > --- linux-next-20091215.orig/fs/nfs/callback.c
> > > > +++ linux-next-20091215/fs/nfs/callback.c
> > > > @@ -352,8 +352,8 @@ static int check_gss_callback_principal(
> > > > static int nfs_callback_authenticate(struct svc_rqst *rqstp)
> > > > {
> > > > struct nfs_client *clp;
> > > > - RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);
> > > > int ret = SVC_OK;
> > > > + RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);
> > > >
> > >
> > > What version of gcc is giving rise to this warning?
> >
> > > gcc --version
> > gcc (GCC) 4.2.1 (SUSE Linux)
> >
> > > RPC_IFDEBUG is a macro that either evaluates to its argument, or to
> > > nothing, depending on whether or not RPC_DEBUG is defined or not. In
> > > neither case should it evaluate to anything illegal under C90 rules
> > > afaics.
> >
> > Yep. Odd warning.
>
> Not really. If the debug macro evaluates to nothing then you have:
>
> struct nfs_client *clp;
> ;
> int ret = SVC_OK;
>
> So you have a stray semicolon, which is interpreted as an empty code
> line. That qualifies for the mixed declaration and code case :)
>
> I know it's nitpicking, but ...

Ah... I see what you mean.

So really what we should do is just move that semicolon inside the
macro. That would change the !RPC_DEBUG case to

struct nfs_client *clp;

int ret = SVC_OK;

which is 100% legal...

Cheers
Trond

2009-12-17 10:00:29

by Cong Wang

[permalink] [raw]
Subject: Re: [PATCH -next] nfs: fix ISO C90 warning

On Thu, Dec 17, 2009 at 7:01 AM, Trond Myklebust
<[email protected]> wrote:
> On Wed, 2009-12-16 at 23:58 +0100, Thomas Gleixner wrote:
>> On Wed, 16 Dec 2009, Randy Dunlap wrote:
>> > On Wed, 16 Dec 2009 17:40:19 -0500 Trond Myklebust wrote:
>> >
>> > > On Wed, 2009-12-16 at 14:23 -0800, Randy Dunlap wrote:
>> > > > From: Randy Dunlap <[email protected]>
>> > > >
>> > > > Fix gcc ISO C90 warning:
>> > > >
>> > > > fs/nfs/callback.c:356: warning: ISO C90 forbids mixed declarations and code
>> > > >
>> > > > Signed-off-by: Randy Dunlap <[email protected]>
>> > > > ---
>> > > >  fs/nfs/callback.c |    2 +-
>> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
>> > > >
>> > > > --- linux-next-20091215.orig/fs/nfs/callback.c
>> > > > +++ linux-next-20091215/fs/nfs/callback.c
>> > > > @@ -352,8 +352,8 @@ static int check_gss_callback_principal(
>> > > >  static int nfs_callback_authenticate(struct svc_rqst *rqstp)
>> > > >  {
>> > > >         struct nfs_client *clp;
>> > > > -       RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);
>> > > >         int ret = SVC_OK;
>> > > > +       RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);
>> > > >
>> > >
>> > > What version of gcc is giving rise to this warning?
>> >
>> > > gcc --version
>> > gcc (GCC) 4.2.1 (SUSE Linux)
>> >
>> > > RPC_IFDEBUG is a macro that either evaluates to its argument, or to
>> > > nothing, depending on whether or not RPC_DEBUG is defined or not. In
>> > > neither case should it evaluate to anything illegal under C90 rules
>> > > afaics.
>> >
>> > Yep.  Odd warning.
>>
>> Not really. If the debug macro evaluates to nothing then you have:
>>
>>     struct nfs_client *clp;
>>     ;
>>     int ret = SVC_OK;
>>
>> So you have a stray semicolon, which is interpreted as an empty code
>> line. That qualifies for the mixed declaration and code case :)
>>
>> I know it's nitpicking, but ...
>
> Ah... I see what you mean.
>
> So really what we should do is just move that semicolon inside the
> macro. That would change the !RPC_DEBUG case to
>
>    struct nfs_client *clp;
>
>    int ret = SVC_OK;
>
> which is 100% legal...
>

Hi,
Check that currently all usages of RPC_DEBUG are the same,
we can replace them all.

What do you think about the attached patch?

Sorry for attaching it, I have a bad mail environment here.

Signed-off-by: WANG Cong <[email protected]>


Attachments:
rpc-replace-rpc-ifdebug.diff (2.93 kB)

2009-12-17 21:58:26

by Trond Myklebust

[permalink] [raw]
Subject: Re: [PATCH -next] nfs: fix ISO C90 warning

On Thu, 2009-12-17 at 18:00 +0800, Am=C3=A9rico Wang wrote:=20
> Hi,
> Check that currently all usages of RPC_DEBUG are the same,
> we can replace them all.
>=20
> What do you think about the attached patch?
>=20
> Sorry for attaching it, I have a bad mail environment here.
>=20
> Signed-off-by: WANG Cong <[email protected]>

Doesn't that approach instead lead to a lot of 'unreferenced variable'
warnings in the '#undef RPC_DEBUG' case?

Cheers
Trond