1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

r15854: more talloc_set_destructor() typesafe fixes

This commit is contained in:
Andrew Tridgell 2006-05-24 07:34:11 +00:00 committed by Gerald (Jerry) Carter
parent 6b4c085b86
commit 61c6100617
29 changed files with 50 additions and 104 deletions

View File

@ -35,9 +35,8 @@
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*/
static int oop_event_context_destructor(void *ptr)
static int oop_event_context_destructor(struct event_context *ev)
{
struct event_context *ev = talloc_get_type(ptr, struct event_context);
oop_source_sys *oop_sys = ev->additional_data;
oop_sys_delete(oop_sys);
@ -91,9 +90,8 @@ static void *oop_event_fd_handler(oop_source *oop, int fd, oop_event oop_type, v
/*
destroy an fd_event
*/
static int oop_event_fd_destructor(void *ptr)
static int oop_event_fd_destructor(struct fd_event *fde)
{
struct fd_event *fde = talloc_get_type(ptr, struct fd_event);
struct event_context *ev = fde->event_ctx;
oop_source_sys *oop_sys = ev->additional_data;
oop_source *oop = oop_sys_source(oop_sys);
@ -174,8 +172,9 @@ static void oop_event_set_fd_flags(struct fd_event *fde, uint16_t flags)
fde->flags = flags;
}
static int oop_event_timed_destructor(void *ptr);
static int oop_event_timed_deny_destructor(void *ptr)
static int oop_event_timed_destructor(struct timed_event *te);
static int oop_event_timed_deny_destructor(struct timed_event *te)
{
return -1;
}
@ -197,9 +196,8 @@ static void *oop_event_timed_handler(oop_source *oop, struct timeval t, void *pt
/*
destroy a timed event
*/
static int oop_event_timed_destructor(void *ptr)
static int oop_event_timed_destructor(struct timed_event *te)
{
struct timed_event *te = talloc_get_type(ptr, struct timed_event);
struct event_context *ev = te->event_ctx;
oop_source_sys *oop_sys = ev->additional_data;
oop_source *oop = oop_sys_source(oop_sys);

View File

@ -93,10 +93,8 @@ static uint32_t epoll_map_flags(uint16_t flags)
/*
free the epoll fd
*/
static int epoll_ctx_destructor(void *ptr)
static int epoll_ctx_destructor(struct std_event_context *std_ev)
{
struct std_event_context *std_ev = talloc_get_type(ptr,
struct std_event_context);
close(std_ev->epoll_fd);
std_ev->epoll_fd = -1;
return 0;
@ -336,9 +334,8 @@ static void calc_maxfd(struct std_event_context *std_ev)
/*
destroy an fd_event
*/
static int std_event_fd_destructor(void *ptr)
static int std_event_fd_destructor(struct fd_event *fde)
{
struct fd_event *fde = talloc_get_type(ptr, struct fd_event);
struct event_context *ev = fde->event_ctx;
struct std_event_context *std_ev = talloc_get_type(ev->additional_data,
struct std_event_context);
@ -420,16 +417,15 @@ static void std_event_set_fd_flags(struct fd_event *fde, uint16_t flags)
/*
destroy a timed event
*/
static int std_event_timed_destructor(void *ptr)
static int std_event_timed_destructor(struct timed_event *te)
{
struct timed_event *te = talloc_get_type(ptr, struct timed_event);
struct std_event_context *std_ev = talloc_get_type(te->event_ctx->additional_data,
struct std_event_context);
DLIST_REMOVE(std_ev->timed_events, te);
return 0;
}
static int std_event_timed_deny_destructor(void *ptr)
static int std_event_timed_deny_destructor(struct timed_event *te)
{
return -1;
}

View File

@ -1042,9 +1042,8 @@ static const struct ldb_module_ops lldb_ops = {
};
static int lldb_destructor(void *p)
static int lldb_destructor(struct lldb_private *lldb)
{
struct lldb_private *lldb = p;
ldap_unbind(lldb->ldap);
return 0;
}

View File

@ -1963,11 +1963,8 @@ failed:
return -1;
}
static int
destructor(void *p)
{
struct lsqlite3_private *lsqlite3 = p;
static int destructor(struct lsqlite3_private *lsqlite3)
{
if (lsqlite3->sqlite) {
sqlite3_close(lsqlite3->sqlite);
}

View File

@ -43,9 +43,8 @@ struct ltdb_wrap {
static struct ltdb_wrap *tdb_list;
/* destroy the last connection to a tdb */
static int ltdb_wrap_destructor(void *ctx)
static int ltdb_wrap_destructor(struct ltdb_wrap *w)
{
struct ltdb_wrap *w = talloc_get_type(ctx, struct ltdb_wrap);
tdb_close(w->tdb);
if (w->next) {
w->next->prev = w->prev;

View File

@ -71,10 +71,8 @@ struct private_data {
};
int store_destructor(void *data)
int store_destructor(struct results_store *store)
{
struct results_store *store = talloc_get_type(data, struct results_store);
if (store->prev) {
store->prev->next = store->next;
}

View File

@ -87,9 +87,8 @@ static int skel_del_trans(struct ldb_module *module)
return ldb_next_del_trans(module);
}
static int skel_destructor(void *module_ctx)
static int skel_destructor(struct ldb_module *ctx)
{
struct ldb_module *ctx = talloc_get_type(module_ctx, struct ldb_module);
struct private_data *data = talloc_get_type(ctx->private_data, struct private_data);
/* put your clean-up functions here */
if (data->some_private_data) talloc_free(data->some_private_data);

View File

@ -434,9 +434,8 @@ NTSTATUS messaging_send_ptr(struct messaging_context *msg, uint32_t server,
/*
destroy the messaging context
*/
static int messaging_destructor(void *ptr)
static int messaging_destructor(struct messaging_context *msg)
{
struct messaging_context *msg = ptr;
unlink(msg->path);
while (msg->names && msg->names[0]) {
irpc_remove_name(msg, msg->names[0]);
@ -720,9 +719,8 @@ failed:
/*
destroy a irpc request
*/
static int irpc_destructor(void *ptr)
static int irpc_destructor(struct irpc_request *irpc)
{
struct irpc_request *irpc = talloc_get_type(ptr, struct irpc_request);
idr_remove(irpc->msg_ctx->idr, irpc->callid);
return 0;
}

View File

@ -32,9 +32,8 @@ struct ldb_key_data
int subkey_count, value_count;
};
static int ldb_free_hive (void *_hive)
static int ldb_free_hive (struct registry_hive *hive)
{
struct registry_hive *hive = _hive;
talloc_free(hive->backend_data);
hive->backend_data = NULL;
return 0;
@ -96,9 +95,8 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx, TALLOC_CT
}
static int reg_close_ldb_key (void *data)
static int reg_close_ldb_key(struct registry_key *key)
{
struct registry_key *key = data;
struct ldb_key_data *kd = talloc_get_type(key->backend_data, struct ldb_key_data);
/* struct ldb_context *c = key->hive->backend_data; */

View File

@ -28,9 +28,8 @@
/*
auto-close sockets on free
*/
static int socket_destructor(void *ptr)
static int socket_destructor(struct socket_context *sock)
{
struct socket_context *sock = ptr;
if (sock->ops->fn_close) {
sock->ops->fn_close(sock);
}

View File

@ -60,10 +60,8 @@ struct packet_context {
a destructor used when we are processing packets to prevent freeing of this
context while it is being used
*/
static int packet_destructor(void *p)
static int packet_destructor(struct packet_context *pc)
{
struct packet_context *pc = talloc_get_type(p, struct packet_context);
if (pc->busy) {
pc->destructor_called = True;
/* now we refuse the talloc_free() request. The free will

View File

@ -175,9 +175,8 @@ static ssize_t tls_push(gnutls_transport_ptr ptr, const void *buf, size_t size)
/*
destroy a tls session
*/
static int tls_destructor(void *ptr)
static int tls_destructor(struct tls_context *tls)
{
struct tls_context *tls = talloc_get_type(ptr, struct tls_context);
int ret;
ret = gnutls_bye(tls->session, GNUTLS_SHUT_WR);
if (ret < 0) {

View File

@ -49,9 +49,8 @@ struct saved_state {
uid_t uid;
};
static int privileges_destructor(void *ptr)
static int privileges_destructor(struct saved_state *s)
{
struct saved_state *s = ptr;
if (geteuid() != s->uid &&
seteuid(s->uid) != 0) {
smb_panic("Failed to restore privileges");

View File

@ -44,9 +44,8 @@
/*
destroy a pending request
*/
static int cldap_request_destructor(void *ptr)
static int cldap_request_destructor(struct cldap_request *req)
{
struct cldap_request *req = talloc_get_type(ptr, struct cldap_request);
if (req->state == CLDAP_REQUEST_SEND) {
DLIST_REMOVE(req->cldap->send_queue, req);
}

View File

@ -41,11 +41,8 @@
/*
destroy a mailslot handler
*/
static int dgram_mailslot_destructor(void *ptr)
static int dgram_mailslot_destructor(struct dgram_mailslot_handler *dgmslot)
{
struct dgram_mailslot_handler *dgmslot =
talloc_get_type(ptr, struct dgram_mailslot_handler);
DLIST_REMOVE(dgmslot->dgmsock->mailslot_handlers, dgmslot);
return 0;
}

View File

@ -487,9 +487,8 @@ static void ldap_reconnect(struct ldap_connection *conn)
}
/* destroy an open ldap request */
static int ldap_request_destructor(void *ptr)
static int ldap_request_destructor(struct ldap_request *req)
{
struct ldap_request *req = talloc_get_type(ptr, struct ldap_request);
if (req->state == LDAP_REQUEST_PENDING) {
DLIST_REMOVE(req->conn->pending, req);
}

View File

@ -32,10 +32,8 @@
/*
destroy a pending request
*/
static int nbt_name_request_destructor(void *ptr)
{
struct nbt_name_request *req = talloc_get_type(ptr, struct nbt_name_request);
static int nbt_name_request_destructor(struct nbt_name_request *req)
{
if (req->state == NBT_REQUEST_SEND) {
DLIST_REMOVE(req->nbtsock->send_queue, req);
}

View File

@ -50,10 +50,8 @@ static void smbcli_transport_event_handler(struct event_context *ev,
/*
destroy a transport
*/
static int transport_destructor(void *ptr)
static int transport_destructor(struct smbcli_transport *transport)
{
struct smbcli_transport *transport = ptr;
smbcli_transport_dead(transport);
return 0;
}
@ -538,9 +536,8 @@ static void smbcli_timeout_handler(struct event_context *ev, struct timed_event
/*
destroy a request
*/
static int smbcli_request_destructor(void *ptr)
static int smbcli_request_destructor(struct smbcli_request *req)
{
struct smbcli_request *req = talloc_get_type(ptr, struct smbcli_request);
if (req->state == SMBCLI_REQUEST_RECV) {
DLIST_REMOVE(req->transport->pending_recv, req);
}

View File

@ -51,9 +51,8 @@ struct host_state {
name resolution without leaving a potentially blocking call running
in a child
*/
static int host_destructor(void *ptr)
static int host_destructor(struct host_state *state)
{
struct host_state *state = talloc_get_type(ptr, struct host_state);
close(state->child_fd);
if (state->child != (pid_t)-1) {
kill(state->child, SIGTERM);

View File

@ -51,9 +51,8 @@ static void smb2_transport_event_handler(struct event_context *ev,
/*
destroy a transport
*/
static int transport_destructor(void *ptr)
static int transport_destructor(struct smb2_transport *transport)
{
struct smb2_transport *transport = ptr;
smb2_transport_dead(transport);
return 0;
}
@ -254,9 +253,8 @@ static void smb2_timeout_handler(struct event_context *ev, struct timed_event *t
/*
destroy a request
*/
static int smb2_request_destructor(void *ptr)
static int smb2_request_destructor(struct smb2_request *req)
{
struct smb2_request *req = talloc_get_type(ptr, struct smb2_request);
if (req->state == SMB2_REQUEST_RECV) {
DLIST_REMOVE(req->transport->pending_recv, req);
}

View File

@ -144,9 +144,8 @@ static void wrepl_error(void *private, NTSTATUS status)
/*
destroy a wrepl_socket destructor
*/
static int wrepl_socket_destructor(void *ptr)
static int wrepl_socket_destructor(struct wrepl_socket *sock)
{
struct wrepl_socket *sock = talloc_get_type(ptr, struct wrepl_socket);
if (sock->dead) {
sock->free_skipped = True;
return -1;
@ -244,9 +243,8 @@ failed:
/*
destroy a wrepl_request
*/
static int wrepl_request_destructor(void *ptr)
static int wrepl_request_destructor(struct wrepl_request *req)
{
struct wrepl_request *req = talloc_get_type(ptr, struct wrepl_request);
if (req->state == WREPL_REQUEST_RECV) {
DLIST_REMOVE(req->wrepl_socket->recv_queue, req);
}
@ -431,9 +429,8 @@ struct wrepl_send_ctrl_state {
struct wrepl_socket *wrepl_sock;
};
static int wrepl_send_ctrl_destructor(void *ptr)
static int wrepl_send_ctrl_destructor(struct wrepl_send_ctrl_state *s)
{
struct wrepl_send_ctrl_state *s = talloc_get_type(ptr, struct wrepl_send_ctrl_state);
struct wrepl_request *req = s->wrepl_sock->recv_queue;
/* check if the request is still in WREPL_STATE_RECV,

View File

@ -40,9 +40,8 @@ NTSTATUS dcerpc_init(void)
static void dcerpc_ship_next_request(struct dcerpc_connection *c);
/* destroy a dcerpc connection */
static int dcerpc_connection_destructor(void *ptr)
static int dcerpc_connection_destructor(struct dcerpc_connection *c)
{
struct dcerpc_connection *c = ptr;
if (c->transport.shutdown_pipe) {
c->transport.shutdown_pipe(c);
}
@ -918,9 +917,8 @@ req_done:
/*
make sure requests are cleaned up
*/
static int dcerpc_req_destructor(void *ptr)
static int dcerpc_req_destructor(struct rpc_request *req)
{
struct rpc_request *req = ptr;
DLIST_REMOVE(req->p->conn->pending, req);
return 0;
}

View File

@ -237,9 +237,8 @@ static NTSTATUS cvfs_disconnect(struct ntvfs_module_context *ntvfs)
/*
destroy an async info structure
*/
static int async_info_destructor(void *p)
static int async_info_destructor(struct async_info *async)
{
struct async_info *async = talloc_get_type(p, struct async_info);
DLIST_REMOVE(async->cvfs->pending, async);
return 0;
}

View File

@ -63,9 +63,8 @@ static void notify_handler(struct messaging_context *msg_ctx, void *private,
/*
destroy the notify context
*/
static int notify_destructor(void *p)
static int notify_destructor(struct notify_context *notify)
{
struct notify_context *notify = talloc_get_type(p, struct notify_context);
messaging_deregister(notify->messaging_ctx, MSG_PVFS_NOTIFY, notify);
notify_remove_all(notify);
return 0;

View File

@ -100,9 +100,8 @@ _PUBLIC_ struct odb_context *odb_init(TALLOC_CTX *mem_ctx,
/*
destroy a lock on the database
*/
static int odb_lock_destructor(void *ptr)
static int odb_lock_destructor(struct odb_lock *lck)
{
struct odb_lock *lck = ptr;
tdb_chainunlock(lck->odb->w->tdb, lck->key);
return 0;
}

View File

@ -174,9 +174,8 @@ static NTSTATUS ipc_setpathinfo(struct ntvfs_module_context *ntvfs,
/*
destroy a open pipe structure
*/
static int ipc_fd_destructor(void *ptr)
static int ipc_fd_destructor(struct pipe_state *p)
{
struct pipe_state *p = ptr;
DLIST_REMOVE(p->private->pipe_list, p);
return 0;
}

View File

@ -84,9 +84,8 @@ static NTSTATUS pvfs_list_no_wildcard(struct pvfs_state *pvfs, struct pvfs_filen
/*
destroy an open search
*/
static int pvfs_dirlist_destructor(void *ptr)
static int pvfs_dirlist_destructor(struct pvfs_dir *dir)
{
struct pvfs_dir *dir = ptr;
if (dir->dir) closedir(dir->dir);
return 0;
}

View File

@ -117,9 +117,8 @@ static void pvfs_notify_send(struct pvfs_notify_buffer *notify_buffer,
/*
destroy a notify buffer. Called when the handle is closed
*/
static int pvfs_notify_destructor(void *ptr)
static int pvfs_notify_destructor(struct pvfs_notify_buffer *n)
{
struct pvfs_notify_buffer *n = talloc_get_type(ptr, struct pvfs_notify_buffer);
notify_remove(n->f->pvfs->notify_context, n);
n->f->notify_buffer = NULL;
pvfs_notify_send(n, NT_STATUS_OK, True);

View File

@ -54,9 +54,8 @@ struct pvfs_file *pvfs_find_fd(struct pvfs_state *pvfs,
/*
cleanup a open directory handle
*/
static int pvfs_dir_handle_destructor(void *p)
static int pvfs_dir_handle_destructor(struct pvfs_file_handle *h)
{
struct pvfs_file_handle *h = p;
int open_count;
char *path = NULL;
@ -102,10 +101,8 @@ static int pvfs_dir_handle_destructor(void *p)
/*
cleanup a open directory fnum
*/
static int pvfs_dir_fnum_destructor(void *p)
static int pvfs_dir_fnum_destructor(struct pvfs_file *f)
{
struct pvfs_file *f = p;
DLIST_REMOVE(f->pvfs->files.list, f);
ntvfs_handle_remove_backend_data(f->ntvfs, f->pvfs->ntvfs);
@ -412,9 +409,8 @@ cleanup_delete:
/*
destroy a struct pvfs_file_handle
*/
static int pvfs_handle_destructor(void *p)
static int pvfs_handle_destructor(struct pvfs_file_handle *h)
{
struct pvfs_file_handle *h = p;
int open_count;
char *path = NULL;
@ -494,10 +490,8 @@ static int pvfs_handle_destructor(void *p)
/*
destroy a struct pvfs_file
*/
static int pvfs_fnum_destructor(void *p)
static int pvfs_fnum_destructor(struct pvfs_file *f)
{
struct pvfs_file *f = talloc_get_type(p, struct pvfs_file);
DLIST_REMOVE(f->pvfs->files.list, f);
pvfs_lock_close(f->pvfs, f);
ntvfs_handle_remove_backend_data(f->ntvfs, f->pvfs->ntvfs);
@ -768,9 +762,8 @@ struct pvfs_open_retry {
};
/* destroy a pending open request */
static int pvfs_retry_destructor(void *ptr)
static int pvfs_retry_destructor(struct pvfs_open_retry *r)
{
struct pvfs_open_retry *r = ptr;
struct pvfs_state *pvfs = r->ntvfs->private_data;
if (r->odb_locking_key.data) {
struct odb_lock *lck;