[PATCH] libcli/smb: Use helper function for finding session
Jeremy Allison
jra at samba.org
Tue Nov 17 23:57:45 UTC 2015
LGTM - pushed !
On Tue, Nov 17, 2015 at 04:26:51PM -0700, Christof Schmitt wrote:
> From 26b49497c826b6b8089dfe42f996f1997e26fc02 Mon Sep 17 00:00:00 2001
> From: Christof Schmitt <cs at samba.org>
> Date: Wed, 21 Oct 2015 12:04:47 -0700
> Subject: [PATCH] libcli/smb: Use helper function for finding session
>
> This removes some duplicated code.
>
> Signed-off-by: Christof Schmitt <cs at samba.org>
> ---
> libcli/smb/smbXcli_base.c | 37 ++++++++++++++++++-------------------
> 1 files changed, 18 insertions(+), 19 deletions(-)
>
> diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c
> index 6fe4816..1f1b6cd 100644
> --- a/libcli/smb/smbXcli_base.c
> +++ b/libcli/smb/smbXcli_base.c
> @@ -3295,6 +3295,21 @@ static void smb2cli_req_writev_done(struct tevent_req *subreq)
> }
> }
>
> +static struct smbXcli_session* smbXcli_session_by_uid(struct smbXcli_conn *conn,
> + uint64_t uid)
> +{
> + struct smbXcli_session *s = conn->sessions;
> +
> + for (; s; s = s->next) {
> + if (s->smb2->session_id != uid) {
> + continue;
> + }
> + break;
> + }
> +
> + return s;
> +}
> +
> static NTSTATUS smb2cli_inbuf_parse_compound(struct smbXcli_conn *conn,
> uint8_t *buf,
> size_t buflen,
> @@ -3362,14 +3377,7 @@ static NTSTATUS smb2cli_inbuf_parse_compound(struct smbXcli_conn *conn,
> goto inval;
> }
>
> - s = conn->sessions;
> - for (; s; s = s->next) {
> - if (s->smb2->session_id != uid) {
> - continue;
> - }
> - break;
> - }
> -
> + s = smbXcli_session_by_uid(conn, uid);
> if (s == NULL) {
> DEBUG(10, ("unknown session_id %llu\n",
> (unsigned long long)uid));
> @@ -3588,17 +3596,8 @@ static NTSTATUS smb2cli_conn_dispatch_incoming(struct smbXcli_conn *conn,
> uint64_t uid = BVAL(inhdr, SMB2_HDR_SESSION_ID);
>
> if (session == NULL) {
> - struct smbXcli_session *s;
> -
> - s = state->conn->sessions;
> - for (; s; s = s->next) {
> - if (s->smb2->session_id != uid) {
> - continue;
> - }
> -
> - session = s;
> - break;
> - }
> + session = smbXcli_session_by_uid(state->conn,
> + uid);
> }
>
> if (session == NULL) {
> --
> 1.7.1
>
More information about the samba-technical
mailing list