[rtems commit] fstests/fspermission: Fix resource leak

Sebastian Huber sebh at rtems.org
Fri Sep 13 14:42:40 UTC 2013


Module:    rtems
Branch:    master
Commit:    2477a39357e6a79c364377b147d56c81ff79c7d1
Changeset: http://git.rtems.org/rtems/commit/?id=2477a39357e6a79c364377b147d56c81ff79c7d1

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Sep 13 13:14:35 2013 +0200

fstests/fspermission: Fix resource leak

---

 testsuites/fstests/fspermission/test.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/testsuites/fstests/fspermission/test.c b/testsuites/fstests/fspermission/test.c
index e7aae20..60e0c79 100644
--- a/testsuites/fstests/fspermission/test.c
+++ b/testsuites/fstests/fspermission/test.c
@@ -203,6 +203,7 @@ static void test_premission01(void )
    *Create a file with mode 0777
    */
   fd=creat(file01,mode);
+  rtems_test_assert(fd >= 0);
   status=close(fd);
   rtems_test_assert(status==0);
   /*
@@ -210,6 +211,7 @@ static void test_premission01(void )
    */
 
   fd=creat(file02,0240);
+  rtems_test_assert(fd >= 0);
   status=close(fd);
   rtems_test_assert(status==0);
 
@@ -240,7 +242,10 @@ static void test_premission01(void )
   status=mkdir(directory01,0777);
   rtems_test_assert(status==0);
   sprintf(path,"%s/%s",directory01,file01);
-  fd=creat(path,0777);
+  fd = creat(path,0777);
+  rtems_test_assert(fd >= 0);
+  status = close(fd);
+  rtems_test_assert(status == 0);
 
   status=chmod(directory01,0340);
   rtems_test_assert (status == 0);
@@ -260,6 +265,7 @@ static void test_premission01(void )
    * Test write
    */
   fd=open(file01,O_WRONLY);
+  rtems_test_assert(fd >= 0);
   n=write(fd,test_data,len);
   rtems_test_assert(n==len);
   status=close(fd);
@@ -276,7 +282,7 @@ static void test_premission01(void )
    */
   data_buf=(char*)malloc(len+1);
   fd=open(file01,O_RDWR);
-  rtems_test_assert(fd!=-1);
+  rtems_test_assert(fd >= 0);
   n=read(fd,data_buf,len);
   rtems_test_assert(n==len);
   status=close(fd);
@@ -313,6 +319,7 @@ static void test_premission01(void )
   rtems_test_assert(status==0);
 
   fd=open(file01,O_WRONLY);
+  rtems_test_assert(fd >= 0);
   n=write(fd,test_data,len);
   rtems_test_assert(n==len);
   status=close(fd);




More information about the vc mailing list