|
|
Subscribe / Log in / New account

Some idle comments about Linus' e-mail response and Linux

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.)


to post comments

Some idle comments about Linus' e-mail response and Linux

Posted Mar 2, 2007 0:41 UTC (Fri) by cpeterso (guest, #305) [Link] (3 responses)

Win32's CreateFile() API scores many Bad Taste points:

http://msdn2.microsoft.com/en-us/library/aa363858.aspx

Some idle comments about Linus' e-mail response and Linux

Posted Mar 2, 2007 1:00 UTC (Fri) by k8to (guest, #15413) [Link] (2 responses)

The name, for starters.

Some idle comments about Linus' e-mail response and Linux

Posted Mar 3, 2007 2:05 UTC (Sat) by nix (subscriber, #2304) [Link] (1 responses)

The billion insane flags and magic secret interactions are worse. It makes
open()+fcntl() look sane and pleasant.

Some idle comments about Linus' e-mail response and Linux

Posted Mar 4, 2007 9:04 UTC (Sun) by k8to (guest, #15413) [Link]

Oh absolutely. I just find it impressive that they couldn't even figure out that "files" are not just windows api constructs, but really exist on the disk, and so the name is just wrong. It's like opening and closing quotes to the explitive which is the implementation.

I've unfortunately programmed the win32 api before, although in its "sanitized" form, called Mono.

Some idle comments about Linus' e-mail response and Linux

Posted Mar 2, 2007 2:04 UTC (Fri) by proski (subscriber, #104) [Link] (1 responses)

And here we see Linus himself suggesting almost the same thing. No, it's not that bad, since it's a valid pointer, but it's close enough :)

Some idle comments about Linus' e-mail response and Linux

Posted Mar 3, 2007 2:08 UTC (Sat) by nix (subscriber, #2304) [Link]

The &bad_ctype is non-tasteless, I'd say. It's *transparent* and you can
easily tell what it's doing when you read the code. And it doesn't dump
core if you dereference it :)


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds