[parted-devel] [Parted-edge] [RFC][PATCH] Remove alloca from libparted/arch/linux.c

Frodo Baggins frodo.drogo at gmail.com
Thu Sep 6 19:13:02 UTC 2007


On 9/6/07, Jim Meyering <jim at meyering.net> wrote:
> "Frodo Baggins" <frodo.drogo at gmail.com> wrote:
>
> > On 9/6/07, Jim Meyering <jim at meyering.net> wrote:
> >> Otavio Salvador <otavio at debian.org> wrote:
> >> > Jim Meyering <jim at meyering.net> writes:
> >> >
> >> >> I think it would be worthwhile (long term) to convert the other way,
> >> >> e.g., ped_free -> free, ped_malloc -> malloc, etc.
> >> >
> >> > But wouldn't the exception handling be a good thing in this case?
> >>
> >> ?!?  This sort of "exception handling" is never a good thing.
> >> Its use makes for ugly, unmaintainable code.
> >>
> >> One problem is that what libparted calls "exception handling"
> >> is an ugly kludge that can make the library code produce output
> >> and/or try to read an interactive reply from the user
> >> (things libraries must not do, in general).  In addition,
> >> how the handler behaves depends on static state,
> >> which is another big no-no for a library.
> >
> > Do we have a state machine which could help decide what to do when an
> > "exception" occurs?
>
> I'm not sure what you mean.
> The problem isn't deciding what to do, but that there
> is even an opportunity to decide.  Adding state and acting
> on it would just make things worse.  Libraries are supposed
> to be stateless.
>
> IMHO, when something exceptional happens in a library, the
> affected function should simply return with an indication of
> what went wrong.

Cleaning up resources properly and propagating the error so that the
user gets a sane message is the challenge.

Regards,

Frodo B



More information about the parted-devel mailing list