lib: Remove procid_str_static
authorVolker Lendecke <vl@samba.org>
Thu, 23 Apr 2015 16:06:17 +0000 (18:06 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 28 Apr 2015 16:11:13 +0000 (18:11 +0200)
Replace all callers with direct calls to server_id_str_buf without
talloc_tos()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/util/debug_s3.c
source3/include/proto.h
source3/lib/dbwrap/dbwrap_watch.c
source3/lib/util.c
source3/locking/brlock.c
source3/locking/locking.c
source3/smbd/notify_internal.c
source3/smbd/open.c
source3/smbd/server.c
source3/utils/net_status.c
source3/utils/status.c

index 160e2ef230f67ca3a76366c97f95b6faa38eb44d..d9ac15f66052e37212e0cef0f18a927af7a64fc6 100644 (file)
@@ -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);
 
index 30fd4fa3f12dff509b553522298a756030c2ee02..f73778fc5bced0fda15f72f21d56a190131d63ac 100644 (file)
@@ -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);
index c0571d967c1fa1b45b9a492cf9e2e8fc9ded94ed..da1a9cc11e91e762952185e2657c783b308fe3aa 100644 (file)
@@ -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:
index e296fd5e0f9f87585237094a630b80b37080df27..c7ab0ee91227330480af0d4d1e3c7d732eae08a8 100644 (file)
@@ -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);
index 46401a021865a0365b6404de767e8b5da1de049c..5dee91c96c446e393b3b7e461f9fc919e4ca7ea1 100644 (file)
@@ -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);
index ce595e12d0d2f1d8bee02b3ee610102c06cdd173..67eff8f0ee0c730000c6fad57c860d9d7a6c6cab 100644 (file)
@@ -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;
index e612f163da9edd34929f73aad01f72cb2b54daff..845a7cc8f7f69c835887272fb9571a6302589dda 100644 (file)
@@ -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;
                }
 
index 773b146cd68fd31bb06a0372548691d845ea9ac0..ca674b4b03080d24fede4a6a9ff6b262cde22b68 100644 (file)
@@ -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);
index 6921719fb25c5a8376f1287522d56bf61af6bca2..33f6201125cc45bb333f278325602f70dcdb2a2a 100644 (file)
@@ -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);
index be24fec5732607392ad5465ac9e3949091c92b9a..9dbb1a45847401e3dce97d8a2c947dac8a685859 100644 (file)
@@ -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,
index 80aa18e103754d3e6ff46dbc81d5025a37ca2c35..33ca728cf50ebce1236064970ca57d0aae191275 100644 (file)
@@ -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);