Skip to contentSkip to conversation

fix missing return in several files.

PATCH In review Cyril Hrubis 1 participant 3 messages May 18, 2009 – May 22, 2009 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix missing return in several files.

Hi,
these three patches fixes missing return 0; statements.

Signature · 2 lines
Cyril Hrubis
[email protected]
testcases/kernel/io/aio/aio02/main.c +3 -1
Index: ltp-full-20090430/testcases/kernel/io/aio/aio02/main.c
===================================================================
@@ -34,7 +34,9 @@ int TST_TOTAL=0;
 
 int main(void)
 {
-  tst_brkm(TCONF, tst_exit, "libaio missing");
+	tst_brkm(TCONF, tst_exit, "libaio missing");
+
+	return 0;
 }
 
 #endif
testcases/kernel/io/aio/aio01/aio01.c +3 -1
Index: ltp-full-20090430/testcases/kernel/io/aio/aio01/aio01.c
===================================================================
@@ -426,7 +426,9 @@ void cleanup() {
 
 int main(void)
 {
-  tst_brkm(TCONF, tst_exit, "libaio missing");
+	tst_brkm(TCONF, tst_exit, "libaio missing");
+
+	return 0;
 }
 
 #endif
testcases/kernel/security/integrity/ima/src/ima_mmap.c +2 -0
Index: ltp-full-20090430/testcases/kernel/security/integrity/ima/src/ima_mmap.c
===================================================================
@@ -48,4 +48,6 @@ int main(int argc, char *argv[])
 		perror("unmap");
 		return(-1);
 	}
+
+	return 0;
 }

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Hi,

Quoted 7 lines

testcases/kernel/io/aio/aio02/main.c int TST_TOTAL=0; · line 39

Quoted 6 lines

int main(void)
{

testcases/kernel/io/aio/aio02/main.c +3 -1
-  tst_brkm(TCONF, tst_exit, "libaio missing");
+       tst_brkm(TCONF, tst_exit, "libaio missing");
+
+       return 0;
Quoted 7 lines

This is not necessary as tst_exit() will automatically return appropriate value depending on whether it is TCONF, TPASS, TFAIL, etc. And for TCONF it already returns 0.

Probably you will get a build warning saying:

Noting returns although prototype says something should return.

Well it breaks building suse rpm package as buildservice system treats these kind of warning as errors and it's IMHO harmless to add these returns in the code.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 8 lines
Quoted 2 lines

Well it breaks building suse rpm package as buildservice system treats these kind of warning as errors and it's IMHO harmless to add these returns in the code.

Strange. But, in LTP convention, tst_exit() is used which in turn does a return $EXIT_CODE on it?? own. We do not interfere. return 0/1 exists in LTP code only when we have not detected that, or, it has been lying there old. Else, for new tests and when submitting patches we convert all returns to tst_exit().

Yes tst_exit calls exit() call which does some magick that terminates running process and returns value passed to that function. So the code iself is correct. But compiler is not smart enough to see that. And as indirect call to exit() is only situation I'm aware of where missing return is not a bug, it's not so dumb to treat this kind of warning as error. And some buildsystems does so.

There are several possibilities that can avoid this kind of problem.

a) Add return 0, to those main() functions to make buildsystem happy. That's perfectly harmless as the code never gets makes it to this return 0; But it's not clean solution anyway.

b) Add tst_exitval() function that do the same as tst_exit but instead of exiting returns value passed to exit() call. So the code would look like:

   return tst_exitval();

c) Leave it this way and force people who are doing packages to patch all these files on their own.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list