Re: Hundreds of bugs in 2.3.99-pre3

From: willy@thepuffingroup.com
Date: Fri Mar 31 2000 - 19:47:59 EST


On Fri, Mar 31, 2000 at 05:12:54PM +0100, Tim Waugh wrote:
> whereas this is good:
>
> foo_open (...)
> {
> MOD_INC_USE_COUNT;
> stuff..
> if (fail) {
> MOD_DEC_USE_COUNT;
> return -EBUSY;
> }
> sleep.. (safe now)
> stuff..
> return 0;
> }

it's generally better to do:

foo_open()
{
        int result;
        MOD_INC_USE_COUNT;
        stuff..
        result = -EBUSY;
        if (fail)
                goto out;
        sleep..
        stuff..
        result = 0;
out:
        if (result != 0) {
                MOD_DEC_USE_COUNT;
        }
        return result;
}

particularly if you have many possible failure cases.

-
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/



This archive was generated by hypermail 2b29 : Fri Mar 31 2000 - 21:00:30 EST