[PATCH] Small cleanups

Jeremy Allison jra at samba.org
Fri Mar 1 23:57:29 UTC 2019


On Fri, Mar 01, 2019 at 03:22:33PM +0100, Volker Lendecke via samba-technical wrote:
> Hi!
> 
> Review appreciated!

LGTM. RB+ and pushed !

Cheers,

Jeremy.

> -- 
> SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
> phone: 0551-370000-0, mailto:kontakt at sernet.de
> Gesch.F.: Dr. Johannes Loxen und Reinhild Jung
> AG Göttingen: HR-B 2816 - http://www.sernet.de

> From 4a43aaf558f851c05a35183384c16c6a851e127d Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Thu, 28 Feb 2019 21:18:06 +0100
> Subject: [PATCH 1/3] libsmb: Use tevent_req_simple_finish_ntstatus()
> 
> Less lines... Just rediscovered this function :-)
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  source3/libsmb/cli_smb2_fnum.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
> index 795dc557c45..d5beaae9896 100644
> --- a/source3/libsmb/cli_smb2_fnum.c
> +++ b/source3/libsmb/cli_smb2_fnum.c
> @@ -857,15 +857,8 @@ static void cli_smb2_rmdir_disp_set(struct tevent_req *subreq)
>  
>  static void cli_smb2_rmdir_closed(struct tevent_req *subreq)
>  {
> -	struct tevent_req *req = tevent_req_callback_data(
> -		subreq, struct tevent_req);
> -	NTSTATUS status;
> -
> -	status = cli_smb2_close_fnum_recv(subreq);
> -	if (tevent_req_nterror(req, status)) {
> -		return;
> -	}
> -	tevent_req_done(req);
> +	NTSTATUS status = cli_smb2_close_fnum_recv(subreq);
> +	tevent_req_simple_finish_ntstatus(subreq, status);
>  }
>  
>  NTSTATUS cli_smb2_rmdir_recv(struct tevent_req *req)
> -- 
> 2.11.0
> 
> 
> From 3752c4767c9a0739cd82ca5986dc203c6d48d6d7 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Thu, 28 Feb 2019 21:18:06 +0100
> Subject: [PATCH 2/3] libsmb: Use tevent_req_simple_finish_ntstatus()
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  source3/libsmb/cli_smb2_fnum.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
> index d5beaae9896..4352e504cfc 100644
> --- a/source3/libsmb/cli_smb2_fnum.c
> +++ b/source3/libsmb/cli_smb2_fnum.c
> @@ -4240,11 +4240,7 @@ static void cli_smb2_shadow_copy_data_fnum_done(struct tevent_req *subreq)
>  	status = smb2cli_ioctl_recv(subreq, state,
>  				&state->out_input_buffer,
>  				&state->out_output_buffer);
> -	TALLOC_FREE(subreq);
> -	if (tevent_req_nterror(req, status)) {
> -		return;
> -	}
> -	tevent_req_done(req);
> +	tevent_req_simple_finish_ntstatus(subreq, status);
>  }
>  
>  static NTSTATUS cli_smb2_shadow_copy_data_fnum_recv(struct tevent_req *req,
> -- 
> 2.11.0
> 
> 
> From a3e0ed84389ce3cb8697911caa6ffc33937bc81e Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Thu, 28 Feb 2019 21:47:51 +0100
> Subject: [PATCH 3/3] libsmb: Make cli_posix_unlink/rmdir proper
>  tevent_req/subreq pairs
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  source3/libsmb/clifile.c | 63 ++++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 58 insertions(+), 5 deletions(-)
> 
> diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
> index 7d72dc82858..49e58c0d252 100644
> --- a/source3/libsmb/clifile.c
> +++ b/source3/libsmb/clifile.c
> @@ -5486,13 +5486,43 @@ static void cli_posix_unlink_internal_done(struct tevent_req *subreq)
>  	tevent_req_simple_finish_ntstatus(subreq, status);
>  }
>  
> +static NTSTATUS cli_posix_unlink_internal_recv(struct tevent_req *req)
> +{
> +	return tevent_req_simple_recv_ntstatus(req);
> +}
> +
> +struct cli_posix_unlink_state {
> +	uint8_t dummy;
> +};
> +
> +static void cli_posix_unlink_done(struct tevent_req *subreq);
> +
>  struct tevent_req *cli_posix_unlink_send(TALLOC_CTX *mem_ctx,
>  					struct tevent_context *ev,
>  					struct cli_state *cli,
>  					const char *fname)
>  {
> -	return cli_posix_unlink_internal_send(mem_ctx, ev, cli, fname,
> -					      SMB_POSIX_UNLINK_FILE_TARGET);
> +	struct tevent_req *req = NULL, *subreq = NULL;
> +	struct cli_posix_unlink_state *state;
> +
> +	req = tevent_req_create(
> +		mem_ctx, &state, struct cli_posix_unlink_state);
> +	if (req == NULL) {
> +		return NULL;
> +	}
> +	subreq = cli_posix_unlink_internal_send(
> +		mem_ctx, ev, cli, fname, SMB_POSIX_UNLINK_FILE_TARGET);
> +	if (tevent_req_nomem(subreq, req)) {
> +		return tevent_req_post(req, ev);
> +	}
> +	tevent_req_set_callback(subreq, cli_posix_unlink_done, req);
> +	return req;
> +}
> +
> +static void cli_posix_unlink_done(struct tevent_req *subreq)
> +{
> +	NTSTATUS status = cli_posix_unlink_internal_recv(subreq);
> +	tevent_req_simple_finish_ntstatus(subreq, status);
>  }
>  
>  NTSTATUS cli_posix_unlink_recv(struct tevent_req *req)
> @@ -5549,14 +5579,37 @@ NTSTATUS cli_posix_unlink(struct cli_state *cli, const char *fname)
>   rmdir - POSIX semantics.
>  ****************************************************************************/
>  
> +struct cli_posix_rmdir_state {
> +	uint8_t dummy;
> +};
> +
> +static void cli_posix_rmdir_done(struct tevent_req *subreq);
> +
>  struct tevent_req *cli_posix_rmdir_send(TALLOC_CTX *mem_ctx,
>  					struct tevent_context *ev,
>  					struct cli_state *cli,
>  					const char *fname)
>  {
> -	return cli_posix_unlink_internal_send(
> -		mem_ctx, ev, cli, fname,
> -		SMB_POSIX_UNLINK_DIRECTORY_TARGET);
> +	struct tevent_req *req = NULL, *subreq = NULL;
> +	struct cli_posix_rmdir_state *state;
> +
> +	req = tevent_req_create(mem_ctx, &state, struct cli_posix_rmdir_state);
> +	if (req == NULL) {
> +		return NULL;
> +	}
> +	subreq = cli_posix_unlink_internal_send(
> +		mem_ctx, ev, cli, fname, SMB_POSIX_UNLINK_DIRECTORY_TARGET);
> +	if (tevent_req_nomem(subreq, req)) {
> +		return tevent_req_post(req, ev);
> +	}
> +	tevent_req_set_callback(subreq, cli_posix_rmdir_done, req);
> +	return req;
> +}
> +
> +static void cli_posix_rmdir_done(struct tevent_req *subreq)
> +{
> +	NTSTATUS status = cli_posix_unlink_internal_recv(subreq);
> +	tevent_req_simple_finish_ntstatus(subreq, status);
>  }
>  
>  NTSTATUS cli_posix_rmdir_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
> -- 
> 2.11.0
> 




More information about the samba-technical mailing list