2006-09-11 15:15:34

by Jesper Juhl

[permalink] [raw]
Subject: [PATCH] fix warning: no return statement in function returning non-void in kernel/audit.c


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 <[email protected]>
---

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)




2006-09-11 15:56:19

by Dave Jones

[permalink] [raw]
Subject: Re: [PATCH] fix warning: no return statement in function returning non-void in kernel/audit.c

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

2006-09-11 19:22:17

by Jesper Juhl

[permalink] [raw]
Subject: Re: [PATCH] fix warning: no return statement in function returning non-void in kernel/audit.c

On 11/09/06, Dave Jones <[email protected]> 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 <[email protected]>
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

2006-09-11 20:16:35

by Dave Jones

[permalink] [raw]
Subject: Re: [PATCH] fix warning: no return statement in function returning non-void in kernel/audit.c

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

2006-09-11 22:57:17

by Horst H. von Brand

[permalink] [raw]
Subject: Re: [PATCH] fix warning: no return statement in function returning non-void in kernel/audit.c

Jesper Juhl <[email protected]> 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

2006-09-12 08:59:48

by Jesper Juhl

[permalink] [raw]
Subject: Re: [PATCH] fix warning: no return statement in function returning non-void in kernel/audit.c

On 12/09/06, Horst H. von Brand <[email protected]> wrote:
> Jesper Juhl <[email protected]> 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 <[email protected]>
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