[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#822221: ITP: flipcoin -- flip an adjustable coin for random exit status



Hi Rudi!

[When filing a bug, please use X-Debbugs-CC instead of plain CC, so that the copied person (or list) receives the message with bug number from the BTS.]

* Rudi Cilibrasi <cilibrar@alumni.caltech.edu>, 2016-04-21, 23:11:
* Package name    : flipcoin
 Version         : 1.0.0
 Upstream Author : Rudi Cilibrasi <cilibrar@alumni.caltech.edu>
* URL             : https://github.com/rudi-cilibrasi/flipcoin

Um, this page says "0 releases". Has 1.0.0 actually been released?

I'm an enthusiast of small programs that do one thing well. But I'd expect a program which is that short to be perfectly polished, and this one is not. Here's my review of this code:

 if (argc > 1)
   probability = atof(argv[1]);

No error handling... I'd expect to see an error message when the probability cannot be parsed, or it is out of range would be helpful, or there are too many arguments.

 memset(&maxInt, 0xff, sizeof(maxInt));

"maxInt = -1" is would be a more obvious way to write it, IMHO.

 fp = fopen("/dev/urandom", "rb");
 if (fp == NULL) {
   fprintf(stderr, "Error: Cannot open /dev/urandom.\n");

The error message doesn't say what the error was, or what program caused this error.

   exit(2);

This exit code should be documented in the manpage.

 if (fread(&valInt, 1, sizeof(valInt), fp) != sizeof(valInt)) {
   fprintf(stderr, "Error: Cannot read from /dev/urandom.\n");
   exit(2);

Same problems are above.

 return ((probability * ((double) maxInt)+1.0) < valInt);

This is off-by-one, making the return value slightly biased towards 0.

Both COPYING and LICENSE exist and they are identical. Surely one would be enough? :-)

There is no test suite...

All in all, I don't think this is mature enough to be uploaded to Debian at this time.

--
Jakub Wilk


Reply to: