[PATCH] Few trivial cleanups
Volker Lendecke
Volker.Lendecke at SerNet.DE
Tue Feb 13 20:16:19 UTC 2018
Hi!
Review appreciated!
Thanks, Volker
--
Besuchen Sie die verinice.XP 2018 in Berlin,
Anwenderkonferenz für Informationssicherheit
vom 21.-23.03.2018 im Sofitel Kurfürstendamm
Info & Anmeldung hier: http://veriniceXP.org
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 346b0936f531f3b06b7a6b483715dc3a8f386bb3 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 13 Feb 2018 14:05:15 +0100
Subject: [PATCH 1/4] winbind: Don't explicitly send "server_id" for
ONLINESTATUS
Messaging already provides the sender id
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/utils/smbcontrol.c | 8 ++------
source3/winbindd/winbindd_dual.c | 9 +--------
2 files changed, 3 insertions(+), 14 deletions(-)
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index 0f6dacce20d..4b47d3bed57 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -1160,10 +1160,6 @@ static bool do_winbind_onlinestatus(struct tevent_context *ev_ctx,
const struct server_id pid,
const int argc, const char **argv)
{
- struct server_id myid;
-
- myid = messaging_server_id(msg_ctx);
-
if (argc != 1) {
fprintf(stderr, "Usage: smbcontrol winbindd onlinestatus\n");
return False;
@@ -1172,9 +1168,9 @@ static bool do_winbind_onlinestatus(struct tevent_context *ev_ctx,
messaging_register(msg_ctx, NULL, MSG_WINBIND_ONLINESTATUS,
print_pid_string_cb);
- if (!send_message(msg_ctx, pid, MSG_WINBIND_ONLINESTATUS, &myid,
- sizeof(myid)))
+ if (!send_message(msg_ctx, pid, MSG_WINBIND_ONLINESTATUS, NULL, 0)) {
return False;
+ }
wait_replies(ev_ctx, msg_ctx, procid_to_pid(&pid) == 0);
diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
index 993166d82d9..7b1527c38f3 100644
--- a/source3/winbindd/winbindd_dual.c
+++ b/source3/winbindd/winbindd_dual.c
@@ -796,16 +796,9 @@ void winbind_msg_onlinestatus(struct messaging_context *msg_ctx,
{
TALLOC_CTX *mem_ctx;
const char *message;
- struct server_id *sender;
DEBUG(5,("winbind_msg_onlinestatus received.\n"));
- if (!data->data) {
- return;
- }
-
- sender = (struct server_id *)data->data;
-
mem_ctx = talloc_init("winbind_msg_onlinestatus");
if (mem_ctx == NULL) {
return;
@@ -817,7 +810,7 @@ void winbind_msg_onlinestatus(struct messaging_context *msg_ctx,
return;
}
- messaging_send_buf(msg_ctx, *sender, MSG_WINBIND_ONLINESTATUS,
+ messaging_send_buf(msg_ctx, server_id, MSG_WINBIND_ONLINESTATUS,
(const uint8_t *)message, strlen(message) + 1);
talloc_destroy(mem_ctx);
--
2.11.0
From 30db12114f80b24bef5b343778065ec635110539 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 13 Feb 2018 14:05:43 +0100
Subject: [PATCH 2/4] winbind: Don't send "server_id" explicitly for
DUMP_DOMAIN_LIST
messaging already provides the sender id
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/utils/smbcontrol.c | 18 +-----------------
source3/winbindd/winbindd_dual.c | 18 ++++--------------
2 files changed, 5 insertions(+), 31 deletions(-)
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index 4b47d3bed57..c4b56305217 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -1204,11 +1204,6 @@ static bool do_winbind_dump_domain_list(struct tevent_context *ev_ctx,
{
const char *domain = NULL;
int domain_len = 0;
- struct server_id myid;
- uint8_t *buf = NULL;
- int buf_len = 0;
-
- myid = messaging_server_id(msg_ctx);
if (argc < 1 || argc > 2) {
fprintf(stderr, "Usage: smbcontrol <dest> dump-domain-list "
@@ -1224,19 +1219,9 @@ static bool do_winbind_dump_domain_list(struct tevent_context *ev_ctx,
messaging_register(msg_ctx, NULL, MSG_WINBIND_DUMP_DOMAIN_LIST,
print_pid_string_cb);
- buf_len = sizeof(myid)+domain_len;
- buf = SMB_MALLOC_ARRAY(uint8_t, buf_len);
- if (!buf) {
- return false;
- }
-
- memcpy(buf, &myid, sizeof(myid));
- memcpy(&buf[sizeof(myid)], domain, domain_len);
-
if (!send_message(msg_ctx, pid, MSG_WINBIND_DUMP_DOMAIN_LIST,
- buf, buf_len))
+ domain, domain_len))
{
- SAFE_FREE(buf);
return false;
}
@@ -1244,7 +1229,6 @@ static bool do_winbind_dump_domain_list(struct tevent_context *ev_ctx,
/* No replies were received within the timeout period */
- SAFE_FREE(buf);
if (num_replies == 0) {
printf("No replies received\n");
}
diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
index 7b1527c38f3..7fb5aa899e4 100644
--- a/source3/winbindd/winbindd_dual.c
+++ b/source3/winbindd/winbindd_dual.c
@@ -848,7 +848,6 @@ void winbind_msg_dump_domain_list(struct messaging_context *msg_ctx,
{
TALLOC_CTX *mem_ctx;
const char *message = NULL;
- struct server_id *sender = NULL;
const char *domain = NULL;
char *s = NULL;
NTSTATUS status;
@@ -856,22 +855,13 @@ void winbind_msg_dump_domain_list(struct messaging_context *msg_ctx,
DEBUG(5,("winbind_msg_dump_domain_list received.\n"));
- if (!data || !data->data) {
- return;
- }
-
- if (data->length < sizeof(struct server_id)) {
- return;
- }
-
mem_ctx = talloc_init("winbind_msg_dump_domain_list");
if (!mem_ctx) {
return;
}
- sender = (struct server_id *)data->data;
- if (data->length > sizeof(struct server_id)) {
- domain = (const char *)data->data+sizeof(struct server_id);
+ if (data->length > 0) {
+ domain = (const char *)data->data;
}
if (domain) {
@@ -886,7 +876,7 @@ void winbind_msg_dump_domain_list(struct messaging_context *msg_ctx,
return;
}
- messaging_send_buf(msg_ctx, *sender,
+ messaging_send_buf(msg_ctx, server_id,
MSG_WINBIND_DUMP_DOMAIN_LIST,
(const uint8_t *)message, strlen(message) + 1);
@@ -911,7 +901,7 @@ void winbind_msg_dump_domain_list(struct messaging_context *msg_ctx,
}
}
- status = messaging_send_buf(msg_ctx, *sender,
+ status = messaging_send_buf(msg_ctx, server_id,
MSG_WINBIND_DUMP_DOMAIN_LIST,
(uint8_t *)s, strlen(s) + 1);
if (!NT_STATUS_IS_OK(status)) {
--
2.11.0
From 2e3852a2333699119b8b05abe26868dd44d2eae4 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 11 Feb 2018 19:49:19 +0100
Subject: [PATCH 3/4] tevent: Add a helper variable
Easier to read for me :-)
Signed-off-by: Volker Lendecke <vl at samba.org>
---
lib/tevent/tevent_queue.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/tevent/tevent_queue.c b/lib/tevent/tevent_queue.c
index 5516c6cb1e5..2f82e28a4f6 100644
--- a/lib/tevent/tevent_queue.c
+++ b/lib/tevent/tevent_queue.c
@@ -136,17 +136,19 @@ static void tevent_queue_immediate_trigger(struct tevent_context *ev,
struct tevent_queue *q =
talloc_get_type_abort(private_data,
struct tevent_queue);
+ struct tevent_queue_entry *e;
if (!q->running) {
return;
}
- if (!q->list) {
+ e = q->list;
+ if (e == NULL) {
return;
}
- q->list->triggered = true;
- q->list->trigger(q->list->req, q->list->private_data);
+ e->triggered = true;
+ e->trigger(e->req, e->private_data);
}
static struct tevent_queue_entry *tevent_queue_add_internal(
--
2.11.0
From 467cba727791d3c33c9c3c21f645e6371682122e Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 11 Feb 2018 19:50:06 +0100
Subject: [PATCH 4/4] tevent: Simplify tevent_queue_add a bit
Easier to read for me :-)
Signed-off-by: Volker Lendecke <vl at samba.org>
---
lib/tevent/tevent_queue.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/lib/tevent/tevent_queue.c b/lib/tevent/tevent_queue.c
index 2f82e28a4f6..d76f4f126d0 100644
--- a/lib/tevent/tevent_queue.c
+++ b/lib/tevent/tevent_queue.c
@@ -239,11 +239,7 @@ bool tevent_queue_add(struct tevent_queue *queue,
e = tevent_queue_add_internal(queue, ev, req,
trigger, private_data, false);
- if (e == NULL) {
- return false;
- }
-
- return true;
+ return (e != NULL);
}
struct tevent_queue_entry *tevent_queue_add_entry(
--
2.11.0
More information about the samba-technical
mailing list