lkml.org 
[lkml]   [2018]   [Feb]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 2/2] crypto: caam: Use common error handling code in four functions
Date
On 2/14/2018 8:32 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 14 Feb 2018 19:14:49 +0100
>
> Add jump targets so that a bit of exception handling can be better reused
> at the end of these functions.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
[snip]
> @@ -1096,6 +1092,7 @@ static int ahash_digest(struct ahash_request *req)
> if (!ret) {
> ret = -EINPROGRESS;
> } else {
> +unmap_hash:
> ahash_unmap(jrdev, edesc, req, digestsize);
> kfree(edesc);
> }
>
I understand jumps are a necessary evil for dealing with shortcomings of C,
however please avoid jumping in an if/else branch.

Code could be rewritten as:

if (!ret)
return -EINPROGRESS;

unmap_hash:
ahash_unmap(jrdev, edesc, req, digestsize);
kfree(edesc);

Thanks,
Horia

\
 
 \ /
  Last update: 2018-02-15 09:04    [W:0.065 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site