On Fri, Aug 28, 2009 at 09:26:11PM -0400, Zachary Uram wrote:
> Magnificent. You should write a book on debugging C in Linux! I'd buy
> it.

Rubbish.  It was nothing, really.

It was C, nothing really to do with Linux, more to do with POSIX.

Consider this patch (edited down from the whole thing) ...

Wed Jun 10 05:37:48 EST 2009  tanner at real-time.com
  * osx-netrek-server-port.patch
  * Second night of porting netrek-server to osx
  * First night of work switch netrek-server from autotools to cmake
    First night of work porting code base to osx
diff -rN -u old-netrek-server/Vanilla/ntserv/planet.c new-netrek-server/Vanilla/ntserv/planet.c
--- old-netrek-server/Vanilla/ntserv/planet.c	2009-08-29 12:54:48.000000000 +1000
+++ new-netrek-server/Vanilla/ntserv/planet.c	2009-08-29 12:54:48.000000000 +1000
@@ -126,7 +126,7 @@
 void pl_reset(void)
   int i, j, k, which, sanity;
-  MCOPY(pl_virgin(), planets, pl_virgin_size());
+  memcpy(pl_virgin(), planets, pl_virgin_size());
   for (i = 0; i < MAXPLANETS; i++) {
     planets[i].pl_armies = top_armies;

See how Bob was changing MCOPY to memcpy?  Ask yourself why.  He had to
do it in hundreds of places, probably late at night.

MCOPY was the macro defined by an include file:

#define MCOPY(b1,b2,l)  memcpy(b2,b1,l)


#define MCOPY(b1,b2,l)  bcopy(b1,b2,l)

depending on whether the system being used provided memcpy or bcopy.
Notice how the argument order differs between memcpy and bcopy.

Now, bcopy was in 4.3 BSD, but was marked deprecated in POSIX.1-2001,
then removed in POSIX.1-2008.  The replacement was memcpy.

Further, both Mac OS X and Linux now comply with POSIX.1-2001 or
POSIX.1-2008 in that they provide memcpy.

We have no need to support compiling the code on 4.3 BSD.  Nobody using

So Bob was changing the code to be cleaner, simpler, easier to maintain,
and make it work on Mac OS X as well as Linux.

The trivial mistake he made was not to change the order of the
arguments.  It's nothing.  It's a trivial mistake.  I'm sour at myself
for not noticing it earlier, but the amount of code still being ported
from bcopy to memcpy these days is very small.  memcpy has been around
for over a decade in the standard.  I had no excuse.  Sorry.

James Cameron