Re: [hackers] [st] [patch] use goto in xloadfonts

From: FRIGN <dev_AT_frign.de>
Date: Mon, 22 Jun 2015 15:23:37 +0200

On Mon, 22 Jun 2015 09:26:17 +0200
"Roberto E. Vargas Caballero" <k0ga_AT_shike2.com> wrote:

Hey Roberto,

just chiming in into this interesting discussion, not in the interest
of bloating it even more, though.

> I personally don't think is harder. I think is a common pattern in
> C to have die calls in the end of the function and gotos to them.
> The main problem that I can see here is the label, whose name is
> not significative enough: err, which error?, and if we have to add
> more errors in the future, do we have to change this label and all
> the gotos to this label?. I think a label like 'cant_open_font' is
> better. I usually like short names, but in the case of goto the
> story is totally different, because you have a modification in the
> control flow and it should be clear why it is done.

I couldn't agree more. I followed the LibreSSL-refactoring very closely
and they did the same. Gotos + cleanup at the end instead of local
bailouts; the names need to be descriptive though.

Could you give me some information if a cleanup is necessary when the
font fails to load? Is there some possibility open with the gotos now to
have some kind of cleanup?
In general, I prefer this kind of error-handling way over exceptions. :)

Cheers

FRIGN

-- 
FRIGN <dev_AT_frign.de>
Received on Mon Jun 22 2015 - 15:23:37 CEST

This archive was generated by hypermail 2.3.0 : Mon Jun 22 2015 - 15:24:09 CEST