Funny code snippet of the month

Bernd Petrovitsch bernd at firmix.at
Tue Nov 3 23:00:29 UTC 2009


On Die, 2009-11-03 at 14:44 -0800, David N. Lombard wrote: 
> On Tue, Nov 03, 2009 at 01:42:48PM -0800, Alexander Shishkin wrote:
> > On Втр, Ноя 03, 2009 at 04:28:09 +0100, Denys Vlasenko wrote:
> > >           assert (*buffer == info->buffer);
> > >           *buffer = info->buffer;
[...] 
> I wonder if this started out as much different code, with the order reversed,
> the assignment within some hopelessly convoluted conditional making the assert()
> macro a Good Thing(TM).  At least then one could claim an infinitesimal shred
> of plausible deniability... :p

The other interpretation is that one wants to catch bugs in the
development/testing phase (otherwise the assert() doesn't make that much
sense) and for a release, one adds "-DNDEBUG" to the CPPFLAGS so that
the assignment just papers over a bug and adds (false?) robustness.

Bernd
-- 
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services



More information about the busybox mailing list