[PATCH] lib: Remove procid_str_static
Volker Lendecke
Volker.Lendecke at SerNet.DE
Tue Apr 28 00:13:40 MDT 2015
Hi!
Attached find a small cleanup patch removing a talloc_tos use.
Review&push 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 ace7e61003320aeb171b43211404d35dcf89591e Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 23 Apr 2015 18:06:17 +0200
Subject: [PATCH] lib: Remove procid_str_static
Replace all callers with direct calls to server_id_str_buf without
talloc_tos()
Signed-off-by: Volker Lendecke <vl at samba.org>
---
lib/util/debug_s3.c | 5 +++--
source3/include/proto.h | 1 -
source3/lib/dbwrap/dbwrap_watch.c | 6 +++---
source3/lib/util.c | 5 -----
source3/locking/brlock.c | 24 ++++++++++++++++++------
source3/locking/locking.c | 13 +++++++++----
source3/smbd/notify_internal.c | 8 +++++---
source3/smbd/open.c | 3 ++-
source3/smbd/server.c | 7 ++++---
source3/utils/net_status.c | 12 ++++++++----
source3/utils/status.c | 13 +++++++++----
11 files changed, 61 insertions(+), 36 deletions(-)
diff --git a/lib/util/debug_s3.c b/lib/util/debug_s3.c
index 160e2ef..d9ac15f 100644
--- a/lib/util/debug_s3.c
+++ b/lib/util/debug_s3.c
@@ -84,14 +84,15 @@ static void debuglevel_message(struct messaging_context *msg_ctx,
DATA_BLOB *data)
{
char *message = debug_list_class_names_and_levels();
+ struct server_id_buf tmp;
if (!message) {
DEBUG(0,("debuglevel_message - debug_list_class_names_and_levels returned NULL\n"));
return;
}
- DEBUG(1,("INFO: Received REQ_DEBUGLEVEL message from PID %s\n",
- procid_str_static(&src)));
+ DEBUG(1, ("INFO: Received REQ_DEBUGLEVEL message from PID %s\n",
+ server_id_str_buf(src, &tmp)));
messaging_send_buf(msg_ctx, src, MSG_DEBUGLEVEL,
(uint8 *)message, strlen(message) + 1);
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 30fd4fa..f73778f 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -437,7 +437,6 @@ struct server_id procid_self(void);
#define serverid_equal(p1, p2) server_id_equal(p1,p2)
bool procid_is_me(const struct server_id *pid);
struct server_id interpret_pid(const char *pid_string);
-char *procid_str_static(const struct server_id *pid);
bool procid_valid(const struct server_id *pid);
bool procid_is_local(const struct server_id *pid);
bool is_offset_safe(const char *buf_base, size_t buf_len, char *ptr, size_t off);
diff --git a/source3/lib/dbwrap/dbwrap_watch.c b/source3/lib/dbwrap/dbwrap_watch.c
index c0571d9..da1a9cc 100644
--- a/source3/lib/dbwrap/dbwrap_watch.c
+++ b/source3/lib/dbwrap/dbwrap_watch.c
@@ -356,10 +356,10 @@ static void dbwrap_watch_record_stored(struct db_context *db,
status = messaging_send_buf(msg, ids[i], MSG_DBWRAP_MODIFIED,
w_key.dptr, w_key.dsize);
if (!NT_STATUS_IS_OK(status)) {
- char *str = procid_str_static(&ids[i]);
+ struct server_id_buf tmp;
DEBUG(1, ("messaging_send to %s failed: %s\n",
- str, nt_errstr(status)));
- TALLOC_FREE(str);
+ server_id_str_buf(ids[i], &tmp),
+ nt_errstr(status)));
}
}
done:
diff --git a/source3/lib/util.c b/source3/lib/util.c
index e296fd5..c7ab0ee 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -1984,11 +1984,6 @@ struct server_id interpret_pid(const char *pid_string)
return server_id_from_string(get_my_vnn(), pid_string);
}
-char *procid_str_static(const struct server_id *pid)
-{
- return server_id_str(talloc_tos(), pid);
-}
-
bool procid_valid(const struct server_id *pid)
{
return (pid->pid != (uint64_t)-1);
diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c
index 46401a0..5dee91c 100644
--- a/source3/locking/brlock.c
+++ b/source3/locking/brlock.c
@@ -969,8 +969,12 @@ static NTSTATUS brl_lock_posix(struct messaging_context *msg_ctx,
if (pend_lock->lock_type == PENDING_READ_LOCK &&
brl_pending_overlap(plock, pend_lock)) {
- DEBUG(10,("brl_lock_posix: sending unlock message to pid %s\n",
- procid_str_static(&pend_lock->context.pid )));
+ struct server_id_buf tmp;
+
+ DEBUG(10, ("brl_lock_posix: sending unlock "
+ "message to pid %s\n",
+ server_id_str_buf(pend_lock->context.pid,
+ &tmp)));
messaging_send(msg_ctx, pend_lock->context.pid,
MSG_SMB_UNLOCK, &data_blob_null);
@@ -1155,8 +1159,12 @@ bool brl_unlock_windows_default(struct messaging_context *msg_ctx,
/* We could send specific lock info here... */
if (brl_pending_overlap(plock, pend_lock)) {
- DEBUG(10,("brl_unlock: sending unlock message to pid %s\n",
- procid_str_static(&pend_lock->context.pid )));
+ struct server_id_buf tmp;
+
+ DEBUG(10, ("brl_unlock: sending unlock message to "
+ "pid %s\n",
+ server_id_str_buf(pend_lock->context.pid,
+ &tmp)));
messaging_send(msg_ctx, pend_lock->context.pid,
MSG_SMB_UNLOCK, &data_blob_null);
@@ -1312,8 +1320,12 @@ static bool brl_unlock_posix(struct messaging_context *msg_ctx,
/* We could send specific lock info here... */
if (brl_pending_overlap(plock, pend_lock)) {
- DEBUG(10,("brl_unlock: sending unlock message to pid %s\n",
- procid_str_static(&pend_lock->context.pid )));
+ struct server_id_buf tmp;
+
+ DEBUG(10, ("brl_unlock: sending unlock message to "
+ "pid %s\n",
+ server_id_str_buf(pend_lock->context.pid,
+ &tmp)));
messaging_send(msg_ctx, pend_lock->context.pid,
MSG_SMB_UNLOCK, &data_blob_null);
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index ce595e1..67eff8f 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -426,12 +426,14 @@ void locking_close_file(struct messaging_context *msg_ctx,
char *share_mode_str(TALLOC_CTX *ctx, int num, const struct share_mode_entry *e)
{
+ struct server_id_buf tmp;
+
return talloc_asprintf(ctx, "share_mode_entry[%d]: "
"pid = %s, share_access = 0x%x, private_options = 0x%x, "
"access_mask = 0x%x, mid = 0x%llx, type= 0x%x, gen_id = %llu, "
"uid = %u, flags = %u, file_id %s, name_hash = 0x%x",
num,
- procid_str_static(&e->pid),
+ server_id_str_buf(e->pid, &tmp),
e->share_access, e->private_options,
e->access_mask, (unsigned long long)e->op_mid,
e->op_type, (unsigned long long)e->share_file_id,
@@ -533,6 +535,8 @@ bool rename_share_filename(struct messaging_context *msg_ctx,
/* Send the messages. */
for (i=0; i<d->num_share_modes; i++) {
struct share_mode_entry *se = &d->share_modes[i];
+ struct server_id_buf tmp;
+
if (!is_valid_share_mode_entry(se)) {
continue;
}
@@ -557,7 +561,7 @@ bool rename_share_filename(struct messaging_context *msg_ctx,
DEBUG(10,("rename_share_filename: sending rename message to "
"pid %s file_id %s sharepath %s base_name %s "
"stream_name %s\n",
- procid_str_static(&se->pid),
+ server_id_str_buf(se->pid, &tmp),
file_id_string_tos(&id),
d->servicepath, d->base_name,
has_stream ? d->stream_name : ""));
@@ -729,6 +733,7 @@ static void remove_share_mode_lease(struct share_mode_data *d,
*/
bool share_mode_stale_pid(struct share_mode_data *d, uint32_t idx)
{
+ struct server_id_buf tmp;
struct share_mode_entry *e;
if (idx > d->num_share_modes) {
@@ -745,12 +750,12 @@ bool share_mode_stale_pid(struct share_mode_data *d, uint32_t idx)
}
if (serverid_exists(&e->pid)) {
DEBUG(10, ("PID %s (index %u out of %u) still exists\n",
- procid_str_static(&e->pid), idx,
+ server_id_str_buf(e->pid, &tmp), idx,
(unsigned)d->num_share_modes));
return false;
}
DEBUG(10, ("PID %s (index %u out of %u) does not exist anymore\n",
- procid_str_static(&e->pid), idx,
+ server_id_str_buf(e->pid, &tmp), idx,
(unsigned)d->num_share_modes));
e->stale = true;
diff --git a/source3/smbd/notify_internal.c b/source3/smbd/notify_internal.c
index e612f16..845a7cc 100644
--- a/source3/smbd/notify_internal.c
+++ b/source3/smbd/notify_internal.c
@@ -444,12 +444,13 @@ static NTSTATUS notify_del_entry(struct db_record *rec,
void *private_data)
{
TDB_DATA value = dbwrap_record_get_value(rec);
+ struct server_id_buf tmp;
struct notify_db_entry *entries;
size_t i, num_entries;
time_t now;
- DEBUG(10, ("del_entry called for %s %p\n", procid_str_static(pid),
- private_data));
+ DEBUG(10, ("del_entry called for %s %p\n",
+ server_id_str_buf(*pid, &tmp), private_data));
if ((value.dsize % sizeof(struct notify_db_entry)) != 0) {
DEBUG(1, ("Invalid value.dsize = %u\n",
@@ -777,9 +778,10 @@ static void notify_trigger_local(struct notify_context *notify,
}
if (!procid_is_local(&e->server)) {
+ struct server_id_buf tmp;
DEBUG(1, ("internal error: Non-local pid %s in "
"notify.tdb\n",
- procid_str_static(&e->server)));
+ server_id_str_buf(e->server, &tmp)));
continue;
}
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 773b146..ca674b4 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -1251,9 +1251,10 @@ NTSTATUS send_break_message(struct messaging_context *msg_ctx,
{
NTSTATUS status;
char msg[MSG_SMB_SHARE_MODE_ENTRY_SIZE];
+ struct server_id_buf tmp;
DEBUG(10, ("Sending break request to PID %s\n",
- procid_str_static(&exclusive->pid)));
+ server_id_str_buf(exclusive->pid, &tmp)));
/* Create the message. */
share_mode_entry_to_message(msg, exclusive);
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 6921719..33f6201 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -155,10 +155,11 @@ static void msg_inject_fault(struct messaging_context *msg,
DATA_BLOB *data)
{
int sig;
+ struct server_id_buf tmp;
if (data->length != sizeof(sig)) {
DEBUG(0, ("Process %s sent bogus signal injection request\n",
- procid_str_static(&src)));
+ server_id_str_buf(src, &tmp)));
return;
}
@@ -170,10 +171,10 @@ static void msg_inject_fault(struct messaging_context *msg,
#if HAVE_STRSIGNAL
DEBUG(0, ("Process %s requested injection of signal %d (%s)\n",
- procid_str_static(&src), sig, strsignal(sig)));
+ server_id_str_buf(src, &tmp), sig, strsignal(sig)));
#else
DEBUG(0, ("Process %s requested injection of signal %d\n",
- procid_str_static(&src), sig));
+ server_id_str_buf(src, &tmp), sig));
#endif
kill(getpid(), sig);
diff --git a/source3/utils/net_status.c b/source3/utils/net_status.c
index be24fec..9dbb1a4 100644
--- a/source3/utils/net_status.c
+++ b/source3/utils/net_status.c
@@ -34,6 +34,7 @@ int net_status_usage(struct net_context *c, int argc, const char **argv)
static int show_session(const char *key, struct sessionid *session,
void *private_data)
{
+ struct server_id_buf tmp;
bool *parseable = (bool *)private_data;
if (!process_exists(session->pid)) {
@@ -42,13 +43,13 @@ static int show_session(const char *key, struct sessionid *session,
if (*parseable) {
d_printf("%s\\%s\\%s\\%s\\%s\n",
- procid_str_static(&session->pid),
+ server_id_str_buf(session->pid, &tmp),
uidtoname(session->uid),
gidtoname(session->gid),
session->remote_machine, session->hostname);
} else {
d_printf("%7s %-12s %-12s %-12s (%s)\n",
- procid_str_static(&session->pid),
+ server_id_str_buf(session->pid, &tmp),
uidtoname(session->uid),
gidtoname(session->gid),
session->remote_machine, session->hostname);
@@ -95,6 +96,8 @@ static int show_share(const struct connections_key *key,
const struct connections_data *crec,
void *state)
{
+ struct server_id_buf tmp;
+
if (crec->cnum == TID_FIELD_INVALID)
return 0;
@@ -103,7 +106,7 @@ static int show_share(const struct connections_key *key,
}
d_printf("%-10.10s %s %-12s %s",
- crec->servicename, procid_str_static(&crec->pid),
+ crec->servicename, server_id_str_buf(crec->pid, &tmp),
crec->machine,
time_to_asc(crec->start));
@@ -139,6 +142,7 @@ static int show_share_parseable(const struct connections_key *key,
void *state)
{
struct sessionids *ids = (struct sessionids *)state;
+ struct server_id_buf tmp;
int i;
bool guest = true;
@@ -158,7 +162,7 @@ static int show_share_parseable(const struct connections_key *key,
}
d_printf("%s\\%s\\%s\\%s\\%s\\%s\\%s",
- crec->servicename,procid_str_static(&crec->pid),
+ crec->servicename, server_id_str_buf(crec->pid, &tmp),
guest ? "" : uidtoname(ids->entries[i].uid),
guest ? "" : gidtoname(ids->entries[i].gid),
crec->machine,
diff --git a/source3/utils/status.c b/source3/utils/status.c
index 80aa18e..33ca728 100644
--- a/source3/utils/status.c
+++ b/source3/utils/status.c
@@ -137,7 +137,8 @@ static int print_share_mode(const struct share_mode_entry *e,
}
if (Ucrit_checkPid(e->pid)) {
- d_printf("%-11s ",procid_str_static(&e->pid));
+ struct server_id_buf tmp;
+ d_printf("%-11s ", server_id_str_buf(e->pid, &tmp));
d_printf("%-9u ", (unsigned int)e->uid);
switch (map_share_mode_to_deny_mode(e->share_access,
e->private_options)) {
@@ -218,6 +219,7 @@ static void print_brl(struct file_id id,
const char *sharepath = "";
char *fname = NULL;
struct share_mode_lock *share_mode;
+ struct server_id_buf tmp;
if (count==0) {
d_printf("Byte range locks:\n");
@@ -250,7 +252,7 @@ static void print_brl(struct file_id id,
}
d_printf("%-10s %-15s %-4s %-9jd %-9jd %-24s %-24s\n",
- procid_str_static(&pid), file_id_string_tos(&id),
+ server_id_str_buf(pid, &tmp), file_id_string_tos(&id),
desc,
(intmax_t)start, (intmax_t)size,
sharepath, fname);
@@ -263,6 +265,8 @@ static int traverse_connections(const struct connections_key *key,
const struct connections_data *crec,
void *state)
{
+ struct server_id_buf tmp;
+
if (crec->cnum == TID_FIELD_INVALID)
return 0;
@@ -272,7 +276,7 @@ static int traverse_connections(const struct connections_key *key,
}
d_printf("%-10s %s %-12s %s",
- crec->servicename,procid_str_static(&crec->pid),
+ crec->servicename, server_id_str_buf(crec->pid, &tmp),
crec->machine,
time_to_asc(crec->start));
@@ -283,6 +287,7 @@ static int traverse_sessionid(const char *key, struct sessionid *session,
void *private_data)
{
fstring uid_str, gid_str;
+ struct server_id_buf tmp;
if (do_checks &&
(!process_exists(session->pid) ||
@@ -313,7 +318,7 @@ static int traverse_sessionid(const char *key, struct sessionid *session,
}
d_printf("%-7s %-12s %-12s %-12s (%s) %-12s\n",
- procid_str_static(&session->pid),
+ server_id_str_buf(session->pid, &tmp),
uid_str, gid_str,
session->remote_machine, session->hostname, session->protocol_ver);
--
1.7.9.5
More information about the samba-technical
mailing list