From 9fa95168d80beba04b333b06edc492ecb8b085a1 Mon Sep 17 00:00:00 2001 From: Pavel Březina Date: Wed, 10 Dec 2014 19:24:58 +0100 Subject: sbus: add new iface via sbus_conn_register_iface() Rename sbus_conn_add_interface() to sbus_conn_register_iface() and remove sbus_new_interface() calls since it is just one more unnecessary call outside the sbus code. The function sbus_new_interface() is made static and used directly in sbus_conn_register_iface(). The name was chosen to better describe what the function is doing. That it registers an interface on a given object path. The same interface can be used with different paths so it is not really about adding an interface. Preparation for: https://fedorahosted.org/sssd/ticket/2339 Reviewed-by: Jakub Hrozek --- src/providers/data_provider_be.c | 10 +--------- src/providers/proxy/proxy_child.c | 8 +------- src/providers/proxy/proxy_init.c | 11 ++--------- 3 files changed, 4 insertions(+), 25 deletions(-) (limited to 'src/providers') diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c index 95df2d9c6..53a0be258 100644 --- a/src/providers/data_provider_be.c +++ b/src/providers/data_provider_be.c @@ -2216,7 +2216,6 @@ static void init_timeout(struct tevent_context *ev, static int be_client_init(struct sbus_connection *conn, void *data) { - struct sbus_interface *intf; struct be_ctx *bectx; struct be_client *becli; struct timeval tv; @@ -2252,14 +2251,7 @@ static int be_client_init(struct sbus_connection *conn, void *data) DEBUG(SSSDBG_CONF_SETTINGS, "Set-up Backend ID timeout [%p]\n", becli->timeout); - /* Attach the client context to the connection context, so that it is - * always available when we need to manage the connection. */ - intf = sbus_new_interface(conn, DP_PATH, &be_methods.vtable, becli); - if (!intf) { - return ENOMEM; - } - - return sbus_conn_add_interface(conn, intf); + return sbus_conn_register_iface(conn, &be_methods.vtable, DP_PATH, becli); } /* be_srv_init diff --git a/src/providers/proxy/proxy_child.c b/src/providers/proxy/proxy_child.c index e261b2f58..9876b9328 100644 --- a/src/providers/proxy/proxy_child.c +++ b/src/providers/proxy/proxy_child.c @@ -381,7 +381,6 @@ int proxy_child_send_id(struct sbus_connection *conn, uint32_t id); static int proxy_cli_init(struct pc_ctx *ctx) { - struct sbus_interface *intf; char *sbus_address; int ret; @@ -399,12 +398,7 @@ static int proxy_cli_init(struct pc_ctx *ctx) return ret; } - intf = sbus_new_interface(ctx, DP_PATH, &pc_methods.vtable, ctx); - if (!intf) { - ret = ENOMEM; - } else { - ret = sbus_conn_add_interface(ctx->conn, intf); - } + ret = sbus_conn_register_iface(ctx->conn, &pc_methods.vtable, DP_PATH, ctx); if (ret != EOK) { DEBUG(SSSDBG_FATAL_FAILURE, "Failed to export proxy.\n"); return ret; diff --git a/src/providers/proxy/proxy_init.c b/src/providers/proxy/proxy_init.c index 1e7345117..f76ad02ae 100644 --- a/src/providers/proxy/proxy_init.c +++ b/src/providers/proxy/proxy_init.c @@ -331,7 +331,6 @@ static int proxy_client_init(struct sbus_connection *conn, void *data) { struct proxy_auth_ctx *proxy_auth_ctx; struct proxy_client *proxy_cli; - struct sbus_interface *intf; struct timeval tv; proxy_auth_ctx = talloc_get_type(data, struct proxy_auth_ctx); @@ -362,14 +361,8 @@ static int proxy_client_init(struct sbus_connection *conn, void *data) DEBUG(SSSDBG_CONF_SETTINGS, "Set-up proxy client ID timeout [%p]\n", proxy_cli->timeout); - /* Attach the client context to the connection context, so that it is - * always available when we need to manage the connection. */ - intf = sbus_new_interface(conn, DP_PATH, &proxy_methods.vtable, proxy_cli); - if (!intf) { - return ENOMEM; - } - - return sbus_conn_add_interface(conn, intf); + return sbus_conn_register_iface(conn, &proxy_methods.vtable, + DP_PATH, proxy_cli); } static void init_timeout(struct tevent_context *ev, -- cgit