Bad Code of the Day

Nov 02, 2009 15:58

This two-line subroutine, with the name of the actual subroutine changed to protect . . . well, to protect somebody, was stumbled across during a review of other code today. There was no comment anywhere close to it, and the name didn't give much of a hint as to what it did:

int check_something_incomprehensible(void *a, char *value)
{
if (!a) return UNBADARG;
return UNINVALID_KEY & -!!strncmp((char*)a, value, 4);
}

The sad part? I knew immediately what the & -!!strncmp... is doing, thanks to previous adventures with the same author.
Previous post Next post
Up