[K42-discussion] Small Error Code script (was: Allocating error codes)

Livio Soares livio at eecg.toronto.edu
Sat Sep 16 12:23:40 EST 2006


  Hi Patrick,

  In actuality,  there are tons  of error code  numbers to choose  from, without
needing the IBM allocator. The trick is:  take of advantage of the fact that K42
sometimes leaks ;-P

  The following script might be of some  interest to people on the list. It uses
some GNU tools such as bash, grep, cut, sort; hopefully will work for everyone.

Usage: 

    k42_error_codes.sh kitchsrc-directory

Output:

  STDOUT:  A list  of code  numbers which  have leaked  and should  be currently
          available for use

  STDERR: Tags of two forms:

          1) "Strange error code: " + code number
              These are code numbers outside the [1000 - 10000] range. 

          2) "REPEAT: " + code number
              These are code numbers which show up more than once. 


  Caveat:  This script  does not  distinguish uncommented  from  commented code,
          hence:
          a) There  might  be  _more_  unused  codes than  it  detects  (but  it
             should never report a used error code)
          b) The  "REPEAT:" and  "Strange error code:"  tags could  be reporting
             invalid information. 


  Some useful numbers from the git tree:

$ ./k42_error_codes.sh ./kitchsrc/ 2> /dev/null | wc
    966     966    4830
 
    So; there are 966 unused/leaked error code to choose from. 

$ ./k42_error_codes.sh ./kitchsrc/ 2>&1 | grep ^REPEAT | wc
     99     198    1287

    There are 99 occurrences of repeated error codes! :-(


  I hope this is useful,

			Livio
-------------- next part --------------
A non-text attachment was scrubbed...
Name: k42_error_codes.sh
Type: application/x-sh
Size: 731 bytes
Desc: not available
Url : http://ozlabs.org/pipermail/k42-discussion/attachments/20060915/002c1775/attachment.sh 


More information about the K42-discussion mailing list