Home

November 20th, 2007

swat kats, autobot, optimus prime, transformer, cartoon, angry, rob, bitter, animation, condensed comics

This is why you’re not allowed to have nice things

While doing maintenance, I found the following atrocity:

inline void fast_strncpy(char *dest, const char *src, int nbytes) {
  if (nbytes <= 10) {
    switch (nbytes) {
      case 1:
        dest[0] = '\0';
        break;
      case 2:
        dest[0] = src[0];
        dest[1] = '\0';
        break;
      case 3:
        dest[0] = src[0];
        dest[1] = src[1];
        dest[2] = '\0';
        break;
      case 4:
        dest[0] = src[0];
        dest[1] = src[1];
        dest[2] = src[2];
        dest[3] = '\0';
        break;
        // AND SO ON FOR AN OBSCENE NUMBER OF CASES...
  }
  else {
    memcpy(dest, src, nbytes - 1);
    dest[nbytes] = '\0'; // WHAT’S WRONG HERE, KIDS?
  }
}

“Why does our performance suck compared to the competitors?”

Because maybe, just maybe, your engineers can’t program worth crap?

swat kats, autobot, optimus prime, transformer, cartoon, angry, rob, bitter, animation, condensed comics

Today's Word of the Day

ret•req |'ret ,rek| noun a bizarre behavior from software explained post facto by editing the wiki holding the requirements document once said behavior is discovered.

Origin early 21st cent.: blend of retroactive and requirement.

See Also CYA