what in particular do you dislike? I took the style from the BSD 4.4 cat source, and the attribution of that code is to Rob Pike himself. The one thing I did change was moving assignment in conditions and loop tests to separate assignments and tests, as in changing if (buf = malloc(bsize)){ err(1,0); } to buf = malloc(bsize); if (!buf) { err(1, 0); }, which I found (when starting to learn C) to be easier to understand.
Though I understand that C makes 0 and NULL interchangeable in many contexts, I think it’s important to reflect the type and intent of the variables and values in expressions. For instance, I think (buf != NULL) is clearer than (!buf). Similarly err(1, NULL) instead of err(1, 0).
I also think the structure of the do/while loop in main() is confusing, and probably would have been better with the use of argc and explicit handling of the no-argument case.
I’ve been voted -1 troll, though, so I suppose I’ll get my coat!
You used K&R style function declarations and C99 style line comments. At the very least, stick with either K&R, C89 (new function declaration style, no // comments) or C99.
Man that was fast!
Couldn’t help thinking, is this realtime? does the guy prepares its casts? Are you guys able to write that this fast?
(author here) very very rehearsed, and done in small segments. Also, the voiceover was done separately. For my paid screencasts about re-writing Git I’ve been recording the typing/talking simultaneously, but I thought a casual viewer would appreciate a quicker watch. I’ll be practicing to get to grb/Destroy All Software speeds!
Not initializing
modeseems dangerous, although it’s probably fine in main(), I guess?I initialized a
char *modeat around 3:09, is that what you mean?You’re right that it would be dangerous! But clang would have assumed a type of
intand complained when I tried to assignmode = optarg, so the compiler is looking out for us at least a little :)No, you did not initialize it.
And yes it is dangerous, main() or not.
oh, you’re right! s/declare/initialize in my brain.
Yeah, a dangerous mistake.