2011-03-13 15:48:27

by Rakib Mullick

[permalink] [raw]
Subject: [PATCH] fs, coda: Fix compile warning when CONFIG_SYSCTL=n.

When CONFIG_SYSCTL=n, we get the following warning:

fs/coda/sysctl.c:18: warning: ?coda_table? defined but not used

Following patches fixes the above warning by making sure coda_table
and it's callee
function are in the same context. It also cleans up the code by
removing extra #ifdef.


Signed-off-by: Rakib Mullick <[email protected]>
---

diff --git a/fs/coda/sysctl.c b/fs/coda/sysctl.c
index c6405ce..d9cc2b3 100644
--- a/fs/coda/sysctl.c
+++ b/fs/coda/sysctl.c
@@ -13,7 +13,6 @@

#ifdef CONFIG_SYSCTL
static struct ctl_table_header *fs_table_header;
-#endif

static ctl_table coda_table[] = {
{
@@ -40,7 +39,6 @@ static ctl_table coda_table[] = {
{}
};

-#ifdef CONFIG_SYSCTL
static ctl_table fs_table[] = {
{
.procname = "coda",
@@ -49,22 +47,23 @@ static ctl_table fs_table[] = {
},
{}
};
-#endif

void coda_sysctl_init(void)
{
-#ifdef CONFIG_SYSCTL
if ( !fs_table_header )
fs_table_header = register_sysctl_table(fs_table);
-#endif
}

void coda_sysctl_clean(void)
{
-#ifdef CONFIG_SYSCTL
if ( fs_table_header ) {
unregister_sysctl_table(fs_table_header);
fs_table_header = NULL;
}
-#endif
}
+#else
+
+#define coda_sysctl_init() do { } while (0);
+#define coda_sysctl_clean() do { } while (0);
+
+#endif


2011-03-14 22:34:55

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] fs, coda: Fix compile warning when CONFIG_SYSCTL=n.

On Sun, 13 Mar 2011 21:48:23 +0600
Rakib Mullick <[email protected]> wrote:

> When CONFIG_SYSCTL=n, we get the following warning:
>
> fs/coda/sysctl.c:18: warning: ___coda_table___ defined but not used
>
> Following patches fixes the above warning by making sure coda_table
> and it's callee
> function are in the same context. It also cleans up the code by
> removing extra #ifdef.
>
> ...
>
> --- a/fs/coda/sysctl.c
> +++ b/fs/coda/sysctl.c
>
> ...
>
> +#else
> +
> +#define coda_sysctl_init() do { } while (0);
> +#define coda_sysctl_clean() do { } while (0);
> +
> +#endif

These do/while stubs should not have the trailing ";" - adding them
will cause breakage in some calling scenarios.

It is much better to implement such stubs in C rather than as macros.

But these stubs can't be doing anything useful anyway: they appear at
the end of a .c file which wasn't #included by anything. Therefore:

--- a/fs/coda/sysctl.c~fs-coda-fix-compile-warning-when-config_sysctl=n-fix
+++ a/fs/coda/sysctl.c
@@ -61,9 +61,4 @@ void coda_sysctl_clean(void)
fs_table_header = NULL;
}
}
-#else
-
-#define coda_sysctl_init() do { } while (0);
-#define coda_sysctl_clean() do { } while (0);
-
#endif
_

2011-03-15 03:27:37

by Rakib Mullick

[permalink] [raw]
Subject: Re: [PATCH] fs, coda: Fix compile warning when CONFIG_SYSCTL=n.

On Tue, Mar 15, 2011 at 4:34 AM, Andrew Morton
<[email protected]> wrote:
> On Sun, 13 Mar 2011 21:48:23 +0600
> Rakib Mullick <[email protected]> wrote:
>
> These do/while stubs should not have the trailing ";" - adding them
> will cause breakage in some calling scenarios.
>
I missed that, these stubs are not used by anything. I wasn't sure,
who knows, some random config might trigger some more warning. So I
kept it.

> It is much better to implement such stubs in C rather than as macros.
>
I'll remember.

> But these stubs can't be doing anything useful anyway: they appear at
> the end of a .c file which wasn't #included by anything. ?Therefore:
>
> --- a/fs/coda/sysctl.c~fs-coda-fix-compile-warning-when-config_sysctl=n-fix
> +++ a/fs/coda/sysctl.c
> @@ -61,9 +61,4 @@ void coda_sysctl_clean(void)
> ? ? ? ? ? ? ? ?fs_table_header = NULL;
> ? ? ? ?}
> ?}
> -#else
> -
> -#define ? ? ? ?coda_sysctl_init() ? ? ? ? ? ? ?do { } ?while (0);
> -#define ? ? ? ?coda_sysctl_clean() ? ? ? ? ? ? do { } ?while (0);
> -
> ?#endif
> _
>
>

2011-03-24 07:54:34

by Ingo Molnar

[permalink] [raw]
Subject: [origin tree build failure] Re: [PATCH] fs, coda: Fix compile warning when CONFIG_SYSCTL=n.


* Rakib Mullick <[email protected]> wrote:

> When CONFIG_SYSCTL=n, we get the following warning:
>
> fs/coda/sysctl.c:18: warning: ‘coda_table’ defined but not used
>
> Following patches fixes the above warning by making sure coda_table
> and it's callee
> function are in the same context. It also cleans up the code by
> removing extra #ifdef.
>
>
> Signed-off-by: Rakib Mullick <[email protected]>
> ---
>
> diff --git a/fs/coda/sysctl.c b/fs/coda/sysctl.c
> index c6405ce..d9cc2b3 100644
> --- a/fs/coda/sysctl.c
> +++ b/fs/coda/sysctl.c

FYI, the v2 of this patch:

0bc825d240ab: codafs: fix compile warning when CONFIG_SYSCTL=n

broke the upstream build:

fs/built-in.o: In function `init_coda':
psdev.c:(.init.text+0x2549): undefined reference to `coda_sysctl_clean'
fs/built-in.o: In function `exit_coda':
psdev.c:(.exit.text+0x1bf): undefined reference to `coda_sysctl_clean'
fs/built-in.o: In function `init_coda_psdev':
psdev.c:(.text.unlikely+0x21e1): undefined reference to `coda_sysctl_init'

I don't think the -v2 commit was build-tested with !CONFIG_PROC_SYSCTL &&
CONFIG_CODA_FS=y.

Ingo

2011-03-24 10:46:17

by Rakib Mullick

[permalink] [raw]
Subject: Re: [origin tree build failure] Re: [PATCH] fs, coda: Fix compile warning when CONFIG_SYSCTL=n.

On Thu, Mar 24, 2011 at 1:54 PM, Ingo Molnar <[email protected]> wrote:
>
> * Rakib Mullick <[email protected]> wrote:
>
>> When CONFIG_SYSCTL=n, we get the following warning:
>>
>> fs/coda/sysctl.c:18: warning: ?coda_table? defined but not used
>>
>> Following patches fixes the above warning by making sure coda_table
>> and it's callee
>> function are in the same context. It also cleans up the code by
>> removing extra #ifdef.
>>
>>
>> Signed-off-by: Rakib Mullick <[email protected]>
>> ---
>>
>> diff --git a/fs/coda/sysctl.c b/fs/coda/sysctl.c
>> index c6405ce..d9cc2b3 100644
>> --- a/fs/coda/sysctl.c
>> +++ b/fs/coda/sysctl.c
>
> FYI, the v2 of this patch:
>
> ?0bc825d240ab: codafs: fix compile warning when CONFIG_SYSCTL=n
>
> broke the upstream build:
>
> ?fs/built-in.o: In function `init_coda':
> ?psdev.c:(.init.text+0x2549): undefined reference to `coda_sysctl_clean'
> ?fs/built-in.o: In function `exit_coda':
> ?psdev.c:(.exit.text+0x1bf): undefined reference to `coda_sysctl_clean'
> ?fs/built-in.o: In function `init_coda_psdev':
> ?psdev.c:(.text.unlikely+0x21e1): undefined reference to `coda_sysctl_init'
>
> I don't think the -v2 commit was build-tested with !CONFIG_PROC_SYSCTL &&
> CONFIG_CODA_FS=y.
>
Andrew cleans up the unnecessary stubs. But, clearly removed
definition is necessary. And Yes, you are right, I didn't build test
it. Sorry for that. Please consider the following patch.

---
codafs: Fix build break when CONFIG_PROC_SYSCTL=n

Commit 0bc825d240ab (codafs: fix compile warning when
CONFIG_SYSCTL=n), introduces build breakage, when CONFIG_PROC_SYSCTL=n
and CONFIG_CODA_FS=y. This patch fixes it.

fs/built-in.o: In function `init_coda':
psdev.c:(.init.text+0xc02): undefined reference to `coda_sysctl_init'
psdev.c:(.init.text+0xc7c): undefined reference to `coda_sysctl_clean'
fs/built-in.o: In function `exit_coda':
psdev.c:(.exit.text+0xa9): undefined reference to `coda_sysctl_clean'
make: *** [.tmp_vmlinux1] Error 1

Signed-off-by: Rakib Mullick <[email protected]>
Reported-by: Ingo Molnar <[email protected]>
---

diff --git a/fs/coda/sysctl.c b/fs/coda/sysctl.c
index 06d27a4..af56ad5 100644
--- a/fs/coda/sysctl.c
+++ b/fs/coda/sysctl.c
@@ -61,4 +61,13 @@ void coda_sysctl_clean(void)
fs_table_header = NULL;
}
}
+
+#else
+void coda_sysctl_init(void)
+{
+}
+
+void coda_sysctl_clean(void)
+{
+}
#endif

2011-03-24 16:03:01

by Randy Dunlap

[permalink] [raw]
Subject: Re: [origin tree build failure] Re: [PATCH] fs, coda: Fix compile warning when CONFIG_SYSCTL=n.

On Thu, 24 Mar 2011 16:46:15 +0600 Rakib Mullick wrote:

> On Thu, Mar 24, 2011 at 1:54 PM, Ingo Molnar <[email protected]> wrote:
> >
> > * Rakib Mullick <[email protected]> wrote:
> >
> >> When CONFIG_SYSCTL=n, we get the following warning:
> >>
> >> fs/coda/sysctl.c:18: warning: ‘coda_table’ defined but not used
> >>
> >> Following patches fixes the above warning by making sure coda_table
> >> and it's callee
> >> function are in the same context. It also cleans up the code by
> >> removing extra #ifdef.
> >>
> >>
> >> Signed-off-by: Rakib Mullick <[email protected]>
> >> ---
> >>
> >> diff --git a/fs/coda/sysctl.c b/fs/coda/sysctl.c
> >> index c6405ce..d9cc2b3 100644
> >> --- a/fs/coda/sysctl.c
> >> +++ b/fs/coda/sysctl.c
> >
> > FYI, the v2 of this patch:
> >
> >  0bc825d240ab: codafs: fix compile warning when CONFIG_SYSCTL=n
> >
> > broke the upstream build:
> >
> >  fs/built-in.o: In function `init_coda':
> >  psdev.c:(.init.text+0x2549): undefined reference to `coda_sysctl_clean'
> >  fs/built-in.o: In function `exit_coda':
> >  psdev.c:(.exit.text+0x1bf): undefined reference to `coda_sysctl_clean'
> >  fs/built-in.o: In function `init_coda_psdev':
> >  psdev.c:(.text.unlikely+0x21e1): undefined reference to `coda_sysctl_init'
> >
> > I don't think the -v2 commit was build-tested with !CONFIG_PROC_SYSCTL &&
> > CONFIG_CODA_FS=y.
> >
> Andrew cleans up the unnecessary stubs. But, clearly removed
> definition is necessary. And Yes, you are right, I didn't build test
> it. Sorry for that. Please consider the following patch.
>
> ---
> codafs: Fix build break when CONFIG_PROC_SYSCTL=n
>
> Commit 0bc825d240ab (codafs: fix compile warning when
> CONFIG_SYSCTL=n), introduces build breakage, when CONFIG_PROC_SYSCTL=n
> and CONFIG_CODA_FS=y. This patch fixes it.
>
> fs/built-in.o: In function `init_coda':
> psdev.c:(.init.text+0xc02): undefined reference to `coda_sysctl_init'
> psdev.c:(.init.text+0xc7c): undefined reference to `coda_sysctl_clean'
> fs/built-in.o: In function `exit_coda':
> psdev.c:(.exit.text+0xa9): undefined reference to `coda_sysctl_clean'
> make: *** [.tmp_vmlinux1] Error 1
>
> Signed-off-by: Rakib Mullick <[email protected]>
> Reported-by: Ingo Molnar <[email protected]>

Acked-by: Randy Dunlap <[email protected]>

Thanks.

> ---
>
> diff --git a/fs/coda/sysctl.c b/fs/coda/sysctl.c
> index 06d27a4..af56ad5 100644
> --- a/fs/coda/sysctl.c
> +++ b/fs/coda/sysctl.c
> @@ -61,4 +61,13 @@ void coda_sysctl_clean(void)
> fs_table_header = NULL;
> }
> }
> +
> +#else
> +void coda_sysctl_init(void)
> +{
> +}
> +
> +void coda_sysctl_clean(void)
> +{
> +}
> #endif
> --
> 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/


---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***