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

Jeremy Allison jra at samba.org
Thu Mar 9 18:47:18 UTC 2017


On Thu, Mar 09, 2017 at 02:43:10PM +0200, Uri Simchoni wrote:
> On 03/09/2017 02:31 PM, Andreas Schneider wrote:
> > On Thursday, 9 March 2017 12:19:46 CET Stefan Metzmacher wrote:
> >> 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...
> > 
> > talloc_guide.txt is outdated since years. We should remove it.
> > 
> How's this for the doxygen fix?

LGTM. Pushed !

> From cd9f0bf9955dcaca103566e9bc4690344150a223 Mon Sep 17 00:00:00 2001
> From: Uri Simchoni <uri at samba.org>
> Date: Thu, 9 Mar 2017 14:40:54 +0200
> Subject: [PATCH] talloc: fix doxygen of talloc_move
> 
> talloc_move cannot fail.
> 
> Signed-off-by: Uri Simchoni <uri at samba.org>
> ---
>  lib/talloc/talloc.h | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/talloc/talloc.h b/lib/talloc/talloc.h
> index 227f745..618430a 100644
> --- a/lib/talloc/talloc.h
> +++ b/lib/talloc/talloc.h
> @@ -407,10 +407,11 @@ const char *talloc_set_name(const void *ptr, const char *fmt, ...) PRINTF_ATTRIB
>   *
>   * @param[in]  new_ctx  The new parent context.
>   *
> - * @param[in]  pptr     Pointer to the talloc chunk to move.
> + * @param[in]  pptr     Pointer to a pointer to the talloc chunk to move.
> + *
> + * @return              The pointer to the talloc chunk that moved.
> + *                      It does not have any failure modes.
>   *
> - * @return              The pointer of the talloc chunk it has been moved to,
> - *                      NULL on error.
>   */
>  void *talloc_move(const void *new_ctx, void **pptr);
>  #else
> -- 
> 2.9.3
> 




More information about the samba-technical mailing list