All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix warning: no return statement in function returning non-void in kernel/audit.c
@ 2006-09-11 15:15 Jesper Juhl
  2006-09-11 16:03 ` Dave Jones
  2006-09-11 22:56 ` Horst H. von Brand
  0 siblings, 2 replies; 6+ messages in thread
From: Jesper Juhl @ 2006-09-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: jesper.juhl, Rickard Faith


kauditd_thread() is being used in a call to kthread_run(). kthread_run() expects
a function returning 'int' which is also how kauditd_thread() is declared. Unfortunately
kauditd_thread() neglects to return a value which results in this complaint from gcc :

  kernel/audit.c:372: warning: no return statement in function returning non-void

Easily fixed by just adding a 'return 0;' to kauditd_thread().


Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---

 kernel/audit.c |    1 +
 1 file changed, 1 insertion(+)

--- linux-2.6.18-rc6-git3-orig/kernel/audit.c	2006-09-11 10:46:11.092786000 +0200
+++ linux-2.6.18-rc6-git3/kernel/audit.c	2006-09-11 17:08:00.888216381 +0200
@@ -369,6 +369,7 @@ static int kauditd_thread(void *dummy)
 			remove_wait_queue(&kauditd_wait, &wait);
 		}
 	}
+	return 0;
 }
 
 int audit_send_list(void *_dest)




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

* Re: [PATCH] fix warning: no return statement in function returning non-void in kernel/audit.c
  2006-09-11 15:15 [PATCH] fix warning: no return statement in function returning non-void in kernel/audit.c Jesper Juhl
@ 2006-09-11 16:03 ` Dave Jones
  2006-09-11 19:22   ` Jesper Juhl
  2006-09-11 22:56 ` Horst H. von Brand
  1 sibling, 1 reply; 6+ messages in thread
From: Dave Jones @ 2006-09-11 16:03 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: linux-kernel, Rickard Faith

On Mon, Sep 11, 2006 at 05:15:16PM +0200, Jesper Juhl wrote:
 > 
 > kauditd_thread() is being used in a call to kthread_run(). kthread_run() expects
 > a function returning 'int' which is also how kauditd_thread() is declared. Unfortunately
 > kauditd_thread() neglects to return a value which results in this complaint from gcc :
 > 
 >   kernel/audit.c:372: warning: no return statement in function returning non-void
 > 
 > Easily fixed by just adding a 'return 0;' to kauditd_thread().

Which will never be reached.  Does marking the function NORET_TYPE
also silence the warning?

	Dave

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

* Re: [PATCH] fix warning: no return statement in function returning non-void in kernel/audit.c
  2006-09-11 16:03 ` Dave Jones
@ 2006-09-11 19:22   ` Jesper Juhl
  2006-09-11 20:23     ` Dave Jones
  0 siblings, 1 reply; 6+ messages in thread
From: Jesper Juhl @ 2006-09-11 19:22 UTC (permalink / raw)
  To: Dave Jones, Jesper Juhl, linux-kernel, Rickard Faith

On 11/09/06, Dave Jones <davej@redhat.com> wrote:
> On Mon, Sep 11, 2006 at 05:15:16PM +0200, Jesper Juhl wrote:
>  >
>  > kauditd_thread() is being used in a call to kthread_run(). kthread_run() expects
>  > a function returning 'int' which is also how kauditd_thread() is declared. Unfortunately
>  > kauditd_thread() neglects to return a value which results in this complaint from gcc :
>  >
>  >   kernel/audit.c:372: warning: no return statement in function returning non-void
>  >
>  > Easily fixed by just adding a 'return 0;' to kauditd_thread().
>
> Which will never be reached.

True, and gcc even seems to optimize it out, since the size of audit.o
doesn't change with the patch applied... So, it does no harm and it
silences the warning - so why not?
I guess one could add a small /* never reached */ comment...


> Does marking the function NORET_TYPE
> also silence the warning?
>

Nope :(

This is with gcc 4.1.1 btw.

-- 
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

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

* Re: [PATCH] fix warning: no return statement in function returning non-void in kernel/audit.c
  2006-09-11 19:22   ` Jesper Juhl
@ 2006-09-11 20:23     ` Dave Jones
  0 siblings, 0 replies; 6+ messages in thread
From: Dave Jones @ 2006-09-11 20:23 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: linux-kernel, Rickard Faith

On Mon, Sep 11, 2006 at 09:22:15PM +0200, Jesper Juhl wrote:
 > >  > kauditd_thread() is being used in a call to kthread_run(). kthread_run() expects
 > >  > a function returning 'int' which is also how kauditd_thread() is declared. Unfortunately
 > >  > kauditd_thread() neglects to return a value which results in this complaint from gcc :
 > >  >
 > >  >   kernel/audit.c:372: warning: no return statement in function returning non-void
 > >  >
 > >  > Easily fixed by just adding a 'return 0;' to kauditd_thread().
 > >
 > > Which will never be reached.
 > 
 > True, and gcc even seems to optimize it out, since the size of audit.o
 > doesn't change with the patch applied... So, it does no harm and it
 > silences the warning - so why not?

Ah well, works for me :)

 > I guess one could add a small /* never reached */ comment...

Could do for completeness, though it should seem fairly obvious.

 > > Does marking the function NORET_TYPE
 > > also silence the warning?
 > Nope :(

Bah!

	Dave


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

* Re: [PATCH] fix warning: no return statement in function returning non-void in kernel/audit.c
  2006-09-11 15:15 [PATCH] fix warning: no return statement in function returning non-void in kernel/audit.c Jesper Juhl
  2006-09-11 16:03 ` Dave Jones
@ 2006-09-11 22:56 ` Horst H. von Brand
  2006-09-12  8:59   ` Jesper Juhl
  1 sibling, 1 reply; 6+ messages in thread
From: Horst H. von Brand @ 2006-09-11 22:56 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: linux-kernel, Rickard Faith

Jesper Juhl <jesper.juhl@gmail.com> wrote:
> kauditd_thread() is being used in a call to kthread_run(). kthread_run()
> expects a function returning 'int' which is also how kauditd_thread() is
> declared. Unfortunately kauditd_thread() neglects to return a value

It is an infinite loop...
>                                                                     which
> results in this complaint from gcc :

>   kernel/audit.c:372: warning: no return statement in function returning non-void

> Easily fixed by just adding a 'return 0;' to kauditd_thread().

How about marking it as never returning?
-- 
Dr. Horst H. von Brand                   User #22616 counter.li.org
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513

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

* Re: [PATCH] fix warning: no return statement in function returning non-void in kernel/audit.c
  2006-09-11 22:56 ` Horst H. von Brand
@ 2006-09-12  8:59   ` Jesper Juhl
  0 siblings, 0 replies; 6+ messages in thread
From: Jesper Juhl @ 2006-09-12  8:59 UTC (permalink / raw)
  To: Horst H. von Brand; +Cc: linux-kernel, Rickard Faith

On 12/09/06, Horst H. von Brand <vonbrand@inf.utfsm.cl> wrote:
> Jesper Juhl <jesper.juhl@gmail.com> wrote:
> > kauditd_thread() is being used in a call to kthread_run(). kthread_run()
> > expects a function returning 'int' which is also how kauditd_thread() is
> > declared. Unfortunately kauditd_thread() neglects to return a value
>
> It is an infinite loop...

I know. I'm just trying to get gcc to shut up.


> >                                                                     which
> > results in this complaint from gcc :
>
> >   kernel/audit.c:372: warning: no return statement in function returning non-void
>
> > Easily fixed by just adding a 'return 0;' to kauditd_thread().
>
> How about marking it as never returning?

Marking it NORET_TYPE doesn't do the trick, adding a 'return 0;' does.
And gcc optimizes the return away anyway, so the object file doesn't
increase in size, so it does no harm.

-- 
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

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

end of thread, other threads:[~2006-09-12  8:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-11 15:15 [PATCH] fix warning: no return statement in function returning non-void in kernel/audit.c Jesper Juhl
2006-09-11 16:03 ` Dave Jones
2006-09-11 19:22   ` Jesper Juhl
2006-09-11 20:23     ` Dave Jones
2006-09-11 22:56 ` Horst H. von Brand
2006-09-12  8:59   ` Jesper Juhl

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.