home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lclint.zip / lclint-2_3h-os2-bin.zip / test / libs.c < prev    next >
Text File  |  1997-09-03  |  1KB  |  61 lines

  1. /*
  2. ** test of standard library
  3. */
  4.  
  5. int compare (int x, int y)
  6. {
  7.   x = y;
  8.   return (3);
  9. }
  10.  
  11. char *compare2 (int x, int y)
  12. {
  13.   x = y;
  14.   return "ok";
  15. }
  16.  
  17. void
  18. leave (int i)
  19. {
  20.   exit ("hullo"); /* 1. Function exit expects arg 1 to be int gets char * */
  21.   exit (i);       /* 2. Unreachable code */
  22.  
  23. void
  24. print (char *s, FILE *f)
  25. {
  26.   char c;
  27.  
  28.   fprintf (f, s);
  29.   printf(s);
  30.   fprintf (stderr, s);
  31.  
  32.   c = fgetc(f); /* 3. Assignment of int to char: c = fgetc(f) */
  33.   c = getc (f); /* 4. Assignment of int to char: c = getc(f) */
  34. }
  35.  
  36. int
  37. main (void)
  38. {
  39.   unsigned int x;
  40.  
  41.   x = NULL;
  42.   
  43.   /*@-null@*/ /* suppress errors for passing NULL's */
  44.   /*@-noeffect@*/
  45.   (void) bsearch (NULL, NULL, sizeof(int), compare) ;  /* 5, 6  */
  46.   (void) bsearch (NULL, NULL, sizeof(int), sizeof(int), (int (*) ()) compare) ; /* ok */
  47.   bsearch (NULL, NULL, sizeof(int), sizeof(int), (char (*) ()) compare2) ; /* 7, 8 */
  48.   /*@=noeffect@*/
  49.  
  50.   qsort (NULL, x, x, (int (*)()) compare);
  51.   qsort (x, x, x, (char (*)()) compare2); /* 9, 10. */
  52.  
  53.   signal (SIGHUP, compare); /* 11. */
  54.   signal (SIGHUP, leave);
  55.  
  56.   return 23;
  57. }
  58.  
  59.  
  60.