[PATCH] some cleanups

Volker Lendecke vl at samba.org
Fri Jul 29 13:24:48 UTC 2016


Hi!

Attached find some cleanups. I can't get them through a private
autobuild, even master for mails reliably fails in

tests/eventscripts/01.reclock.monitor.005.sh

Maybe someone can take a look nevertheless.

Thanks, Volker
-------------- next part --------------
>From 16dd36a2b4044d97a9af895f83aa499459576a3f Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 29 Jul 2016 10:53:20 +0200
Subject: [PATCH 1/3] ctdb: Fix uninitialized variable warnings

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 ctdb/tools/ctdb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index d0381a5..0497e89 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -4951,7 +4951,7 @@ static int control_setlmasterrole(TALLOC_CTX *mem_ctx,
 				  struct ctdb_context *ctdb,
 				  int argc, const char **argv)
 {
-	uint32_t lmasterrole;
+	uint32_t lmasterrole = 0;
 	int ret;
 
 	if (argc != 1) {
@@ -4979,7 +4979,7 @@ static int control_setrecmasterrole(TALLOC_CTX *mem_ctx,
 				    struct ctdb_context *ctdb,
 				    int argc, const char **argv)
 {
-	uint32_t recmasterrole;
+	uint32_t recmasterrole = 0;
 	int ret;
 
 	if (argc != 1) {
-- 
2.1.4


>From fccf5ae15853cc0419ed801fc159490ee20f3e20 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 29 Jul 2016 10:54:39 +0200
Subject: [PATCH 2/3] lib: Fix a pointless error check

According to susv4, addr.s6_addr is a

uint8_t s6_addr[16]

which is always != 0

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source4/lib/socket/socket_ip.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/source4/lib/socket/socket_ip.c b/source4/lib/socket/socket_ip.c
index d531053..6ec5252 100644
--- a/source4/lib/socket/socket_ip.c
+++ b/source4/lib/socket/socket_ip.c
@@ -861,7 +861,8 @@ static NTSTATUS ipv6_sendto(struct socket_context *sock,
 		
 		ZERO_STRUCT(srv_addr);
 		addr                     = interpret_addr6(dest_addr->addr);
-		if (addr.s6_addr == 0) {
+		if (memcmp(&addr.s6_addr, &in6addr_any,
+			   sizeof(addr.s6_addr)) == 0) {
 			return NT_STATUS_HOST_UNREACHABLE;
 		}
 		srv_addr.sin6_addr = addr;
-- 
2.1.4


>From cfeee975455bb8b8d3dc03f2990bccec7f45ca92 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 29 Jul 2016 14:00:10 +0200
Subject: [PATCH 3/3] ldb: Fix two signed/unsigned hickups

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 lib/ldb/common/ldb_dn.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/ldb/common/ldb_dn.c b/lib/ldb/common/ldb_dn.c
index 3fa5ab5..b23ee17 100644
--- a/lib/ldb/common/ldb_dn.c
+++ b/lib/ldb/common/ldb_dn.c
@@ -1699,7 +1699,7 @@ bool ldb_dn_remove_child_components(struct ldb_dn *dn, unsigned int num)
  */
 bool ldb_dn_replace_components(struct ldb_dn *dn, struct ldb_dn *new_dn)
 {
-	int i;
+	unsigned int i;
 
 	if ( ! ldb_dn_validate(dn) || ! ldb_dn_validate(new_dn)) {
 		return false;
@@ -1904,11 +1904,11 @@ int ldb_dn_set_component(struct ldb_dn *dn, int num,
 		return LDB_ERR_OTHER;
 	}
 
-	if (num >= dn->comp_num) {
+	if (num < 0) {
 		return LDB_ERR_OTHER;
 	}
 
-	if (num < 0) {
+	if ((unsigned)num >= dn->comp_num) {
 		return LDB_ERR_OTHER;
 	}
 
-- 
2.1.4



More information about the samba-technical mailing list