celix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Broekhuis <a.broekh...@gmail.com>
Subject Re: Nested ifs for celix_status_t
Date Mon, 23 Jan 2012 10:54:35 GMT
Hi,


> In my opinion this makes the code very unclear


I agree, some time ago there was some discussion on using this vs some
exception mechanisms [1]. I still think this is the best choice, but ideas
on how to simplify this are welcome!


> and I am thinking about
> adding the following macro to address this problem:
> #define DO_IF_SUCCESS(status, call_func) ((status) == CELIX_SUCCESS) ?
> (call_func) : (status)
>

Look good and usable. Makes the code much cleaner.
A drawback I see for now is that the macro executes the expression for each
use. Using the nested if's the code would fall through to the end.
I am not sure what the consequence of this is, but probably not that large.


> I would like to hear some opinions about this solution and if it is
> something which can be added to celix_errno.h ?
>

celix_errno.h would be the right place to add this. Feel free to create an
issue for this (optionally with patch). Of no one objects I can add it
without an impact on the existing code base.

[1]:
http://incubator.markmail.org/search/list:org.apache.incubator.celix-dev+exception+handling

-- 
Met vriendelijke groet,

Alexander Broekhuis

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message