Some idle comments about Linus' e-mail response and Linux
Posted Mar 1, 2007 19:36 UTC (Thu) by
nix (subscriber, #2304)
In reply to:
Some idle comments about Linus' e-mail response and Linux by pr1268
Parent article:
Quote of the week
All the examples so far have been macro-level.
On the micro-level, it's Bad Taste to write code which `happens to work'
without concern that it's grossly, obviously disgusting. e.g. one I saw
many years ago (and fixed at once) had a function looking ocnceptually
something like (identifiers anonymized to protect the guilty)
struct foo *get_foo(int a, long b, const char *c);
and they wanted to return `a foo', `no foo to find' and `error while
looking for a foo'. So they returned a foo, NULL, and, um, (struct foo *)
1.
And *that* was bad taste. Sure the pointer was never dereferenced if it
was 1, so it wasn't technically a standards violation. But the hidden
unexpectedness of that return value, and the absence of any hint except in
its various callers that this might happen made it Bad Taste. (To add
insult to injury get_foo() also assumed a different meaning for a
null-string-valued `c' parameter and for a NULL `c'...)
(of course I called it. Of course I didn't expect this return value. But
when the program crashed on an error path, I didn't consider it *my*
fault. It was the fault of the author of get_foo(). Some adjustment of
55-odd callers later, and it was no longer doing such a vile thing.)
(
Log in to post comments)