139
you are viewing a single comment's thread
view the rest of the comments
[-] calcopiritus@lemmy.world 2 points 21 hours ago

Can confirm. I have to do this all the time. Some coworkers just delete it, and I have to explain the situation every time when they see in the git blame that I put that semicolon there.

As someone pointed out in another comment, in switch statements you should just start a new scope with {}. But in actual labels it's just better to put a load-bearing semicolon. You don't need to put it in another line though, I just put them like this:

int main() {
    int *a = malloc(sizeof(*a));
    if (init_a(a) <= 0) {
        goto err;
    }
    do_something(a);
err:;
    int ret = 0;
    if (a == NULL) {
        ret = -1;
    }
    free(a);
    return ret;
}
this post was submitted on 21 Sep 2026
139 points (99.3% liked)

Programmer Humor

33314 readers
499 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 3 years ago
MODERATORS