From f3f2dfc51a25080290e13ed1d1f8c85932e0be31 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 31 Jan 2009 23:57:02 +0100 Subject: s4:lib/messaging: avoid c++ reserved word 'private' metze --- source4/lib/messaging/irpc.h | 14 ++++++------- source4/lib/messaging/messaging.c | 40 +++++++++++++++++++------------------- source4/lib/messaging/tests/irpc.c | 4 ++-- 3 files changed, 29 insertions(+), 29 deletions(-) (limited to 'source4/lib/messaging') diff --git a/source4/lib/messaging/irpc.h b/source4/lib/messaging/irpc.h index fa91a147c6..9be8461f6a 100644 --- a/source4/lib/messaging/irpc.h +++ b/source4/lib/messaging/irpc.h @@ -48,10 +48,10 @@ struct irpc_message { typedef NTSTATUS (*irpc_function_t)(struct irpc_message *, void *r); /* register a server function with the irpc messaging system */ -#define IRPC_REGISTER(msg_ctx, pipename, funcname, function, private) \ +#define IRPC_REGISTER(msg_ctx, pipename, funcname, function, private_data) \ irpc_register(msg_ctx, &ndr_table_ ## pipename, \ NDR_ ## funcname, \ - (irpc_function_t)function, private) + (irpc_function_t)function, private_data) /* make a irpc call */ #define IRPC_CALL(msg_ctx, server_id, pipename, funcname, ptr, ctx) \ @@ -82,16 +82,16 @@ struct irpc_request { struct loadparm_context; -typedef void (*msg_callback_t)(struct messaging_context *msg, void *private, +typedef void (*msg_callback_t)(struct messaging_context *msg, void *private_data, uint32_t msg_type, struct server_id server_id, DATA_BLOB *data); NTSTATUS messaging_send(struct messaging_context *msg, struct server_id server, uint32_t msg_type, DATA_BLOB *data); -NTSTATUS messaging_register(struct messaging_context *msg, void *private, +NTSTATUS messaging_register(struct messaging_context *msg, void *private_data, uint32_t msg_type, msg_callback_t fn); -NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private, +NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private_data, msg_callback_t fn, uint32_t *msg_type); struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx, const char *dir, @@ -104,14 +104,14 @@ struct messaging_context *messaging_client_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev); NTSTATUS messaging_send_ptr(struct messaging_context *msg, struct server_id server, uint32_t msg_type, void *ptr); -void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void *private); +void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void *private_data); NTSTATUS irpc_register(struct messaging_context *msg_ctx, const struct ndr_interface_table *table, - int call, irpc_function_t fn, void *private); + int call, irpc_function_t fn, void *private_data); struct irpc_request *irpc_call_send(struct messaging_context *msg_ctx, struct server_id server_id, const struct ndr_interface_table *table, diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c index decad7b5a8..c27f977cce 100644 --- a/source4/lib/messaging/messaging.c +++ b/source4/lib/messaging/messaging.c @@ -64,7 +64,7 @@ struct messaging_context { struct dispatch_fn { struct dispatch_fn *next, *prev; uint32_t msg_type; - void *private; + void *private_data; msg_callback_t fn; }; @@ -94,7 +94,7 @@ static void irpc_handler(struct messaging_context *, void *, /* A useful function for testing the message system. */ -static void ping_message(struct messaging_context *msg, void *private, +static void ping_message(struct messaging_context *msg, void *private_data, uint32_t msg_type, struct server_id src, DATA_BLOB *data) { DEBUG(1,("INFO: Received PING message from server %u.%u [%.*s]\n", @@ -149,7 +149,7 @@ static void messaging_dispatch(struct messaging_context *msg, struct messaging_r next = d->next; data.data = rec->packet.data + sizeof(*rec->header); data.length = rec->header->length; - d->fn(msg, d->private, d->msg_type, rec->header->from, &data); + d->fn(msg, d->private_data, d->msg_type, rec->header->from, &data); } rec->header->length = 0; } @@ -217,9 +217,9 @@ static NTSTATUS try_send(struct messaging_rec *rec) retry backed off messages */ static void msg_retry_timer(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct messaging_context *msg = talloc_get_type(private, + struct messaging_context *msg = talloc_get_type(private_data, struct messaging_context); msg->retry_te = NULL; @@ -339,9 +339,9 @@ static void messaging_recv_handler(struct messaging_context *msg) handle a socket event */ static void messaging_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct messaging_context *msg = talloc_get_type(private, + struct messaging_context *msg = talloc_get_type(private_data, struct messaging_context); if (flags & EVENT_FD_WRITE) { messaging_send_handler(msg); @@ -355,7 +355,7 @@ static void messaging_handler(struct tevent_context *ev, struct tevent_fd *fde, /* Register a dispatch function for a particular message type. */ -NTSTATUS messaging_register(struct messaging_context *msg, void *private, +NTSTATUS messaging_register(struct messaging_context *msg, void *private_data, uint32_t msg_type, msg_callback_t fn) { struct dispatch_fn *d; @@ -376,7 +376,7 @@ NTSTATUS messaging_register(struct messaging_context *msg, void *private, d = talloc_zero(msg->dispatch, struct dispatch_fn); NT_STATUS_HAVE_NO_MEMORY(d); d->msg_type = msg_type; - d->private = private; + d->private_data = private_data; d->fn = fn; DLIST_ADD(msg->dispatch[msg_type], d); @@ -388,7 +388,7 @@ NTSTATUS messaging_register(struct messaging_context *msg, void *private, register a temporary message handler. The msg_type is allocated above MSG_TMP_BASE */ -NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private, +NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private_data, msg_callback_t fn, uint32_t *msg_type) { struct dispatch_fn *d; @@ -396,7 +396,7 @@ NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private, d = talloc_zero(msg->dispatch, struct dispatch_fn); NT_STATUS_HAVE_NO_MEMORY(d); - d->private = private; + d->private_data = private_data; d->fn = fn; id = idr_get_new_above(msg->dispatch_tree, d, MSG_TMP_BASE, UINT16_MAX); @@ -414,7 +414,7 @@ NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private, /* De-register the function for a particular message type. */ -void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void *private) +void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void *private_data) { struct dispatch_fn *d, *next; @@ -429,7 +429,7 @@ void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void for (d = msg->dispatch[msg_type]; d; d = next) { next = d->next; - if (d->private == private) { + if (d->private_data == private_data) { DLIST_REMOVE(msg->dispatch[msg_type], d); talloc_free(d); } @@ -631,7 +631,7 @@ struct irpc_list { const struct ndr_interface_table *table; int callnum; irpc_function_t fn; - void *private; + void *private_data; }; @@ -640,7 +640,7 @@ struct irpc_list { */ NTSTATUS irpc_register(struct messaging_context *msg_ctx, const struct ndr_interface_table *table, - int callnum, irpc_function_t fn, void *private) + int callnum, irpc_function_t fn, void *private_data) { struct irpc_list *irpc; @@ -659,7 +659,7 @@ NTSTATUS irpc_register(struct messaging_context *msg_ctx, irpc->table = table; irpc->callnum = callnum; irpc->fn = fn; - irpc->private = private; + irpc->private_data = private_data; irpc->uuid = irpc->table->syntax_id.uuid; return NT_STATUS_OK; @@ -768,7 +768,7 @@ static void irpc_handler_request(struct messaging_context *msg_ctx, if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) goto failed; /* make the call */ - m->private = i->private; + m->private = i->private_data; m->defer_reply = false; m->msg_ctx = msg_ctx; m->irpc = i; @@ -793,7 +793,7 @@ failed: /* handle an incoming irpc message */ -static void irpc_handler(struct messaging_context *msg_ctx, void *private, +static void irpc_handler(struct messaging_context *msg_ctx, void *private_data, uint32_t msg_type, struct server_id src, DATA_BLOB *packet) { struct irpc_message *m; @@ -844,9 +844,9 @@ static int irpc_destructor(struct irpc_request *irpc) timeout a irpc request */ static void irpc_timeout(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct irpc_request *irpc = talloc_get_type(private, struct irpc_request); + struct irpc_request *irpc = talloc_get_type(private_data, struct irpc_request); irpc->status = NT_STATUS_IO_TIMEOUT; irpc->done = true; if (irpc->async.fn) { diff --git a/source4/lib/messaging/tests/irpc.c b/source4/lib/messaging/tests/irpc.c index d45bcb6bf7..5d49438c5c 100644 --- a/source4/lib/messaging/tests/irpc.c +++ b/source4/lib/messaging/tests/irpc.c @@ -54,9 +54,9 @@ static NTSTATUS irpc_AddOne(struct irpc_message *irpc, struct echo_AddOne *r) a deferred reply to echodata */ static void deferred_echodata(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct irpc_message *irpc = talloc_get_type(private, struct irpc_message); + struct irpc_message *irpc = talloc_get_type(private_data, struct irpc_message); struct echo_EchoData *r = irpc->data; r->out.out_data = talloc_memdup(r, r->in.in_data, r->in.len); if (r->out.out_data == NULL) { -- cgit From 96f176dbd84090fd18b8c796f869ddaa2da39e59 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 1 Feb 2009 00:02:17 +0100 Subject: s4:lib/messaging: fix warnings in testsuite metze --- source4/lib/messaging/tests/irpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/messaging') diff --git a/source4/lib/messaging/tests/irpc.c b/source4/lib/messaging/tests/irpc.c index 5d49438c5c..42a811d116 100644 --- a/source4/lib/messaging/tests/irpc.c +++ b/source4/lib/messaging/tests/irpc.c @@ -87,7 +87,7 @@ static bool test_addone(struct torture_context *test, const void *_data, struct echo_AddOne r; NTSTATUS status; const struct irpc_test_data *data = (const struct irpc_test_data *)_data; - uint32_t value = (uint32_t)_value; + uint32_t value = *(const uint32_t *)_value; /* make the call */ r.in.in_data = value; @@ -261,7 +261,7 @@ struct torture_suite *torture_local_irpc(TALLOC_CTX *mem_ctx) for (i = 0; i < 5; i++) { torture_tcase_add_test_const(tcase, "addone", test_addone, - (void *)values[i]); + (void *)&values[i]); } torture_tcase_add_test_const(tcase, "echodata", test_echodata, NULL); -- cgit From 5f13710ced2565355c3cdcef04067cacdf74a9ad Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 1 Feb 2009 00:03:47 +0100 Subject: s4:irpc: avoid c++ reserved word 'private' metze --- source4/lib/messaging/irpc.h | 4 ++-- source4/lib/messaging/messaging.c | 4 ++-- source4/lib/messaging/tests/irpc.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'source4/lib/messaging') diff --git a/source4/lib/messaging/irpc.h b/source4/lib/messaging/irpc.h index 9be8461f6a..3c518828ab 100644 --- a/source4/lib/messaging/irpc.h +++ b/source4/lib/messaging/irpc.h @@ -30,7 +30,7 @@ */ struct irpc_message { struct server_id from; - void *private; + void *private_data; struct irpc_header header; struct ndr_pull *ndr; bool defer_reply; @@ -76,7 +76,7 @@ struct irpc_request { TALLOC_CTX *mem_ctx; struct { void (*fn)(struct irpc_request *); - void *private; + void *private_data; } async; }; diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c index c27f977cce..cfceeffac7 100644 --- a/source4/lib/messaging/messaging.c +++ b/source4/lib/messaging/messaging.c @@ -109,7 +109,7 @@ static void ping_message(struct messaging_context *msg, void *private_data, static NTSTATUS irpc_uptime(struct irpc_message *msg, struct irpc_uptime *r) { - struct messaging_context *ctx = talloc_get_type(msg->private, struct messaging_context); + struct messaging_context *ctx = talloc_get_type(msg->private_data, struct messaging_context); *r->out.start_time = timeval_to_nttime(&ctx->start_time); return NT_STATUS_OK; } @@ -768,7 +768,7 @@ static void irpc_handler_request(struct messaging_context *msg_ctx, if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) goto failed; /* make the call */ - m->private = i->private_data; + m->private_data= i->private_data; m->defer_reply = false; m->msg_ctx = msg_ctx; m->irpc = i; diff --git a/source4/lib/messaging/tests/irpc.c b/source4/lib/messaging/tests/irpc.c index 42a811d116..3eb23e0f7d 100644 --- a/source4/lib/messaging/tests/irpc.c +++ b/source4/lib/messaging/tests/irpc.c @@ -145,7 +145,7 @@ static bool test_echodata(struct torture_context *tctx, static void irpc_callback(struct irpc_request *irpc) { struct echo_AddOne *r = (struct echo_AddOne *)irpc->r; - int *pong_count = (int *)irpc->async.private; + int *pong_count = (int *)irpc->async.private_data; NTSTATUS status = irpc_call_recv(irpc); if (!NT_STATUS_IS_OK(status)) { printf("irpc call failed - %s\n", nt_errstr(status)); @@ -186,7 +186,7 @@ static bool test_speed(struct torture_context *tctx, torture_assert(tctx, irpc != NULL, "AddOne send failed"); irpc->async.fn = irpc_callback; - irpc->async.private = &pong_count; + irpc->async.private_data = &pong_count; ping_count++; -- cgit From 735af62105c563f9ee2ffd8bc21e914499d5ee76 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:20:52 +0100 Subject: s4:lib/messaging: s/private/private_data metze --- source4/lib/messaging/pymessaging.c | 4 ++-- source4/lib/messaging/tests/messaging.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source4/lib/messaging') diff --git a/source4/lib/messaging/pymessaging.c b/source4/lib/messaging/pymessaging.c index 535da4526c..96981895b6 100644 --- a/source4/lib/messaging/pymessaging.c +++ b/source4/lib/messaging/pymessaging.c @@ -159,11 +159,11 @@ static PyObject *py_messaging_send(PyObject *self, PyObject *args, PyObject *kwa Py_RETURN_NONE; } -static void py_msg_callback_wrapper(struct messaging_context *msg, void *private, +static void py_msg_callback_wrapper(struct messaging_context *msg, void *private_data, uint32_t msg_type, struct server_id server_id, DATA_BLOB *data) { - PyObject *callback = (PyObject *)private; + PyObject *callback = (PyObject *)private_data; PyObject_CallFunction(callback, discard_const_p(char, "i(iii)s#"), msg_type, server_id.id, server_id.id2, server_id.node, diff --git a/source4/lib/messaging/tests/messaging.c b/source4/lib/messaging/tests/messaging.c index 838de55d83..f61132caac 100644 --- a/source4/lib/messaging/tests/messaging.c +++ b/source4/lib/messaging/tests/messaging.c @@ -29,7 +29,7 @@ static uint32_t msg_pong; -static void ping_message(struct messaging_context *msg, void *private, +static void ping_message(struct messaging_context *msg, void *private_data, uint32_t msg_type, struct server_id src, DATA_BLOB *data) { NTSTATUS status; @@ -39,17 +39,17 @@ static void ping_message(struct messaging_context *msg, void *private, } } -static void pong_message(struct messaging_context *msg, void *private, +static void pong_message(struct messaging_context *msg, void *private_data, uint32_t msg_type, struct server_id src, DATA_BLOB *data) { - int *count = private; + int *count = (int *)private_data; (*count)++; } -static void exit_message(struct messaging_context *msg, void *private, +static void exit_message(struct messaging_context *msg, void *private_data, uint32_t msg_type, struct server_id src, DATA_BLOB *data) { - talloc_free(private); + talloc_free(private_data); exit(0); } -- cgit