On Mon, Sep 12, 2011 at 10:31:44AM -0500, Pieter Hintjens wrote:
> On Mon, Sep 12, 2011 at 10:20 AM, AJ Lewis <[email protected]>
> wrote:
> 
> > I could put together something - I'm afraid it will break the
> > current API though, as void functions that call zmalloc (or call
> > other functions that call zmalloc) should propagate the error...is
> > that acceptable?
> 
> Breaking the API is fine if it's for good reasons. We bump the version
> number appropriately. The next would be 1.2.0.

Hi - I'm still looking at this - got pulled off on some other projects
I'm working on for a bit.  Another question regarding error handling:

Are you ok using a 'goto' statement to jump to the bottom of a function
on error, ala the linux kernel?

int somefunc()
{
...
    error = func1();
    if (error) {
        // specific cleanup
        goto end;
    }
    error = func2();
    if (error) {
        // specific cleanup
        goto end;
    }
    error = func2();
    if (error) {
        // specific cleanup
        goto end;
    }
...
end:
   // Do exit cleanup

   return error;
}

Or do you want nested if/else blocks?

int somefunc()
{
   ...
   error = func1();
   if (!error) {
       error = func2();
       if (!error) {
           error = func3();
           if (!error) {
               ...
           } else {
               // specific cleanup
           }
       } else {
          // specific cleanup
   } else {
      // specific cleanup
   }
   
   // Do exit cleanup
   return error;
}

Personally, I prefer the first method, but I know people that absolutely
will not use goto.

Thanks,
-- 
AJ Lewis
Software Engineer
Quantum Corporation

Work:    651 688-4346

----------------------------------------------------------------------
The information contained in this transmission may be confidential. Any 
disclosure, copying, or further distribution of confidential information is not 
permitted unless such privilege is explicitly granted in writing by Quantum. 
Quantum reserves the right to have electronic communications, including email 
and attachments, sent across its networks filtered through anti virus and spam 
software programs and retain such messages in order to comply with applicable 
data security and retention requirements. Quantum is not responsible for the 
proper and complete transmission of the substance of this communication or for 
any delay in its receipt.
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to