[PATCH] Some smaller cleanups from my attic

Jeremy Allison jra at samba.org
Mon May 16 17:51:32 UTC 2016


On Mon, May 16, 2016 at 04:58:25PM +0200, Volker Lendecke wrote:
> Hi!
> 
> Review appreciated!

LGTM. Pushed !

> -- 
> 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 c3c6a8850df809fa5e99cbe8287e6bab07d809f1 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Sun, 24 Apr 2016 16:07:43 +0200
> Subject: [PATCH 1/4] ctdb: Improve debug in case of set_runstate failure
> 
> If this fails, we want to know which states it wanted to move to. Don't do the
> return before the debug.
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  ctdb/common/ctdb_util.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/ctdb/common/ctdb_util.c b/ctdb/common/ctdb_util.c
> index 39108bc..154878b 100644
> --- a/ctdb/common/ctdb_util.c
> +++ b/ctdb/common/ctdb_util.c
> @@ -642,12 +642,13 @@ enum ctdb_runstate runstate_from_string(const char *label)
>  
>  void ctdb_set_runstate(struct ctdb_context *ctdb, enum ctdb_runstate runstate)
>  {
> +	DEBUG(DEBUG_NOTICE,("Set runstate to %s (%d)\n",
> +			    runstate_to_string(runstate), runstate));
> +
>  	if (runstate <= ctdb->runstate) {
>  		ctdb_fatal(ctdb, "runstate must always increase");
>  	}
>  
> -	DEBUG(DEBUG_NOTICE,("Set runstate to %s (%d)\n",
> -			    runstate_to_string(runstate), runstate));
>  	ctdb->runstate = runstate;
>  }
>  
> -- 
> 1.9.1
> 
> 
> From 3975174255fc0511a541af39fda372fd56873355 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Mon, 16 May 2016 16:42:18 +0200
> Subject: [PATCH 2/4] ctdb: Fix the O3 developer build
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  ctdb/tests/src/fake_ctdbd.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/ctdb/tests/src/fake_ctdbd.c b/ctdb/tests/src/fake_ctdbd.c
> index e198a5d..0d08313 100644
> --- a/ctdb/tests/src/fake_ctdbd.c
> +++ b/ctdb/tests/src/fake_ctdbd.c
> @@ -2025,7 +2025,8 @@ static void server_new_client(struct tevent_req *subreq)
>  	struct server_state *state = tevent_req_data(
>  		req, struct server_state);
>  	struct ctdbd_context *ctdb = state->ctdb;
> -	int client_fd, ret;
> +	int client_fd;
> +	int ret = 0;
>  
>  	client_fd = accept_recv(subreq, &ret);
>  	TALLOC_FREE(subreq);
> @@ -2057,7 +2058,8 @@ static void server_client_done(struct tevent_req *subreq)
>  	struct server_state *state = tevent_req_data(
>  		req, struct server_state);
>  	struct ctdbd_context *ctdb = state->ctdb;
> -	int ret, status;
> +	int ret = 0;
> +	int status;
>  
>  	status = client_recv(subreq, &ret);
>  	TALLOC_FREE(subreq);
> -- 
> 1.9.1
> 
> 
> From 7c9e13022b0b81a1cd86fc47ba8477cd0f2a3446 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Sun, 1 May 2016 17:28:56 +0200
> Subject: [PATCH 3/4] lib: Fix a signed/unsigned mixup
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  lib/crypto/arcfour.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/crypto/arcfour.c b/lib/crypto/arcfour.c
> index d310649..00054d3 100644
> --- a/lib/crypto/arcfour.c
> +++ b/lib/crypto/arcfour.c
> @@ -25,7 +25,7 @@
>  /* initialise the arcfour sbox with key */
>  _PUBLIC_ void arcfour_init(struct arcfour_state *state, const DATA_BLOB *key) 
>  {
> -	int ind;
> +	size_t ind;
>  	uint8_t j = 0;
>  	for (ind = 0; ind < sizeof(state->sbox); ind++) {
>  		state->sbox[ind] = (uint8_t)ind;
> -- 
> 1.9.1
> 
> 
> From 30c2d5bb782c138921c071418730ff0d0688eff1 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Sun, 1 May 2016 17:30:11 +0200
> Subject: [PATCH 4/4] lib: Fix some whitespace
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  lib/crypto/arcfour.c | 25 +++++++++++++------------
>  1 file changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/lib/crypto/arcfour.c b/lib/crypto/arcfour.c
> index 00054d3..af9b20c 100644
> --- a/lib/crypto/arcfour.c
> +++ b/lib/crypto/arcfour.c
> @@ -1,20 +1,20 @@
> -/* 
> +/*
>     Unix SMB/CIFS implementation.
>  
>     An implementation of the arcfour algorithm
>  
>     Copyright (C) Andrew Tridgell 1998
> -   
> +
>     This program is free software; you can redistribute it and/or modify
>     it under the terms of the GNU General Public License as published by
>     the Free Software Foundation; either version 3 of the License, or
>     (at your option) any later version.
> -   
> +
>     This program is distributed in the hope that it will be useful,
>     but WITHOUT ANY WARRANTY; without even the implied warranty of
>     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>     GNU General Public License for more details.
> -   
> +
>     You should have received a copy of the GNU General Public License
>     along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  */
> @@ -23,19 +23,19 @@
>  #include "../lib/crypto/arcfour.h"
>  
>  /* initialise the arcfour sbox with key */
> -_PUBLIC_ void arcfour_init(struct arcfour_state *state, const DATA_BLOB *key) 
> +_PUBLIC_ void arcfour_init(struct arcfour_state *state, const DATA_BLOB *key)
>  {
>  	size_t ind;
>  	uint8_t j = 0;
>  	for (ind = 0; ind < sizeof(state->sbox); ind++) {
>  		state->sbox[ind] = (uint8_t)ind;
>  	}
> -	
> +
>  	for (ind = 0; ind < sizeof(state->sbox); ind++) {
>  		uint8_t tc;
> -		
> +
>  		j += (state->sbox[ind] + key->data[ind%key->length]);
> -		
> +
>  		tc = state->sbox[ind];
>  		state->sbox[ind] = state->sbox[j];
>  		state->sbox[j] = tc;
> @@ -45,10 +45,11 @@ _PUBLIC_ void arcfour_init(struct arcfour_state *state, const DATA_BLOB *key)
>  }
>  
>  /* crypt the data with arcfour */
> -_PUBLIC_ void arcfour_crypt_sbox(struct arcfour_state *state, uint8_t *data, int len) 
> +_PUBLIC_ void arcfour_crypt_sbox(struct arcfour_state *state, uint8_t *data,
> +				 int len)
>  {
>  	int ind;
> -	
> +
>  	for (ind = 0; ind < len; ind++) {
>  		uint8_t tc;
>  		uint8_t t;
> @@ -59,7 +60,7 @@ _PUBLIC_ void arcfour_crypt_sbox(struct arcfour_state *state, uint8_t *data, int
>  		tc = state->sbox[state->index_i];
>  		state->sbox[state->index_i] = state->sbox[state->index_j];
>  		state->sbox[state->index_j] = tc;
> -		
> +
>  		t = state->sbox[state->index_i] + state->sbox[state->index_j];
>  		data[ind] = data[ind] ^ state->sbox[t];
>  	}
> @@ -68,7 +69,7 @@ _PUBLIC_ void arcfour_crypt_sbox(struct arcfour_state *state, uint8_t *data, int
>  /*
>    arcfour encryption with a blob key
>  */
> -_PUBLIC_ void arcfour_crypt_blob(uint8_t *data, int len, const DATA_BLOB *key) 
> +_PUBLIC_ void arcfour_crypt_blob(uint8_t *data, int len, const DATA_BLOB *key)
>  {
>  	struct arcfour_state state;
>  	arcfour_init(&state, key);
> -- 
> 1.9.1
> 




More information about the samba-technical mailing list