Skip to contentSkip to conversation

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

PATCH In review Jesper Juhl 3 participants 6 messages Sep 11, 2006 – Sep 12, 2006 Audit

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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().

---

 kernel/audit.c |    1 +
 1 file changed, 1 insertion(+)
kernel/audit.c +1 -0
@@ -369,6 +369,7 @@ static int kauditd_thread(void *dummy)
 			remove_wait_queue(&kauditd_wait, &wait);
 		}
 	}
+	return 0;
 }
 
 int audit_send_list(void *_dest)
#1 lore raw
Quoted 8 lines · Jesper Juhl

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

#2 lore raw
Quoted 11 lines · Dave Jones
Quoted 8 lines · Jesper Juhl

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...

Quoted 3 lines

Does marking the function NORET_TYPE
also silence the warning?

Nope :(

This is with gcc 4.1.1 btw.

Signature · 3 lines
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
#3 lore raw
Quoted 6 lines · Jesper Juhl
Quoted 6 lines
Quoted 6 lines

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

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

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 :)

Quoted 1 line

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

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

Quoted 3 lines
Quoted 2 lines

Does marking the function NORET_TYPE
also silence the warning?

Nope :(

Bah!

Dave

#4 lore raw
In reply to Jesper Juhl
Quoted 3 lines · Jesper Juhl

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...

Quoted 6 lines

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?

Signature · 4 lines
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
#5 lore raw
Quoted 6 lines · Horst H. von Brand
Quoted 3 lines · Jesper Juhl

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.

Quoted 8 lines
Quoted 6 lines

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.

Signature · 3 lines
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