All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kobject: Suppress compiler warning with gcc 3.x
@ 2010-06-03  5:23 Tetsuo Handa
  2010-06-03  5:31 ` Eric Dumazet
  0 siblings, 1 reply; 10+ messages in thread
From: Tetsuo Handa @ 2010-06-03  5:23 UTC (permalink / raw)
  To: ebiederm, randy.dunlap, gregkh; +Cc: linux-kernel

Gcc 3.x generates a warning

  include/linux/sysfs.h:183: warning: parameter has incomplete type

on each file.
Suppress the warning by moving the definition of "enum kobj_ns_type"
to before "#include <linux/sysfs.h>".

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
 include/linux/kobject.h |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

--- linux-2.6.35-rc1.orig/include/linux/kobject.h
+++ linux-2.6.35-rc1/include/linux/kobject.h
@@ -16,6 +16,16 @@
 #ifndef _KOBJECT_H_
 #define _KOBJECT_H_
 
+/*
+ * Namespace types which are used to tag kobjects and sysfs entries.
+ * Network namespace will likely be the first.
+ */
+enum kobj_ns_type {
+	KOBJ_NS_TYPE_NONE = 0,
+	KOBJ_NS_TYPE_NET,
+	KOBJ_NS_TYPES
+};
+
 #include <linux/types.h>
 #include <linux/list.h>
 #include <linux/sysfs.h>
@@ -136,16 +146,6 @@ struct kobj_attribute {
 
 extern const struct sysfs_ops kobj_sysfs_ops;
 
-/*
- * Namespace types which are used to tag kobjects and sysfs entries.
- * Network namespace will likely be the first.
- */
-enum kobj_ns_type {
-	KOBJ_NS_TYPE_NONE = 0,
-	KOBJ_NS_TYPE_NET,
-	KOBJ_NS_TYPES
-};
-
 struct sock;
 
 /*

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] kobject: Suppress compiler warning with gcc 3.x
  2010-06-03  5:23 [PATCH] kobject: Suppress compiler warning with gcc 3.x Tetsuo Handa
@ 2010-06-03  5:31 ` Eric Dumazet
  2010-06-03  5:55   ` Américo Wang
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Dumazet @ 2010-06-03  5:31 UTC (permalink / raw)
  To: Tetsuo Handa
  Cc: ebiederm, randy.dunlap, gregkh, linux-kernel, Eric W. Biederman

Le jeudi 03 juin 2010 à 14:23 +0900, Tetsuo Handa a écrit :
> Gcc 3.x generates a warning
> 
>   include/linux/sysfs.h:183: warning: parameter has incomplete type
> 
> on each file.
> Suppress the warning by moving the definition of "enum kobj_ns_type"
> to before "#include <linux/sysfs.h>".
> 
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>


I was about to submit same patch, but I was also reverting 27eabc7cb4b3
(sysfs: Don't use enums in inline function declaration.)

So that sysfs_exit_ns() prototype is consistent regardless of
CONFIG_SYSFS

What do you think ?


> ---
>  include/linux/kobject.h |   20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> --- linux-2.6.35-rc1.orig/include/linux/kobject.h
> +++ linux-2.6.35-rc1/include/linux/kobject.h
> @@ -16,6 +16,16 @@
>  #ifndef _KOBJECT_H_
>  #define _KOBJECT_H_
>  
> +/*
> + * Namespace types which are used to tag kobjects and sysfs entries.
> + * Network namespace will likely be the first.
> + */
> +enum kobj_ns_type {
> +	KOBJ_NS_TYPE_NONE = 0,
> +	KOBJ_NS_TYPE_NET,
> +	KOBJ_NS_TYPES
> +};
> +
>  #include <linux/types.h>
>  #include <linux/list.h>
>  #include <linux/sysfs.h>
> @@ -136,16 +146,6 @@ struct kobj_attribute {
>  
>  extern const struct sysfs_ops kobj_sysfs_ops;
>  
> -/*
> - * Namespace types which are used to tag kobjects and sysfs entries.
> - * Network namespace will likely be the first.
> - */
> -enum kobj_ns_type {
> -	KOBJ_NS_TYPE_NONE = 0,
> -	KOBJ_NS_TYPE_NET,
> -	KOBJ_NS_TYPES
> -};
> -
>  struct sock;
>  
>  /*



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] kobject: Suppress compiler warning with gcc 3.x
  2010-06-03  5:31 ` Eric Dumazet
@ 2010-06-03  5:55   ` Américo Wang
  2010-06-03  6:02     ` Eric W. Biederman
  0 siblings, 1 reply; 10+ messages in thread
From: Américo Wang @ 2010-06-03  5:55 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Tetsuo Handa, ebiederm, randy.dunlap, gregkh, linux-kernel,
	Eric W. Biederman

On Thu, Jun 03, 2010 at 07:31:41AM +0200, Eric Dumazet wrote:
>Le jeudi 03 juin 2010 à 14:23 +0900, Tetsuo Handa a écrit :
>> Gcc 3.x generates a warning
>> 
>>   include/linux/sysfs.h:183: warning: parameter has incomplete type
>> 
>> on each file.
>> Suppress the warning by moving the definition of "enum kobj_ns_type"
>> to before "#include <linux/sysfs.h>".
>> 
>> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
>
>
>I was about to submit same patch, but I was also reverting 27eabc7cb4b3
>(sysfs: Don't use enums in inline function declaration.)
>
>So that sysfs_exit_ns() prototype is consistent regardless of
>CONFIG_SYSFS
>
>What do you think ?
>

This looks odd, in sysfs.h we do have a forward declaration of
enum kobj_ns_type... I am wondering why gcc 3.x doesn't recognize it.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] kobject: Suppress compiler warning with gcc 3.x
  2010-06-03  5:55   ` Américo Wang
@ 2010-06-03  6:02     ` Eric W. Biederman
  2010-06-03  6:23       ` Américo Wang
  0 siblings, 1 reply; 10+ messages in thread
From: Eric W. Biederman @ 2010-06-03  6:02 UTC (permalink / raw)
  To: Américo Wang
  Cc: Eric Dumazet, Tetsuo Handa, ebiederm, randy.dunlap, gregkh, linux-kernel

Américo Wang <xiyou.wangcong@gmail.com> writes:

> On Thu, Jun 03, 2010 at 07:31:41AM +0200, Eric Dumazet wrote:
>>Le jeudi 03 juin 2010 à 14:23 +0900, Tetsuo Handa a écrit :
>>> Gcc 3.x generates a warning
>>> 
>>>   include/linux/sysfs.h:183: warning: parameter has incomplete type
>>> 
>>> on each file.
>>> Suppress the warning by moving the definition of "enum kobj_ns_type"
>>> to before "#include <linux/sysfs.h>".
>>> 
>>> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
>>
>>
>>I was about to submit same patch, but I was also reverting 27eabc7cb4b3
>>(sysfs: Don't use enums in inline function declaration.)
>>
>>So that sysfs_exit_ns() prototype is consistent regardless of
>>CONFIG_SYSFS
>>
>>What do you think ?
>>
>
> This looks odd, in sysfs.h we do have a forward declaration of
> enum kobj_ns_type... I am wondering why gcc 3.x doesn't recognize it.

Because the replacement is an inline, and we are passing the enum by value
gcc wants to see the full definition, at the point where the inline function
is declared.


Eric

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] kobject: Suppress compiler warning with gcc 3.x
  2010-06-03  6:02     ` Eric W. Biederman
@ 2010-06-03  6:23       ` Américo Wang
  2010-06-03  6:40         ` Eric W. Biederman
  2010-06-03  6:46         ` Eric Dumazet
  0 siblings, 2 replies; 10+ messages in thread
From: Américo Wang @ 2010-06-03  6:23 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: Américo Wang, Eric Dumazet, Tetsuo Handa, ebiederm,
	randy.dunlap, gregkh, linux-kernel

On Wed, Jun 02, 2010 at 11:02:28PM -0700, Eric W. Biederman wrote:
>Américo Wang <xiyou.wangcong@gmail.com> writes:
>
>> On Thu, Jun 03, 2010 at 07:31:41AM +0200, Eric Dumazet wrote:
>>>Le jeudi 03 juin 2010 à 14:23 +0900, Tetsuo Handa a écrit :
>>>> Gcc 3.x generates a warning
>>>> 
>>>>   include/linux/sysfs.h:183: warning: parameter has incomplete type
>>>> 
>>>> on each file.
>>>> Suppress the warning by moving the definition of "enum kobj_ns_type"
>>>> to before "#include <linux/sysfs.h>".
>>>> 
>>>> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
>>>
>>>
>>>I was about to submit same patch, but I was also reverting 27eabc7cb4b3
>>>(sysfs: Don't use enums in inline function declaration.)
>>>
>>>So that sysfs_exit_ns() prototype is consistent regardless of
>>>CONFIG_SYSFS
>>>
>>>What do you think ?
>>>
>>
>> This looks odd, in sysfs.h we do have a forward declaration of
>> enum kobj_ns_type... I am wondering why gcc 3.x doesn't recognize it.
>
>Because the replacement is an inline, and we are passing the enum by value
>gcc wants to see the full definition, at the point where the inline function
>is declared.
>

But sysfs_exit_ns() is not inlined if CONFIG_SYSFS here.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] kobject: Suppress compiler warning with gcc 3.x
  2010-06-03  6:23       ` Américo Wang
@ 2010-06-03  6:40         ` Eric W. Biederman
  2010-06-03  8:57           ` Américo Wang
  2010-06-03  6:46         ` Eric Dumazet
  1 sibling, 1 reply; 10+ messages in thread
From: Eric W. Biederman @ 2010-06-03  6:40 UTC (permalink / raw)
  To: Américo Wang
  Cc: Eric Dumazet, Tetsuo Handa, ebiederm, randy.dunlap, gregkh, linux-kernel

Américo Wang <xiyou.wangcong@gmail.com> writes:

> On Wed, Jun 02, 2010 at 11:02:28PM -0700, Eric W. Biederman wrote:
>>Américo Wang <xiyou.wangcong@gmail.com> writes:
>>
>>> On Thu, Jun 03, 2010 at 07:31:41AM +0200, Eric Dumazet wrote:
>>>>Le jeudi 03 juin 2010 à 14:23 +0900, Tetsuo Handa a écrit :
>>>>> Gcc 3.x generates a warning
>>>>> 
>>>>>   include/linux/sysfs.h:183: warning: parameter has incomplete type
>>>>> 
>>>>> on each file.
>>>>> Suppress the warning by moving the definition of "enum kobj_ns_type"
>>>>> to before "#include <linux/sysfs.h>".
>>>>> 
>>>>> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
>>>>
>>>>
>>>>I was about to submit same patch, but I was also reverting 27eabc7cb4b3
>>>>(sysfs: Don't use enums in inline function declaration.)
>>>>
>>>>So that sysfs_exit_ns() prototype is consistent regardless of
>>>>CONFIG_SYSFS
>>>>
>>>>What do you think ?
>>>>
>>>
>>> This looks odd, in sysfs.h we do have a forward declaration of
>>> enum kobj_ns_type... I am wondering why gcc 3.x doesn't recognize it.
>>
>>Because the replacement is an inline, and we are passing the enum by value
>>gcc wants to see the full definition, at the point where the inline function
>>is declared.
>>
>
> But sysfs_exit_ns() is not inlined if CONFIG_SYSFS here.

You are right gcc 3.x seems full of it.  I was thinking of the !CONFIG_SYSFS
case where I had to pull out the enum because it is in fact inlined.

If we are going to worry about gcc 3.x and about my !CONFIG_SYSFS
inline function the clean way to handle this seems to be to introduce
a new header file that both sysfs.h and kobject.h can include.
Assuming/requiring that files that include sysfs.h also include
kobject.h to seems like the wrong way to go.

Eric


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] kobject: Suppress compiler warning with gcc 3.x
  2010-06-03  6:23       ` Américo Wang
  2010-06-03  6:40         ` Eric W. Biederman
@ 2010-06-03  6:46         ` Eric Dumazet
  2010-06-03  8:52           ` Américo Wang
  1 sibling, 1 reply; 10+ messages in thread
From: Eric Dumazet @ 2010-06-03  6:46 UTC (permalink / raw)
  To: Américo Wang
  Cc: Eric W. Biederman, Tetsuo Handa, ebiederm, randy.dunlap, gregkh,
	linux-kernel

Le jeudi 03 juin 2010 à 14:23 +0800, Américo Wang a écrit :
> On Wed, Jun 02, 2010 at 11:02:28PM -0700, Eric W. Biederman wrote:
> >Américo Wang <xiyou.wangcong@gmail.com> writes:
> >
> >> On Thu, Jun 03, 2010 at 07:31:41AM +0200, Eric Dumazet wrote:
> >>>Le jeudi 03 juin 2010 à 14:23 +0900, Tetsuo Handa a écrit :
> >>>> Gcc 3.x generates a warning
> >>>> 
> >>>>   include/linux/sysfs.h:183: warning: parameter has incomplete type
> >>>> 
> >>>> on each file.
> >>>> Suppress the warning by moving the definition of "enum kobj_ns_type"
> >>>> to before "#include <linux/sysfs.h>".
> >>>> 
> >>>> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> >>>
> >>>
> >>>I was about to submit same patch, but I was also reverting 27eabc7cb4b3
> >>>(sysfs: Don't use enums in inline function declaration.)
> >>>
> >>>So that sysfs_exit_ns() prototype is consistent regardless of
> >>>CONFIG_SYSFS
> >>>
> >>>What do you think ?
> >>>
> >>
> >> This looks odd, in sysfs.h we do have a forward declaration of
> >> enum kobj_ns_type... I am wondering why gcc 3.x doesn't recognize it.
> >
> >Because the replacement is an inline, and we are passing the enum by value
> >gcc wants to see the full definition, at the point where the inline function
> >is declared.
> >
> 
> But sysfs_exit_ns() is not inlined if CONFIG_SYSFS here.
> 

 
# gcc -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk
--host=i386-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-10)


# cat try.c
enum kobj_ns_type;
void sysfs_exit_ns(enum kobj_ns_type type, const void *tag);
int main(int argc, char *argv[])
{
	return 0;
}
# gcc -O2 -Wall -o try try.c
try.c:2: warning: parameter has incomplete type
#



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] kobject: Suppress compiler warning with gcc 3.x
  2010-06-03  6:46         ` Eric Dumazet
@ 2010-06-03  8:52           ` Américo Wang
  0 siblings, 0 replies; 10+ messages in thread
From: Américo Wang @ 2010-06-03  8:52 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Américo Wang, Eric W. Biederman, Tetsuo Handa, ebiederm,
	randy.dunlap, gregkh, linux-kernel

On Thu, Jun 03, 2010 at 08:46:27AM +0200, Eric Dumazet wrote:
>Le jeudi 03 juin 2010 à 14:23 +0800, Américo Wang a écrit :
>> On Wed, Jun 02, 2010 at 11:02:28PM -0700, Eric W. Biederman wrote:
>> >Américo Wang <xiyou.wangcong@gmail.com> writes:
>> >
>> >> On Thu, Jun 03, 2010 at 07:31:41AM +0200, Eric Dumazet wrote:
>> >>>Le jeudi 03 juin 2010 à 14:23 +0900, Tetsuo Handa a écrit :
>> >>>> Gcc 3.x generates a warning
>> >>>> 
>> >>>>   include/linux/sysfs.h:183: warning: parameter has incomplete type
>> >>>> 
>> >>>> on each file.
>> >>>> Suppress the warning by moving the definition of "enum kobj_ns_type"
>> >>>> to before "#include <linux/sysfs.h>".
>> >>>> 
>> >>>> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
>> >>>
>> >>>
>> >>>I was about to submit same patch, but I was also reverting 27eabc7cb4b3
>> >>>(sysfs: Don't use enums in inline function declaration.)
>> >>>
>> >>>So that sysfs_exit_ns() prototype is consistent regardless of
>> >>>CONFIG_SYSFS
>> >>>
>> >>>What do you think ?
>> >>>
>> >>
>> >> This looks odd, in sysfs.h we do have a forward declaration of
>> >> enum kobj_ns_type... I am wondering why gcc 3.x doesn't recognize it.
>> >
>> >Because the replacement is an inline, and we are passing the enum by value
>> >gcc wants to see the full definition, at the point where the inline function
>> >is declared.
>> >
>> 
>> But sysfs_exit_ns() is not inlined if CONFIG_SYSFS here.
>> 
>
> 
># gcc -v
>Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.6/specs
>Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
>--infodir=/usr/share/info --enable-shared --enable-threads=posix
>--disable-checking --with-system-zlib --enable-__cxa_atexit
>--disable-libunwind-exceptions --enable-java-awt=gtk
>--host=i386-redhat-linux
>Thread model: posix
>gcc version 3.4.6 20060404 (Red Hat 3.4.6-10)
>
>
># cat try.c
>enum kobj_ns_type;
>void sysfs_exit_ns(enum kobj_ns_type type, const void *tag);
>int main(int argc, char *argv[])
>{
>	return 0;
>}
># gcc -O2 -Wall -o try try.c
>try.c:2: warning: parameter has incomplete type

This sounds like a bug of gcc 3.x, gcc 4.x would complain about it.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] kobject: Suppress compiler warning with gcc 3.x
  2010-06-03  6:40         ` Eric W. Biederman
@ 2010-06-03  8:57           ` Américo Wang
  2010-06-03  9:32             ` Eric Dumazet
  0 siblings, 1 reply; 10+ messages in thread
From: Américo Wang @ 2010-06-03  8:57 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: Américo Wang, Eric Dumazet, Tetsuo Handa, ebiederm,
	randy.dunlap, gregkh, linux-kernel

On Wed, Jun 02, 2010 at 11:40:12PM -0700, Eric W. Biederman wrote:
>Américo Wang <xiyou.wangcong@gmail.com> writes:
>
>> On Wed, Jun 02, 2010 at 11:02:28PM -0700, Eric W. Biederman wrote:
>>>Américo Wang <xiyou.wangcong@gmail.com> writes:
>>>
>>>> On Thu, Jun 03, 2010 at 07:31:41AM +0200, Eric Dumazet wrote:
>>>>>Le jeudi 03 juin 2010 à 14:23 +0900, Tetsuo Handa a écrit :
>>>>>> Gcc 3.x generates a warning
>>>>>> 
>>>>>>   include/linux/sysfs.h:183: warning: parameter has incomplete type
>>>>>> 
>>>>>> on each file.
>>>>>> Suppress the warning by moving the definition of "enum kobj_ns_type"
>>>>>> to before "#include <linux/sysfs.h>".
>>>>>> 
>>>>>> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
>>>>>
>>>>>
>>>>>I was about to submit same patch, but I was also reverting 27eabc7cb4b3
>>>>>(sysfs: Don't use enums in inline function declaration.)
>>>>>
>>>>>So that sysfs_exit_ns() prototype is consistent regardless of
>>>>>CONFIG_SYSFS
>>>>>
>>>>>What do you think ?
>>>>>
>>>>
>>>> This looks odd, in sysfs.h we do have a forward declaration of
>>>> enum kobj_ns_type... I am wondering why gcc 3.x doesn't recognize it.
>>>
>>>Because the replacement is an inline, and we are passing the enum by value
>>>gcc wants to see the full definition, at the point where the inline function
>>>is declared.
>>>
>>
>> But sysfs_exit_ns() is not inlined if CONFIG_SYSFS here.
>
>You are right gcc 3.x seems full of it.  I was thinking of the !CONFIG_SYSFS
>case where I had to pull out the enum because it is in fact inlined.
>
>If we are going to worry about gcc 3.x and about my !CONFIG_SYSFS
>inline function the clean way to handle this seems to be to introduce
>a new header file that both sysfs.h and kobject.h can include.

Agreed.

>Assuming/requiring that files that include sysfs.h also include
>kobject.h to seems like the wrong way to go.


Yeah.

However, this compile warning only appears in gcc 3.x
and it seems it's a fault of gcc 3.x, not the code. I am wondering
if we need to fix it.

Thanks.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] kobject: Suppress compiler warning with gcc 3.x
  2010-06-03  8:57           ` Américo Wang
@ 2010-06-03  9:32             ` Eric Dumazet
  0 siblings, 0 replies; 10+ messages in thread
From: Eric Dumazet @ 2010-06-03  9:32 UTC (permalink / raw)
  To: Américo Wang
  Cc: Eric W. Biederman, Tetsuo Handa, ebiederm, randy.dunlap, gregkh,
	linux-kernel

Le jeudi 03 juin 2010 à 16:57 +0800, Américo Wang a écrit :

> 
> Yeah.
> 
> However, this compile warning only appears in gcc 3.x
> and it seems it's a fault of gcc 3.x, not the code. I am wondering
> if we need to fix it.
> 

I believe gcc-3 was born before the code you mention.

We can keep ability to compile kernel on old gcc for very litle care.

Lets do it please, unless there is a real show-stopper, not because
we feel gcc-3 is 'old'



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-06-03  9:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-03  5:23 [PATCH] kobject: Suppress compiler warning with gcc 3.x Tetsuo Handa
2010-06-03  5:31 ` Eric Dumazet
2010-06-03  5:55   ` Américo Wang
2010-06-03  6:02     ` Eric W. Biederman
2010-06-03  6:23       ` Américo Wang
2010-06-03  6:40         ` Eric W. Biederman
2010-06-03  8:57           ` Américo Wang
2010-06-03  9:32             ` Eric Dumazet
2010-06-03  6:46         ` Eric Dumazet
2010-06-03  8:52           ` Américo Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.