[elinks-dev] exit(!!NULL) in die()

Jonas Fonseca fonseca at diku.dk
Tue Aug 28 08:10:09 MDT 2007


Kalle Olavi Niemitalo <kon at iki.fi> wrote Tue, Aug 28, 2007:
> In elinks-0.12/src/protocol/test/stub.c, we now have:
> 
> static void
> die(const char *msg, ...)
> {
> 	va_list args;
> 
> 	if (msg) {
> 		va_start(args, msg);
> 		vfprintf(stderr, msg, args);
> 		fputs("\n", stderr);
> 		va_end(args);
> 	}
> 
> 	exit(!!NULL);
> }
> 
> !!NULL is 0.  Wouldn't it make more sense to exit(1) or
> exit(EXIT_FAILURE), as an error has occurred?

Yes, sorry, I just copy/pasted it from the DOM test code.

elinks > git grep 'exit(!!'
src/dom/test/dom-select.c:      exit(!!NULL);
src/dom/test/sgml-parser.c:     exit(!!NULL);
src/protocol/ftp/ftp-parser.c:  exit(!!NULL);
src/protocol/test/stub.c:       exit(!!NULL);

Maybe a unified version should even go to a src/util/test.{h,inc} file.

-- 
Jonas Fonseca


More information about the elinks-dev mailing list