[PATCH v2 07/19] rsatoc: cleanup error handling

Sascha Hauer s.hauer at pengutronix.de
Mon Aug 5 03:07:59 PDT 2024


On Mon, Aug 05, 2024 at 11:54:56AM +0200, Ahmad Fatoum wrote:
> On 01.08.24 07:57, Sascha Hauer wrote:
> > - In case of an error bail out immediately instead of continuing and
> >   just return an error at the end
> > - explicitly set 'ret' right before going to the cleanup label which
> >   makes the code more readable
> > 
> > Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> > ---
> >  scripts/rsatoc.c | 58 +++++++++++++++++++++++++++++++++---------------
> >  1 file changed, 40 insertions(+), 18 deletions(-)
> > 
> > diff --git a/scripts/rsatoc.c b/scripts/rsatoc.c
> > index 0faf41bca2..22f0318298 100644
> > --- a/scripts/rsatoc.c
> > +++ b/scripts/rsatoc.c
> > @@ -167,15 +167,16 @@ static int rsa_get_exponent(RSA *key, uint64_t *e)
> >  	const BIGNUM *key_e;
> >  	uint64_t te;
> >  
> > -	ret = -EINVAL;
> >  	bn_te = NULL;
> >  
> >  	if (!e)
> >  		goto cleanup;
> 
> Won't ret be undefined here?

Indeed. This check is removed anyway in the next patch, so doesn't
matter much. I'll just swap this one with the next patch.

> 
> Also the return value is ultimately used only for an error message,
> gen_key's error is not propagated, but it should result in the utility
> aborting with an error code.

Fixed further down this series, but you noticed yourself already.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list