Improve variable naming style 31/255031/5
authortaemin.yeom <taemin.yeom@samsung.com>
Thu, 11 Mar 2021 09:17:04 +0000 (18:17 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Mon, 15 Mar 2021 08:22:52 +0000 (08:22 +0000)
Change-Id: I5236467f2efbc7768f49028b09e0a758967fd979
Signed-off-by: taemin.yeom <taemin.yeom@samsung.com>
src/libgdbus/libgdbus.c
src/libgdbus/libgdbus.h
src/libsystemd/libsystemd.c

index 499a449..3679337 100644 (file)
@@ -998,21 +998,21 @@ static void _method_call_handler(GDBusConnection *conn,
 {
        dbus_interface_s *iface_s = (dbus_interface_s *)user_data;
        const dbus_method_s *methods;
-       GVariant *result = NULL;
+       GVariant *reply = NULL;
 
        /* todo: ghash ? */
        methods = _dbus_handle_lookup_method(iface_s->list_methods, name);
        if (methods) {
-               result = methods->func(conn, sender, path, iface, name, param, invocation, get_dh_from_oh(iface_s->oh));
+               reply = methods->func(conn, sender, path, iface, name, param, invocation, get_dh_from_oh(iface_s->oh));
 
                /* async, maybe they will reply...maybe.. */
-               if (!result)
+               if (!reply)
                        return;
        } else {
                _E("no methods");
        }
 
-       g_dbus_method_invocation_return_value(invocation, result);
+       g_dbus_method_invocation_return_value(invocation, reply);
 }
 
 static GDBusInterfaceVTable path_vtable = {_method_call_handler};
@@ -1356,7 +1356,7 @@ int dbus_handle_register_dbus_object_all(dbus_handle_h handle)
        dcl_dbus_handle();
        dbus_object_handle_s *oh = NULL;
        dbus_interface_s *ih = NULL;
-       int ret = 0;
+       int ret_dbus = 0;
 
        if (!dh) {
                dh = _dbus_handle_get_default_connection();
@@ -1405,9 +1405,9 @@ int dbus_handle_register_dbus_object_all(dbus_handle_h handle)
                        if (ih && ih->list_methods)
                                _D("method list len %d", g_list_length(ih->list_methods));*/
 
-                       ret = _dbus_handle_register_dbus_object(dh, oh->path, ih);
-                       if (ret <= 0)
-                               _E("failed to register dbus object%d", ret);
+                       ret_dbus = _dbus_handle_register_dbus_object(dh, oh->path, ih);
+                       if (ret_dbus <= 0)
+                               _E("failed to register dbus object%d", ret_dbus);
 
                }
        }
@@ -1753,11 +1753,11 @@ int dbus_handle_method_sync_with_reply_var(const char *dest,
                                                const char *iface,
                                                const char *method,
                                                GVariant *param,
-                                               GVariant **reply)
+                                               GVariant **out_reply)
 {
        GError *err = NULL;
-       GVariant *ret = NULL;
-       int err_val = 0;
+       GVariant *reply = NULL;
+       int ret = 0;
        dbus_handle_s *dh = NULL;
 
        if (!dest || !path || !iface || !method) {
@@ -1775,41 +1775,41 @@ int dbus_handle_method_sync_with_reply_var(const char *dest,
                return -ECOMM;
        }
 
-       ret = g_dbus_connection_call_sync(dh->conn,
+       reply = g_dbus_connection_call_sync(dh->conn,
                        dest, path, iface, method,
                        param, NULL,
                        G_DBUS_CALL_FLAGS_NONE,
                        DBUS_REPLY_TIMEOUT,
                        NULL,
                        &err);
-       if (!ret || err) {
+       if (!reply || err) {
                if (err) {
                        _E("failed to g_dbus_connection_call_sync:%s", err->message);
                        if (g_error_matches(err, G_DBUS_ERROR, G_DBUS_ERROR_ACCESS_DENIED))
-                               err_val = -EPERM;
+                               ret = -EPERM;
                        else
-                               err_val = -ECOMM;
+                               ret = -ECOMM;
                        g_error_free(err);
-                       return err_val;
+                       return ret;
                } else {
                        _E("failed to g_dbus_connection_call_sync");
                }
                return -ECOMM;
        }
 
-       if(reply)
-               *reply = ret;
+       if(out_reply)
+               *out_reply = reply;
        else
-               g_variant_unref(ret);
+               g_variant_unref(reply);
 
-       return err_val;
+       return ret;
 }
 
 int dbus_handle_method_sync_with_reply_var_timeout(const char *dest, const char *path,
-       const char *iface, const char *method, GVariant *param, GVariant **reply, int timeout)
+       const char *iface, const char *method, GVariant *param, GVariant **out_reply, int timeout)
 {
        GError *err = NULL;
-       GVariant *ret;
+       GVariant *reply;
        dbus_handle_s *dh = NULL;
 
        if (!dest || !path || !iface || !method) {
@@ -1827,14 +1827,14 @@ int dbus_handle_method_sync_with_reply_var_timeout(const char *dest, const char
                return -ECOMM;
        }
 
-       ret = g_dbus_connection_call_sync(dh->conn,
+       reply = g_dbus_connection_call_sync(dh->conn,
                                        dest, path, iface, method,
                                        param, NULL,
                                        G_DBUS_CALL_FLAGS_NONE,
                                        timeout,
                                        NULL,
                                        &err);
-       if (!ret || err) {
+       if (!reply || err) {
                if (err) {
                        _E("failed to g_dbus_connection_call_sync:%s", err->message);
                        g_error_free(err);
@@ -1844,10 +1844,10 @@ int dbus_handle_method_sync_with_reply_var_timeout(const char *dest, const char
                return -ECOMM;
        }
 
-       if(reply)
-               *reply = ret;
+       if(out_reply)
+               *out_reply = reply;
        else
-               g_variant_unref(ret);
+               g_variant_unref(reply);
 
        return 0;
 }
@@ -1860,7 +1860,7 @@ int dbus_handle_method_sync_pairs(const char *dest,
                                        va_list args)
 {
        GError *err = NULL;
-       GVariant * reply = NULL;
+       GVariant *reply = NULL;
        char *key, *value;
        int ret = 0;
        GVariant *var;
@@ -1984,14 +1984,14 @@ int dbus_handle_method_with_unix_fd_list_sync_with_reply_var(const char *dest,
                                                                const char *iface,
                                                                const char *method,
                                                                GVariant *param,
-                                                               GVariant **reply,
+                                                               GVariant **out_reply,
                                                                int *in_fdlist,
                                                                int in_size,
                                                                int **out_fdlist,
                                                                int *out_size)
 {
-       int err_val = 0;
-       GVariant *ret = NULL;
+       int ret = 0;
+       GVariant *reply = NULL;
        GError *err = NULL;
        dbus_handle_s *dh = NULL;
        GUnixFDList *g_infdlist = NULL;
@@ -2017,7 +2017,7 @@ int dbus_handle_method_with_unix_fd_list_sync_with_reply_var(const char *dest,
                g_infdlist = g_unix_fd_list_new_from_array(in_fdlist, in_size);
                if (!g_infdlist) {
                        _E("failed to g_unix_fd_list_new_from_array\n");
-                       err_val = -EAGAIN;
+                       ret = -EAGAIN;
                        goto out;
                }
                //g_infdlist = g_unix_fd_list_new();
@@ -2025,14 +2025,14 @@ int dbus_handle_method_with_unix_fd_list_sync_with_reply_var(const char *dest,
        }
 
        /* send message */
-       ret = g_dbus_connection_call_with_unix_fd_list_sync(dh->conn,
+       reply = g_dbus_connection_call_with_unix_fd_list_sync(dh->conn,
                dest, path, iface, method,
                param, NULL,
                G_DBUS_CALL_FLAGS_NONE,
                -1,
                g_infdlist, &g_outfdlist,
                NULL, &err);
-       if (!ret || err) {
+       if (!reply || err) {
                if (err) {
                        _E("failed to g_dbus_connection_call_with_unix_fd_list_sync:%s", err->message);
                        g_error_free(err);
@@ -2043,14 +2043,14 @@ int dbus_handle_method_with_unix_fd_list_sync_with_reply_var(const char *dest,
                        if (g_infdlist)
                                g_object_unref(g_infdlist);
                }
-               err_val = -EAGAIN;
+               ret = -EAGAIN;
                goto out;
        }
 
-       if(reply)
-               *reply = ret;
+       if(out_reply)
+               *out_reply = reply;
        else
-               g_variant_unref(ret);
+               g_variant_unref(reply);
 
        /* copy fds to out array */
        if (g_outfdlist) {
@@ -2062,7 +2062,7 @@ int dbus_handle_method_with_unix_fd_list_sync_with_reply_var(const char *dest,
 out:
        if (g_outfdlist)
                g_object_unref(g_outfdlist);
-       return err_val;
+       return ret;
 }
 
 int dbus_handle_method_sync_var(const char *dest,
@@ -2296,7 +2296,7 @@ err:
 int dbus_connection_get_sender_pid(GDBusConnection *conn, const char * sender)
 {
        GError *err = NULL;
-       GVariant *vret = NULL;
+       GVariant *reply = NULL;
        pid_t pid = 0;
 
        if (!conn) {
@@ -2308,21 +2308,21 @@ int dbus_connection_get_sender_pid(GDBusConnection *conn, const char * sender)
                return -1;
        }
 
-       vret = g_dbus_connection_call_sync(conn,
+       reply = g_dbus_connection_call_sync(conn,
                        "org.freedesktop.DBus", "/", "org.freedesktop.DBus", "GetConnectionUnixProcessID",
                        g_variant_new("(s)", sender), NULL,
                        G_DBUS_CALL_FLAGS_NONE,
                        DBUS_REPLY_TIMEOUT,
                        NULL,
                        &err);
-       if (!vret || err) {
+       if (!reply || err) {
                _E("failed to g_dbus_connection_call_sync:%s", err->message);
                g_error_free(err);
                return -1;
        }
 
-       g_variant_get(vret, "(u)", &pid);
-       g_variant_unref(vret);
+       g_variant_get(reply, "(u)", &pid);
+       g_variant_unref(reply);
 
        return pid;
 }
@@ -2350,7 +2350,7 @@ int dbus_handle_get_sender_pid(dbus_handle_h handle, const char * sender)
 int dbus_handle_get_sender_credentials(dbus_handle_h handle, const char *name, GDBusCredentials *creds)
 {
        dcl_dbus_handle();
-       GVariant *vret = NULL;
+       GVariant *reply = NULL;
        GError *err = NULL;
        GVariantIter *iter = NULL;
        char * item;
@@ -2363,7 +2363,7 @@ int dbus_handle_get_sender_credentials(dbus_handle_h handle, const char *name, G
                        return -1;
                }
        }
-       vret = g_dbus_connection_call_sync(dh->conn,
+       reply = g_dbus_connection_call_sync(dh->conn,
                                        DBUS_BUS_NAME,
                                        DBUS_OBJECT_PATH,
                                        DBUS_INTERFACE_NAME,
@@ -2374,12 +2374,12 @@ int dbus_handle_get_sender_credentials(dbus_handle_h handle, const char *name, G
                                        DBUS_REPLY_TIMEOUT,
                                        NULL,
                                        &err);
-       if (!vret || err) {
+       if (!reply || err) {
                _E("failed to g_dbus_connection_call_sync:%s", err->message);
                return -1;
        }
 
-       g_variant_get(vret, "(a{sv})", &iter);
+       g_variant_get(reply, "(a{sv})", &iter);
 
        while (g_variant_iter_loop(iter, "{sv}", &item, &sub)) {
                if (!g_strcmp0(item, "UnixUserID")) {
@@ -2396,8 +2396,8 @@ int dbus_handle_get_sender_credentials(dbus_handle_h handle, const char *name, G
 
        if (iter)
                g_variant_iter_free(iter);
-       if (vret)
-               g_variant_unref(vret);
+       if (reply)
+               g_variant_unref(reply);
 
        return 0;
 }
@@ -2451,7 +2451,7 @@ void dbus_handle_unwatch_name(guint id)
 
 int _get_cmdline_name(pid_t pid, char *cmdline, size_t cmdline_size)
 {
-       int fd, ret;
+       int fd, ret_file;
        char buf[PATH_MAX + 1];
        char *filename;
 
@@ -2462,9 +2462,9 @@ int _get_cmdline_name(pid_t pid, char *cmdline, size_t cmdline_size)
                return -1;
        }
 
-       ret = read(fd, buf, PATH_MAX);
+       ret_file = read(fd, buf, PATH_MAX);
        close(fd);
-       if (ret < 0)
+       if (ret_file < 0)
                return -1;
 
        buf[PATH_MAX] = '\0';
@@ -2490,7 +2490,7 @@ char **dbus_handle_get_owner_list(dbus_handle_h handle, const char *bus_name)
 {
        dcl_dbus_handle();
        GError *err = NULL;
-       GVariant *vret = NULL;
+       GVariant *reply = NULL;
        GVariantIter *iter = NULL;
        gchar **strv = NULL;
        gchar *str = NULL;
@@ -2509,7 +2509,7 @@ char **dbus_handle_get_owner_list(dbus_handle_h handle, const char *bus_name)
                }
        }
 
-       vret = g_dbus_connection_call_sync(dh->conn,
+       reply = g_dbus_connection_call_sync(dh->conn,
                                        "org.freedesktop.DBus",
                                        "/",
                                        "org.freedesktop.DBus",
@@ -2520,13 +2520,13 @@ char **dbus_handle_get_owner_list(dbus_handle_h handle, const char *bus_name)
                                        DBUS_REPLY_TIMEOUT,
                                        NULL,
                                        &err);
-       if (!vret || err) {
+       if (!reply || err) {
                _E("failed to g_dbus_connection_call_sync:%s", err->message);
                g_error_free(err);
                return NULL;
        }
 
-       g_variant_get(vret, "(as)", &iter);
+       g_variant_get(reply, "(as)", &iter);
        strv = g_new(gchar *, g_variant_iter_n_children(iter) + 1);
 
        i = 0;
@@ -2535,7 +2535,7 @@ char **dbus_handle_get_owner_list(dbus_handle_h handle, const char *bus_name)
        strv[i] = NULL;
 
        g_variant_iter_free(iter);
-       g_variant_unref(vret);
+       g_variant_unref(reply);
 
        return strv;
 }
@@ -2575,7 +2575,7 @@ void dbus_handle_check_owner_name(dbus_handle_h handle, const char *owner_name)
 int check_systemd_active(void)
 {
        int ret = FALSE;
-       GVariant *msg = NULL;
+       GVariant *reply = NULL;
        GVariant *var = NULL;
        char *state;
 
@@ -2586,13 +2586,13 @@ int check_systemd_active(void)
                        "org.freedesktop.DBus.Properties",
                        "Get",
                        g_variant_new("(ss)", "org.freedesktop.systemd1.Unit", "ActiveState"),
-                       &msg);
+                       &reply);
        if (ret < 0)
                return ret;
-       if (!msg)
+       if (!reply)
                return -EBADMSG;
 
-       if (!g_variant_get_safe(msg, "(v)", &var)) {
+       if (!g_variant_get_safe(reply, "(v)", &var)) {
                _E("reply is not variant type");
                ret = -EBADMSG;
                goto out;
@@ -2610,8 +2610,8 @@ int check_systemd_active(void)
 out:
        if (var)
                g_variant_unref(var);
-       if (msg)
-               g_variant_unref(msg);
+       if (reply)
+               g_variant_unref(reply);
 
        return ret;
 }
index 91fb1f3..0e26bb8 100644 (file)
@@ -127,14 +127,14 @@ int dbus_handle_method_sync_with_reply_var                (const char *dest,
                                                                const char *iface,
                                                                const char *method,
                                                                GVariant *param,
-                                                               GVariant **reply);
+                                                               GVariant **out_reply);
 
 int dbus_handle_method_sync_with_reply_var_timeout     (const char *dest,
                                                                const char *path,
                                                                const char *iface,
                                                                const char *method,
                                                                GVariant *param,
-                                                               GVariant **reply,
+                                                               GVariant **out_reply,
                                                                int timeout);
 
 int dbus_handle_method_sync_pairs              (const char *dest,
@@ -169,7 +169,7 @@ int dbus_handle_method_with_unix_fd_list_sync_with_reply_var(const char *dest,
                                                                const char *iface,
                                                                const char *method,
                                                                GVariant *param,
-                                                               GVariant **reply,
+                                                               GVariant **out_reply,
                                                                int *in_fdlist,
                                                                int in_size,
                                                                int **out_fdlist,
index a463118..a045616 100644 (file)
@@ -411,18 +411,18 @@ GVariant *systemd_get_manager_property(const char *property)
 {
        GVariant *reply = NULL;
        GVariant *val = NULL;
-       int ret = 0;
+       int ret_dbus = 0;
 
        if (!property)
                return NULL;
 
-       ret = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
+       ret_dbus = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
                                                        SYSTEMD_DBUS_PATH,
                                                        DBUS_IFACE_DBUS_PROPERTIES,
                                                        "Get",
                                                        g_variant_new("(ss)", SYSTEMD_DBUS_MANAGER_IFACE, property),
                                                        &reply);
-       if (!reply || !g_variant_get_safe(reply, "(v)", &val) || ret < 0)
+       if (ret_dbus < 0 || !g_variant_get_safe(reply, "(v)", &val))
                _E("Failed to get variant");
        if (reply)
                g_variant_unref(reply);
@@ -435,21 +435,21 @@ GVariant *systemd_get_unit_property(const char *unit, const char *property)
        char *escaped;
        GVariant *reply = NULL;
        GVariant *val = NULL;
-       int ret = 0;
+       int ret_dbus = 0;
 
        if (!unit || !property)
                return NULL;
 
        escaped = systemd_get_unit_dbus_path(unit);
 
-       ret = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
+       ret_dbus = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
                                                        escaped,
                                                        DBUS_IFACE_DBUS_PROPERTIES,
                                                        "Get",
                                                        g_variant_new("(ss)", SYSTEMD_DBUS_UNIT_IFACE, property),
                                                        &reply);
 
-       if (!reply || !g_variant_get_safe(reply, "(v)", &val) || ret < 0)
+       if (ret_dbus < 0 || !g_variant_get_safe(reply, "(v)", &val))
                _E("Failed to get variant");
        if (reply)
                g_variant_unref(reply);
@@ -463,20 +463,20 @@ GVariant *systemd_get_service_property(const char *unit, const char *property)
        char *escaped;
        GVariant *reply = NULL;
        GVariant *val = NULL;
-       int ret = 0;
+       int ret_dbus = 0;
 
        if (!unit || !property)
                return NULL;
 
        escaped = systemd_get_unit_dbus_path(unit);
 
-       ret = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
+       ret_dbus = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
                                                        escaped,
                                                        DBUS_IFACE_DBUS_PROPERTIES,
                                                        "Get",
                                                        g_variant_new("(ss)", SYSTEMD_DBUS_SERVICE_IFACE, property),
                                                        &reply);
-       if (!reply || !g_variant_get_safe(reply, "(v)", &val) || ret < 0)
+       if (ret_dbus < 0 || !g_variant_get_safe(reply, "(v)", &val))
                _E("Failed to get variant");
        if (reply)
                g_variant_unref(reply);