[asterisk-dev] [Code Review] 4543: clang compiler warning: RAII-clang reentrancy / Updating variable from inside a _block

Diederik de Groot reviewboard at asterisk.org
Sat Mar 28 10:03:35 CDT 2015



> On March 28, 2015, 3:51 p.m., Matt Jordan wrote:
> > /branches/13/include/asterisk/utils.h, line 1055
> > <https://reviewboard.asterisk.org/r/4543/diff/1/?file=73018#file73018line1055>
> >
> >     I don't have any problem with the actual fix here, but I don't think we should change the parameter name from initval to ctor.
> >     
> >     In the list of parameters passed to the RAII_VAR macro, initval represents an actual concrete value to assign to the variable specified by vartype/varname. Yes, sometimes that value is returned by a constructor function - but it is often just a value as well. For example:
> >     
> >     RAII_VAR(struct foo_t *, foo, NULL, ao2_cleanup);
> >     
> >     On the other hand, the 'dtor' parameter *must* be invokable. It isn't a value - it is a destructor function that is called when varname leaves scope.

Reverted the name change.

BTW: not 100% sure if the "if (varname)" before calling the destructor is still needed.

FYI: A test might be necessary to see if the destructor is not called to soon (at the exit of the first recursion, instead of on the last).


- Diederik


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/4543/#review14940
-----------------------------------------------------------


On March 28, 2015, 4:01 p.m., Diederik de Groot wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/4543/
> -----------------------------------------------------------
> 
> (Updated March 28, 2015, 4:01 p.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Bugs: ASTERISK-24917
>     https://issues.asterisk.org/jira/browse/ASTERISK-24917
> 
> 
> Repository: Asterisk
> 
> 
> Description
> -------
> 
> RAII-clang reentrancy / Updating variable from inside a _block
> 
> To update the varname variable from inside the cleanup block it needs to be decorated with "__block" as in:
> __block vartype varname = ctor;
> 
> 
> Diffs
> -----
> 
>   /branches/13/include/asterisk/utils.h 433444 
> 
> Diff: https://reviewboard.asterisk.org/r/4543/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Diederik de Groot
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20150328/99b9e235/attachment.html>


More information about the asterisk-dev mailing list