Hi,
References: <[EMAIL PROTECTED]>
Content-Disposition: inline; filename=fix-compiler-warning-ftest04.diff

Fix warning about _is_ unused variable (note the difference between "may" and 
"is" unused!).
Only child opens the file descriptor, once forked.

ftest04.c: In function 'runtest':
ftest04.c:188: warning: 'fd' is used uninitialized in this function

Valgrind spot this issue as well:
==15263== Syscall param close(fd) contains uninitialised byte(s)
==15263==    at 0x4BD70A0: __close_nocancel (in /lib64/libc-2.4.so)
==15263==    by 0x401CD6: runtest (ftest04.c:188)
==15263==    by 0x401AD0: main (ftest04.c:111)

Fix tested on SLES 10 SP2:
:~/ltp/ltp-full-20080825/:[0]# ./testcases/kernel/fs/ftest/ftest04
ftest04     1  PASS  :  Test passed.

Sigend-off-by: Daniel Gollub <[EMAIL PROTECTED]>

---
 testcases/kernel/fs/ftest/ftest04.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: ltp-full-20080825/testcases/kernel/fs/ftest/ftest04.c
===================================================================
--- ltp-full-20080825.orig/testcases/kernel/fs/ftest/ftest04.c
+++ ltp-full-20080825/testcases/kernel/fs/ftest/ftest04.c
@@ -183,9 +183,9 @@ int runtest()
                                tst_exit();
                        }
                        dotest(nchild, i, fd);          /* do it! */
+                       close(fd);
                        tst_exit();                     /* when done, exit */
                }
-               close(fd);
                if (child < 0) {
                         tst_resm(TINFO, "System resource may be too low, 
fork() malloc()"
                                           " etc are likely to fail.");


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to