1. 2

    Not initializing mode seems dangerous, although it’s probably fine in main(), I guess?

    1. 2

      I initialized a char *mode at around 3:09, is that what you mean?

      You’re right that it would be dangerous! But clang would have assumed a type of int and complained when I tried to assign mode = optarg, so the compiler is looking out for us at least a little :)

      1. 4

        No, you did not initialize it.

        And yes it is dangerous, main() or not.

        1. 2

          oh, you’re right! s/declare/initialize in my brain.

          Yeah, a dangerous mistake.

    1. 1

      I’m pretty sure I’m violently allergic to his C style.

      1. 3

        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.

        1. 5

          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!

          1. 2

            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.

        1. 1

          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?

          1. 5

            (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!