libreplace: fix coverity ID 517 - untangle close from open in test/os2_delete.c
authorMichael Adam <obnox@samba.org>
Thu, 27 Mar 2008 10:26:33 +0000 (11:26 +0100)
committerMichael Adam <obnox@samba.org>
Thu, 27 Mar 2008 10:56:51 +0000 (11:56 +0100)
This is not a proper bug but the code is clearer now
and we are tracking failure of open separate from that of close.

Michael

source/lib/replace/test/os2_delete.c

index c6ef180..b45c135 100644 (file)
@@ -39,8 +39,15 @@ static void create_files(void)
        int i;
        for (i=0;i<NUM_FILES;i++) {
                char fname[40];
+               int fd;
                sprintf(fname, TESTDIR "/test%u.txt", i);
-               close(open(fname, O_CREAT|O_RDWR, 0600)) == 0 || FAILED("close");
+               fd = open(fname, O_CREAT|O_RDWR, 0600);
+               if (fd < 0) {
+                       FAILED("open");
+               }
+               if (close(fd) != 0) {
+                       FAILED("close");
+               }
        }
 }