talloc_move - only nullify pointer if memory got "stolen"?

Stefan Metzmacher metze at samba.org
Thu Mar 9 11:19:46 UTC 2017


Am 09.03.2017 um 12:07 schrieb Uri Simchoni:
> On 03/09/2017 12:54 PM, Stefan Metzmacher wrote:
>> Hi Uri,
>>
>>> Just came across this - is the attached patch correct / necessary?
>>
>> Can you give more details? In what situation does that happen?
>>
>> metze
>>
> I just looked at the code, no special "situation". I was wondering
> whether I need to check the return value of talloc_move(), and what
> happens if it fails.

talloc_steal() and talloc_move() never fail.

The doxygen comment for talloc_steal has this:

 * @return              Returns the pointer that you pass it. It does
not have
 *                      any failure modes.

While the comment for talloc_move() seems to be wrong:

 * @return              The pointer of the talloc chunk it has been
moved to,
 *                      NULL on error.


talloc_guide.txt seems to be not that explicit about the return value
of talloc_steal() and talloc_move() is completely missing.

We may want to improve the doxygen comments and talloc_guide.txt...

metze

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20170309/b26d87ff/signature.sig>


More information about the samba-technical mailing list