On 2011-11-16, Phil Carmody <> wrote:
> Seebs <usenet-> writes:
>> Consider:
>>
>> struct foo *f = malloc(sizeof(*f));
>> free(f);
>> f->x = 1;
>>
>> I do not consider it a reasonable assumption that an arbitrary person
>> with 3-5 years or more of experience programming C will see anything
>> wrong here.
> Astounding. And I say that as someone who's spent a long time in maintenance
> fixing major ****-ups by people who just didn't get it. But not one of them
> (even the "we've read /Design Patterns/, we don't have to care about O(n^2)
> getting huge" crowd, and even the "shift by N bits by shifting by 1 bit N-1
> times" dude) would have done *that*.
You would be amazed.
> I hope you're exagerating. I guess I should get a nice warm feeling of
> comfort that ${DAYJOB} really is about as great a bunch of coders as
> you could ever hope to work with.
Nope, not exaggerating. Couple jobs back, there was this guy who had
on paper a decade of C experience, who absolutely *insisted* that this
had to work, and was the only reasonable way to avoid memory leaks.
And he got promoted to being in charge of stuff.
But yeah. It is sort of astounding, but then... I read a lot of code,
and it is full of nonsense. Today's:
*p++ = toupper((unsigned char) *p);
This is in code that's widely used, and gcc even warns about it... If
you compile at -O0. Which most people don't.
In another fairly famous piece of software, we came across:
unsigned char x;
x = NULL;
which, again, "had worked most of the time".
I guess that's the thing. Most code is not subject to serious technical
review, and most programmers are sorta shoddy. Heck, I do horrible stuff,
it's just that I usually get it caught in review, or I catch it myself
if I'm lucky.
-s
--
Copyright 2011, all wrongs reversed. Peter Seebach /
usenet-
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.