lkml.org 
[lkml]   [2017]   [Oct]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: char/tpm: Less checks in tpm_ibmvtpm_probe() after error detection
From
Date
>> If the code doing the allocation is changed in the future the single
>> cleanup can stay whereas multiple labels have to be rewritten again.
>
> No, they don't unless you choose bad label names. Perhaps numbered
> labels? We don't get a lot of those in the kernel any more. Label
> name should be based on what the label does. Often I see bad label
> names like generic labels:
>
> foo = kmalloc();
> if (!foo)
> goto out;
>
> What is out going to do? Another common anti-pattern is come-from
> labels:
>
> foo = kmalloc();
> if (!foo)
> goto kmalloc_failed;
>
> Obviously, we can see from the if statement that the alloc failed and
> you *just* know the next line is going to be is going to be:
>
> if (invalid)
> goto kmalloc_failed;
>
> Which is wrong because kmalloc didn't fail... But if the label name is
> based on what it does then, when you add or a remove an allocation, you
> just have to edit the one thing.

Would you be interested in an update on a topic like “Source code review
around jump label usage”?
https://lkml.org/lkml/2015/12/11/378

Regards,
Markus

\
 
 \ /
  Last update: 2017-10-22 17:29    [W:0.122 / U:2.960 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site