From 7b4bb3bb662f024c80520b80f90962c1c474ec12 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
Date: Mon, 5 Jan 2015 13:49:27 +0100
Subject: [PATCH 2/9] sbus: remove unused 'reply as' functions

These functions became unused after previous patch.
---
 src/sbus/sssd_dbus.h            |  22 -----
 src/sbus/sssd_dbus_properties.c | 144 -------------------------------
 src/sbus/sssd_dbus_request.c    | 184 ----------------------------------------
 3 files changed, 350 deletions(-)

diff --git a/src/sbus/sssd_dbus.h b/src/sbus/sssd_dbus.h
index 0f7562e6b5e773e633b7041935a9f25187f1beee..1de06974161009eb67af104805787f3f75fca271 100644
--- a/src/sbus/sssd_dbus.h
+++ b/src/sbus/sssd_dbus.h
@@ -298,28 +298,6 @@ int sbus_request_return_and_finish(struct sbus_request *dbus_req,
                                    int first_arg_type,
                                    ...);
 
-int sbus_add_variant_to_dict(DBusMessageIter *iter_dict,
-                             const char *key,
-                             int type,
-                             const void *value);
-
-int sbus_add_array_as_variant_to_dict(DBusMessageIter *iter_dict,
-                                      const char *key,
-                                      int type,
-                                      uint8_t *values,
-                                      const int len,
-                                      const unsigned int item_size);
-
-int sbus_request_return_as_variant(struct sbus_request *dbus_req,
-                                   int type,
-                                   const void *value);
-
-int sbus_request_return_array_as_variant(struct sbus_request *dbus_req,
-                                         int type,
-                                         uint8_t *values,
-                                         const int len,
-                                         const size_t item_size);
-
 /*
 
  * Return an error for a DBus method call request. The @error is a normal
diff --git a/src/sbus/sssd_dbus_properties.c b/src/sbus/sssd_dbus_properties.c
index 15bc6a93739bdad84cbf4f1a2595bbec11d3f81d..25ea446d16701d2ebd2c034b37728482207a4ddf 100644
--- a/src/sbus/sssd_dbus_properties.c
+++ b/src/sbus/sssd_dbus_properties.c
@@ -339,147 +339,3 @@ static int sbus_properties_get_all(struct sbus_request *sbus_req, void *pvt)
 fail:
     return sbus_request_fail_and_finish(sbus_req, error);
 }
-
-static char *
-type_to_string(char type, char *str)
-{
-    int l;
-
-    l = snprintf(str, 2, "%c", type);
-    if (l != 1) {
-        return NULL;
-    }
-
-    return str;
-}
-
-int sbus_add_variant_to_dict(DBusMessageIter *iter_dict,
-                             const char *key,
-                             int type,
-                             const void *value)
-{
-    DBusMessageIter iter_dict_entry;
-    DBusMessageIter iter_dict_val;
-    dbus_bool_t dbret;
-    char strtype[2];
-
-    type_to_string(type, strtype);
-
-    dbret = dbus_message_iter_open_container(iter_dict,
-                                             DBUS_TYPE_DICT_ENTRY, NULL,
-                                             &iter_dict_entry);
-    if (!dbret) {
-        return ENOMEM;
-    }
-
-    /* Start by appending the key */
-    dbret = dbus_message_iter_append_basic(&iter_dict_entry,
-                                           DBUS_TYPE_STRING, &key);
-    if (!dbret) {
-        return ENOMEM;
-    }
-
-    dbret = dbus_message_iter_open_container(&iter_dict_entry,
-                                             DBUS_TYPE_VARIANT,
-                                             strtype,
-                                             &iter_dict_val);
-    if (!dbret) {
-        return ENOMEM;
-    }
-
-    /* Now add the value */
-    dbret = dbus_message_iter_append_basic(&iter_dict_val, type, value);
-    if (!dbret) {
-        return ENOMEM;
-    }
-
-    dbret = dbus_message_iter_close_container(&iter_dict_entry,
-                                              &iter_dict_val);
-    if (!dbret) {
-        return ENOMEM;
-    }
-
-    dbret = dbus_message_iter_close_container(iter_dict,
-                                              &iter_dict_entry);
-    if (!dbret) {
-        return ENOMEM;
-    }
-
-    return EOK;
-}
-
-int sbus_add_array_as_variant_to_dict(DBusMessageIter *iter_dict,
-                                      const char *key,
-                                      int type,
-                                      uint8_t *values,
-                                      const int len,
-                                      const unsigned int item_size)
-{
-    DBusMessageIter iter_dict_entry;
-    DBusMessageIter iter_variant;
-    DBusMessageIter iter_array;
-    dbus_bool_t dbret;
-    char variant_type[] = {DBUS_TYPE_ARRAY, type, '\0'};
-    char array_type[] = {type, '\0'};
-    void *addr = NULL;
-    int i;
-
-    dbret = dbus_message_iter_open_container(iter_dict,
-                                             DBUS_TYPE_DICT_ENTRY, NULL,
-                                             &iter_dict_entry);
-    if (!dbret) {
-        return ENOMEM;
-    }
-
-    /* Start by appending the key */
-    dbret = dbus_message_iter_append_basic(&iter_dict_entry,
-                                           DBUS_TYPE_STRING, &key);
-    if (!dbret) {
-        return ENOMEM;
-    }
-
-    dbret = dbus_message_iter_open_container(&iter_dict_entry,
-                                             DBUS_TYPE_VARIANT,
-                                             variant_type,
-                                             &iter_variant);
-    if (!dbret) {
-        return ENOMEM;
-    }
-
-    dbret = dbus_message_iter_open_container(&iter_variant,
-                                             DBUS_TYPE_ARRAY,
-                                             array_type,
-                                             &iter_array);
-    if (!dbret) {
-        return ENOMEM;
-    }
-
-    /* Now add the value */
-    for (i = 0; i < len; i++) {
-        addr = values + i * item_size;
-        dbret = dbus_message_iter_append_basic(&iter_array, type, addr);
-        if (!dbret) {
-            return ENOMEM;
-        }
-    }
-
-    dbret = dbus_message_iter_close_container(&iter_variant,
-                                              &iter_array);
-    if (!dbret) {
-        return ENOMEM;
-    }
-
-    dbret = dbus_message_iter_close_container(&iter_dict_entry,
-                                              &iter_variant);
-    if (!dbret) {
-        return ENOMEM;
-    }
-
-    dbret = dbus_message_iter_close_container(iter_dict,
-                                              &iter_dict_entry);
-    if (!dbret) {
-        return ENOMEM;
-    }
-
-    return EOK;
-}
diff --git a/src/sbus/sssd_dbus_request.c b/src/sbus/sssd_dbus_request.c
index 7362f4b7949e9ddc84856e74e352651b0aa90f8b..6a012f1c669bb093b6934b13d9f4688c178d1dc2 100644
--- a/src/sbus/sssd_dbus_request.c
+++ b/src/sbus/sssd_dbus_request.c
@@ -129,190 +129,6 @@ int sbus_request_return_and_finish(struct sbus_request *dbus_req,
     return ret;
 }
 
-int sbus_request_return_as_variant(struct sbus_request *dbus_req,
-                                   int type,
-                                   const void *value)
-{
-    DBusMessage *reply;
-    dbus_bool_t dbret;
-    DBusMessageIter iter;
-    DBusMessageIter valiter;
-    char strtype[2];
-    int ret;
-
-    snprintf(strtype, 2, "%c", type);
-
-    reply = dbus_message_new_method_return(dbus_req->message);
-    if (reply == NULL) {
-        DEBUG(SSSDBG_CRIT_FAILURE, "Out of memory allocating DBus message\n");
-        sbus_request_finish(dbus_req, NULL);
-        return ENOMEM;
-    }
-
-    dbus_message_iter_init_append(reply, &iter);
-    dbret = dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
-                                             strtype, &valiter);
-    if (!dbret) {
-        sbus_request_fail_and_finish(
-                            dbus_req,
-                            sbus_error_new(dbus_req,
-                                        DBUS_ERROR_FAILED,
-                                        "Could not open variant for [%s]\n",
-                                        strtype));
-        ret = EINVAL;
-        goto done;
-    }
-
-    dbret = dbus_message_iter_append_basic(&valiter, type, value);
-    if (!dbret) {
-        sbus_request_fail_and_finish(
-                            dbus_req,
-                            sbus_error_new(dbus_req,
-                                        DBUS_ERROR_FAILED,
-                                        "Could not append [%s] to variant\n",
-                                        strtype));
-        ret = EINVAL;
-        goto done;
-    }
-
-    dbret = dbus_message_iter_close_container(&iter, &valiter);
-    if (dbret) {
-        ret = sbus_request_finish(dbus_req, reply);
-    } else {
-        sbus_request_fail_and_finish(
-                            dbus_req,
-                            sbus_error_new(dbus_req,
-                                        DBUS_ERROR_FAILED,
-                                        "Could not close variant\n"));
-        ret = EINVAL;
-    }
-
-done:
-    dbus_message_unref(reply);
-    return ret;
-}
-
-
-int sbus_request_return_array_as_variant(struct sbus_request *dbus_req,
-                                         int type,
-                                         uint8_t *values,
-                                         const int len,
-                                         const size_t item_size)
-{
-    TALLOC_CTX *tmp_ctx = NULL;
-    DBusMessage *reply = NULL;
-    dbus_bool_t dbret;
-    DBusMessageIter iter;
-    DBusMessageIter variant_iter;
-    DBusMessageIter array_iter;
-    char *variant_type = NULL;
-    char *array_type = NULL;
-    void *addr = NULL;
-    int ret;
-    int i;
-
-    tmp_ctx = talloc_new(NULL);
-    if (tmp_ctx == NULL) {
-        return ENOMEM;
-    }
-
-    variant_type = talloc_asprintf(tmp_ctx, DBUS_TYPE_ARRAY_AS_STRING "%c",
-                                   type);
-    if (variant_type == NULL) {
-        ret = ENOMEM;
-        goto done;
-    }
-
-    array_type = talloc_asprintf(tmp_ctx, "%c", type);
-    if (array_type == NULL) {
-        ret = ENOMEM;
-        goto done;
-    }
-
-    reply = dbus_message_new_method_return(dbus_req->message);
-    if (reply == NULL) {
-        DEBUG(SSSDBG_CRIT_FAILURE, "Out of memory allocating DBus message\n");
-        sbus_request_finish(dbus_req, NULL);
-        ret = ENOMEM;
-        goto done;
-    }
-
-    dbus_message_iter_init_append(reply, &iter);
-    dbret = dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
-                                             variant_type, &variant_iter);
-    if (!dbret) {
-        sbus_request_fail_and_finish(
-                            dbus_req,
-                            sbus_error_new(dbus_req,
-                                        DBUS_ERROR_FAILED,
-                                        "Could not open variant for [%s]\n",
-                                        variant_type));
-        ret = EINVAL;
-        goto done;
-    }
-
-    /* Open container for values */
-    dbret = dbus_message_iter_open_container(&variant_iter, DBUS_TYPE_ARRAY,
-                                             array_type, &array_iter);
-    if (!dbret) {
-        sbus_request_fail_and_finish(
-                            dbus_req,
-                            sbus_error_new(dbus_req,
-                                        DBUS_ERROR_FAILED,
-                                        "Could not open array for [%s]\n",
-                                        array_type));
-        ret = EINVAL;
-        goto done;
-    }
-
-    for (i = 0; i < len; i++) {
-        addr = values + i * item_size;
-        dbret = dbus_message_iter_append_basic(&array_iter, type, addr);
-        if (!dbret) {
-            sbus_request_fail_and_finish(
-                                dbus_req,
-                                sbus_error_new(dbus_req,
-                                            DBUS_ERROR_FAILED,
-                                            "Could not append [%s] to variant\n",
-                                            array_type));
-            ret = EINVAL;
-            goto done;
-        }
-    }
-
-    dbret = dbus_message_iter_close_container(&variant_iter, &array_iter);
-    if (!dbret) {
-        sbus_request_fail_and_finish(
-                            dbus_req,
-                            sbus_error_new(dbus_req,
-                                        DBUS_ERROR_FAILED,
-                                        "Could not close array\n"));
-        ret = EINVAL;
-        goto done;
-    }
-
-    dbret = dbus_message_iter_close_container(&iter, &variant_iter);
-    if (dbret) {
-        ret = sbus_request_finish(dbus_req, reply);
-    } else {
-        sbus_request_fail_and_finish(
-                            dbus_req,
-                            sbus_error_new(dbus_req,
-                                        DBUS_ERROR_FAILED,
-                                        "Could not close variant\n"));
-        ret = EINVAL;
-        goto done;
-    }
-
-done:
-    if (reply != NULL) {
-        dbus_message_unref(reply);
-    }
-
-    talloc_free(tmp_ctx);
-    return ret;
-}
-
 int sbus_request_fail_and_finish(struct sbus_request *dbus_req,
                                  const DBusError *error)
 {
-- 
1.7.11.7

