DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Analyzing run-time behavior

Hard to produce error conditions

Now take a look at the function putdata().

                   void
                   putdata(output, data)
                   char    *data;
                   FILE    *output;
          [9]      {
                       /* check for file system out of space */
         [11]          if (fprintf(output, "%s", data) < 0) {
     [U] [12]              fprintf(stderr, "write error with file '%s'", filename);
     [U] [13]              fclose(output);
     [U] [14]              unlink(newreffile);
     [U] [15]              exit(1);
                       }
         [17]      }

Output from lprof -x for putdata()

Because this error is hard to produce, the error recovery part of the function usually does not get tested. You can simulate the error, however, by writing your own fprintf() function that returns a value less than 0. That will cause the error recovery part of the function to be exercised, allowing you to see the following error message:

   write error with file '@%#&HP'
Further inspection reveals that the variable filename was never initialized. That oversight caused the error message to be garbled.
Previous topic: Functions that are never called

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004