[PATCH] librpc: simplify ndr_pull_dnsp_string

Michael Adam obnox at samba.org
Fri Oct 3 02:39:53 MDT 2014


Looks good! pushing

On 2014-10-03 at 01:12 -0700, Matthieu Patou wrote:
> Hello,
> 
> Can someone review this patch ?
> 
> Thanks.
> -- 
> Matthieu Patou
> Samba Team
> http://samba.org

> >From 1c0ec3e626b9827782b245d85944ab613424f3f6 Mon Sep 17 00:00:00 2001
> From: Matthieu Patou <mat at matws.net>
> Date: Sun, 13 Oct 2013 21:39:51 -0700
> Subject: [PATCH] librpc: simplify ndr_pull_dnsp_string
> 
> total_len is 1 and never varies.
> 
> Signed-off-by: Matthieu Patou <mat at matws.net>
> ---
>  librpc/ndr/ndr_dnsp.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/librpc/ndr/ndr_dnsp.c b/librpc/ndr/ndr_dnsp.c
> index fcb623a..46141c1 100644
> --- a/librpc/ndr/ndr_dnsp.c
> +++ b/librpc/ndr/ndr_dnsp.c
> @@ -135,7 +135,6 @@ _PUBLIC_ void ndr_print_dnsp_string(struct ndr_print *ndr, const char *name,
>  _PUBLIC_ enum ndr_err_code ndr_pull_dnsp_string(struct ndr_pull *ndr, int ndr_flags, const char **string)
>  {
>  	uint8_t len;
> -	uint32_t total_len;
>  	char *ret;
>  
>  	NDR_CHECK(ndr_pull_uint8(ndr, ndr_flags, &len));
> @@ -144,13 +143,11 @@ _PUBLIC_ enum ndr_err_code ndr_pull_dnsp_string(struct ndr_pull *ndr, int ndr_fl
>  	if (!ret) {
>  		return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Failed to pull dnsp_string");
>  	}
> -	total_len = 1;
> -	ret = talloc_zero_array(ndr->current_mem_ctx, char, len+1);
> +	ret = talloc_zero_array(ndr->current_mem_ctx, char, len + 1);
>  	if (!ret) {
>  		return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Failed to pull dnsp_string");
>  	}
> -	NDR_CHECK(ndr_pull_bytes(ndr, (uint8_t *)&ret[total_len-1], len));
> -	total_len = len;
> +	NDR_CHECK(ndr_pull_bytes(ndr, (uint8_t *)ret, len));
>  
>  	(*string) = ret;
>  	NDR_PULL_ALIGN(ndr, 1);
> -- 
> 1.9.1
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20141003/7afc3efd/attachment.pgp>


More information about the samba-technical mailing list