[PATCH] smbd: Simplify new_break_message_smb1
Michael Adam
obnox at samba.org
Tue Aug 20 04:40:52 MDT 2013
Pushed to autobuild.
On 2013-08-20 at 12:16 +0200, Volker Lendecke wrote:
> Hi!
>
> Please review&push!
>
> Thanks,
>
> Volker
>
> --
> SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
> phone: +49-551-370000-0, fax: +49-551-370000-9
> AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
> http://www.sernet.de, mailto:kontakt at sernet.de
> From 8a5cbbbb670fc46a7126b5cb8abf000fde1865bc Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Mon, 19 Aug 2013 12:28:24 +0000
> Subject: [PATCH] smbd: Simplify new_break_message_smb1
>
> There's no point in allocating a fixed length array that we throw away
> immediately after use.
>
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
> source3/smbd/oplock.c | 25 +++++++------------------
> 1 file changed, 7 insertions(+), 18 deletions(-)
>
> diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
> index fbdd6c8..21792bd 100644
> --- a/source3/smbd/oplock.c
> +++ b/source3/smbd/oplock.c
> @@ -223,16 +223,11 @@ bool should_notify_deferred_opens(struct smbd_server_connection *sconn)
> Set up an oplock break message.
> ****************************************************************************/
>
> -static char *new_break_message_smb1(TALLOC_CTX *mem_ctx,
> - files_struct *fsp, int cmd)
> -{
> - char *result = talloc_array(mem_ctx, char, smb_size + 8*2 + 0);
> -
> - if (result == NULL) {
> - DEBUG(0, ("talloc failed\n"));
> - return NULL;
> - }
> +#define SMB1_BREAK_MESSAGE_LENGTH (smb_size + 8*2)
>
> +static void new_break_message_smb1(files_struct *fsp, int cmd,
> + char result[SMB1_BREAK_MESSAGE_LENGTH])
> +{
> memset(result,'\0',smb_size);
> srv_set_message(result,8,0,true);
> SCVAL(result,smb_com,SMBlockingX);
> @@ -244,7 +239,6 @@ static char *new_break_message_smb1(TALLOC_CTX *mem_ctx,
> SSVAL(result,smb_vwv2,fsp->fnum);
> SCVAL(result,smb_vwv3,LOCKING_ANDX_OPLOCK_RELEASE);
> SCVAL(result,smb_vwv3+1,cmd);
> - return result;
> }
>
> /****************************************************************************
> @@ -369,12 +363,9 @@ static void add_oplock_timeout_handler(files_struct *fsp)
>
> static void send_break_message_smb1(files_struct *fsp, int level)
> {
> - char *break_msg = new_break_message_smb1(talloc_tos(),
> - fsp,
> - level);
> - if (break_msg == NULL) {
> - exit_server("Could not talloc break_msg\n");
> - }
> + char break_msg[SMB1_BREAK_MESSAGE_LENGTH];
> +
> + new_break_message_smb1(fsp, level, break_msg);
>
> show_msg(break_msg);
> if (!srv_send_smb(fsp->conn->sconn,
> @@ -384,8 +375,6 @@ static void send_break_message_smb1(files_struct *fsp, int level)
> exit_server_cleanly("send_break_message_smb1: "
> "srv_send_smb failed.");
> }
> -
> - TALLOC_FREE(break_msg);
> }
>
> static void break_level2_to_none_async(files_struct *fsp)
> --
> 1.8.1.2
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 215 bytes
Desc: Digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20130820/d3a1b11f/attachment.pgp>
More information about the samba-technical
mailing list