[PATCH] 3 small cleanups

Volker Lendecke Volker.Lendecke at SerNet.DE
Sun Mar 6 13:15:58 UTC 2016


Hi!

Review appreciated!

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
-------------- next part --------------
From 7699ea262250fa6fb7459a0dfb840f88a080d98b Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 28 Feb 2016 17:56:23 +0100
Subject: [PATCH 1/3] lib: Introduce SERVER_ID_BUF_LENGTH

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 lib/util/samba_util.h       |    7 +++++--
 lib/util/server_id.c        |    6 ++++--
 source3/lib/messages_util.c |    8 ++++----
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h
index 56cde7b..9d6f0d8 100644
--- a/lib/util/samba_util.h
+++ b/lib/util/samba_util.h
@@ -722,8 +722,11 @@ void server_id_set_disconnected(struct server_id *id);
  */
 bool server_id_is_disconnected(const struct server_id *id);
 
-void server_id_put(uint8_t buf[24], const struct server_id id);
-void server_id_get(struct server_id *id, const uint8_t buf[24]);
+#define SERVER_ID_BUF_LENGTH 24
+void server_id_put(uint8_t buf[SERVER_ID_BUF_LENGTH],
+		   const struct server_id id);
+void server_id_get(struct server_id *id,
+		   const uint8_t buf[SERVER_ID_BUF_LENGTH]);
 
 /*
  * Samba code should use samba_tevent_context_init() instead of
diff --git a/lib/util/server_id.c b/lib/util/server_id.c
index 83a262d..77c5ee1 100644
--- a/lib/util/server_id.c
+++ b/lib/util/server_id.c
@@ -202,7 +202,8 @@ bool server_id_is_disconnected(const struct server_id *id)
 	return server_id_equal(id, &dis);
 }
 
-void server_id_put(uint8_t buf[24], const struct server_id id)
+void server_id_put(uint8_t buf[SERVER_ID_BUF_LENGTH],
+		   const struct server_id id)
 {
 	SBVAL(buf, 0,  id.pid);
 	SIVAL(buf, 8,  id.task_id);
@@ -210,7 +211,8 @@ void server_id_put(uint8_t buf[24], const struct server_id id)
 	SBVAL(buf, 16, id.unique_id);
 }
 
-void server_id_get(struct server_id *id, const uint8_t buf[24])
+void server_id_get(struct server_id *id,
+		   const uint8_t buf[SERVER_ID_BUF_LENGTH])
 {
 	id->pid       = BVAL(buf, 0);
 	id->task_id   = IVAL(buf, 8);
diff --git a/source3/lib/messages_util.c b/source3/lib/messages_util.c
index 24c364c..7c11ecf 100644
--- a/source3/lib/messages_util.c
+++ b/source3/lib/messages_util.c
@@ -27,8 +27,8 @@ void message_hdr_put(uint8_t buf[MESSAGE_HDR_LENGTH], uint32_t msg_type,
 		     struct server_id src, struct server_id dst)
 {
 	server_id_put(buf, dst);
-	server_id_put(buf + 24, src);
-	SIVAL(buf, 48, msg_type);
+	server_id_put(buf + SERVER_ID_BUF_LENGTH, src);
+	SIVAL(buf, 2 * SERVER_ID_BUF_LENGTH, msg_type);
 }
 
 void message_hdr_get(uint32_t *msg_type, struct server_id *src,
@@ -36,6 +36,6 @@ void message_hdr_get(uint32_t *msg_type, struct server_id *src,
 		     const uint8_t buf[MESSAGE_HDR_LENGTH])
 {
 	server_id_get(dst, buf);
-	server_id_get(src, buf + 24);
-	*msg_type = IVAL(buf, 48);
+	server_id_get(src, buf + SERVER_ID_BUF_LENGTH);
+	*msg_type = IVAL(buf, 2 * SERVER_ID_BUF_LENGTH);
 }
-- 
1.7.9.5


From d3a3c551c1154055359825566e1ea607c5926557 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 22 Feb 2016 20:39:20 +0100
Subject: [PATCH 2/3] lib: Avoid "includes.h" in dbwrap.c

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 lib/dbwrap/dbwrap.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/dbwrap/dbwrap.c b/lib/dbwrap/dbwrap.c
index a1b98c3..f7dcb8a 100644
--- a/lib/dbwrap/dbwrap.c
+++ b/lib/dbwrap/dbwrap.c
@@ -19,7 +19,10 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "includes.h"
+#include "replace.h"
+#include "lib/util/debug.h"
+#include "lib/util/fault.h"
+#include "lib/util/talloc_stack.h"
 #include "dbwrap/dbwrap.h"
 #include "dbwrap/dbwrap_private.h"
 #include "lib/util/util_tdb.h"
-- 
1.7.9.5


From e98ed6858ea912332c5f8ed6e88c22601ab30817 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 22 Feb 2016 21:32:08 +0100
Subject: [PATCH 3/3] g_lock: Remove some unneeded includes

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/lib/g_lock.c |    3 ---
 1 file changed, 3 deletions(-)

diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c
index 346c1ed..1928f5e 100644
--- a/source3/lib/g_lock.c
+++ b/source3/lib/g_lock.c
@@ -24,10 +24,7 @@
 #include "dbwrap/dbwrap_watch.h"
 #include "g_lock.h"
 #include "util_tdb.h"
-#include "ctdbd_conn.h"
-#include "../lib/util/select.h"
 #include "../lib/util/tevent_ntstatus.h"
-#include "system/select.h"
 #include "messages.h"
 #include "serverid.h"
 
-- 
1.7.9.5



More information about the samba-technical mailing list