News for hackers. Stuff that matters.
Re:Notes on structured concurrency, or: Go statement conside... by arghwhat on Saturday April 28, 2018 @12:39PM (#16948402)
That would work, but I'm not sure I find it that pretty. Plus, it assumes all "ops" have compatible error output (which is unfortunately rarely the case).

What I instead do is usually:

    int some_func() {
        int err = OK;
        if (some_op() != SOME_OK_CRITERIA) {
            err = SOME_OP_FAILED;
            goto error;
        }
        ....


    error:
         // do necessary cleanup

         return err;
    }
I'm also mostly responsible for Linux and BSD kernel mode driver, as well as our user-mode driver (most of our driver exist as a shared user-mode component)—I wipe the Windows kernel mode driver off on someone else. :)

I have no allergy to goto at all, as long as its not used in absurd fashions (like how it's used in a duffs device). If a goto seems easier/prettier, I use a goto.

There are no comments on this comment yet.