Re: Structure vs purism ?

Philipp Rumpf (prumpf@jcsbs.lanobis.de)
Fri, 22 Jan 1999 16:14:12 +0000


On Fri, Jan 22, 1999 at 12:01:15PM +1100, Nathan Hand wrote:
> > Another thing is that _sometimes_ gotos are an elegant way to impelemt
> > transaction protocol lookalikes without too much fuzz...
>
> State machines are far more easily implemented using gotos, and I
> expect that this is another valid use for gotos in Linux.

As is the usual "get the irq, get the ioports, get the mmio" stuff. Here is
an example of what this code can look like when no gotos are used (sorry for
the long quote, but it looks a lot more impressive this way ;):

if ((err = kgim_chipset_init(&kgifb_card, &kgifb_display)))
{
ERROR("kgim_chipset_init failed");
kgi_freemem();
return err;
}

if ((err = kgim_monitor_init(&kgifb_card, &kgifb_display)))
{
ERROR("kgim_monitor_init failed");
kgim_chipset_done(&kgifb_display);
kgi_freemem();
return err;
}

if ((err = kgim_ramdac_init(&kgifb_card, &kgifb_display)))
{
ERROR("kgim_ramdac_init failed");

kgim_monitor_done(&kgifb_display);
kgim_chipset_done(&kgifb_display);
kgi_freemem();
return -EIO;
}

if ((err = kgim_clock_init(&kgifb_card, &kgifb_display)))
{
ERROR("kgim_clock_init failed");

kgim_ramdac_done(&kgifb_display);
kgim_monitor_done(&kgifb_display);
kgim_chipset_done(&kgifb_display);
kgi_freemem();
return -EIO;
}

if ((err = kgim_accel_init(&kgifb_card, &kgifb_display)))
{
ERROR("kgim_accel_init failed");

kgim_clock_done(&kgifb_display);
kgim_ramdac_done(&kgifb_display);
kgim_monitor_done(&kgifb_display);
kgim_chipset_done(&kgifb_display);
kgi_freemem();
return -EIO;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/