RPM Community Forums

Mailing List Message of <popt-devel>

Zero tolerance for errors (like malloc returning NULL)

From: Jeff Johnson <n3npq@mac.com>
Date: Mon 14 Jun 2010 - 18:37:07 CEST
Message-id: <22AACF2C-8233-46E5-A98A-F8C74916D146@mac.com>
There's basically two schools of thought for handling
programmer/runtime errors in libraries.

The "Have it your own way!" elitists claim that libraries
should _NEVER_ exit and _ALWAYS_ return an error code.

The other approach is "Punish the moron. NOW!" LART 'em w a ruler and
add assert's throughout the code on "can't happen" conditions.

For development of POPT 2.0 I prefer being punished, and
so am going to wire up assert's throughout POPT to
simplify the code.

For "release" of POPT 2.0, I'm perfectly happy to change
to the ... _NEVER_ ... _ALWAYS_ approach if that really matters.

Hint: When was the last time you saw any application undertake
a sane/reasonable corrective action and continue running when
malloc happened to return NULL? I've never seen such an application
(but my experience is limited).

Meanwhile, assert's for POPT 2.0 development are about to be checked in
so that I can see what needs to be done.

73 de Jeff
Received on Mon Jun 14 18:37:50 2010
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.