Index: /tags/ipp-20101215/Ohana/src/tools/src/roc.c
===================================================================
--- /tags/ipp-20101215/Ohana/src/tools/src/roc.c	(revision 30426)
+++ /tags/ipp-20101215/Ohana/src/tools/src/roc.c	(revision 30427)
@@ -4,5 +4,6 @@
 # include <regex.h>
 
-# define myAssert(LOGIC,MSG) { if (!(LOGIC)) { fprintf (stderr, "%s\n", MSG); abort(); } }
+// # define myAssert(LOGIC,MSG) { if (!(LOGIC)) { fprintf (stderr, "%s\n", MSG); abort(); } }
+# define myAssert(LOGIC,MSG) { if (!(LOGIC)) { fprintf (stderr, "%s\n", MSG); exit(1); } }
 
 # define ROC_HEADER_SIZE  0x1000
@@ -30,10 +31,11 @@
 
   usage();
-  exit (1);
+  exit (2);
 }
 
 int roc_create (int argc, char **argv) {
 
-  int i, j, n, Ninput, result, Nblocks, header_size, size_off, Noff, Nbytes, Nread;
+  int i, j, n, Ninput, result, Nblocks, header_size, size_off;
+  int status, Noff, Nbytes, Nread, Nwrite;
   off_t maxSize, *sizes, *bytes_read;
   char value;
@@ -121,5 +123,6 @@
   myAssert (target, "failed to open output");
 
-  fwrite (header, 1, header_size, target);
+  Nwrite = fwrite (header, 1, header_size, target);
+  myAssert (Nwrite == header_size, "failed to write header");
 
   ALLOCATE (inputData, char *, Ninput);
@@ -134,4 +137,5 @@
       Nbytes = fread (inputData[i], 1, Nread, input[i]);
       myAssert (Nbytes == Nread, "failed to read data");
+
       if (Nread < ROC_BLOCKSIZE) {
 	// if we have reached the end of the file, fill in the rest with NULLs
@@ -149,6 +153,10 @@
     }
 
-    fwrite (outputData, 1, ROC_BLOCKSIZE, target);
-  }
+    Nwrite = fwrite (outputData, 1, ROC_BLOCKSIZE, target);
+    myAssert (Nwrite == ROC_BLOCKSIZE, "failed to write data block");
+  }
+
+  status = fclose (target);
+  myAssert (!status, "failed to close rocfile");
 
   exit (0);
@@ -157,5 +165,6 @@
 int roc_repair (int argc, char **argv) {
 
-  int i, j, n, Ninput, Nblocks, header_size, Nbytes, Nread, Nfile, Nwrite;
+  int i, j, n, Ninput, Nblocks, header_size, Nbytes;
+  int status, Nread, Nfile, Nwrite;
   off_t *sizes, *bytes_read;
   char value;
@@ -201,5 +210,6 @@
   // read the full header
   fseeko (target, 0, SEEK_SET);
-  fread (header, 1, header_size, target);
+  Nread = fread (header, 1, header_size, target);
+  myAssert (Nread == header_size, "failed to read header");
 
   ptr = header;
@@ -252,4 +262,5 @@
       Nbytes = fread (inputData[i], 1, Nread, input[i]);
       myAssert (Nbytes == Nread, "failed to read data");
+
       if (Nread < ROC_BLOCKSIZE) {
 	// if we have reached the end of the file, fill in the rest with NULLs
@@ -258,5 +269,6 @@
       bytes_read[i] += Nread;
     }
-    fread (targetData, 1, ROC_BLOCKSIZE, target);
+    Nread = fread (targetData, 1, ROC_BLOCKSIZE, target);
+    myAssert (Nread == ROC_BLOCKSIZE, "failed to read from target");
     
     for (j = 0; j < ROC_BLOCKSIZE; j++) {
@@ -278,8 +290,12 @@
   for (i = 0; i < Ninput; i++) {
     if (i == Nfile) continue;
-    fclose(input[i]);
-  }
-  fclose (output);
-  fclose (target);
+    status = fclose(input[i]);
+    myAssert (!status, "failed to close input");
+  }
+  status = fclose (output);
+  myAssert (!status, "failed to close output file");
+
+  status = fclose (target);
+  myAssert (!status, "failed to close rocfile");
 
   exit (0);
