devices: change dev_head to global 68/265468/2
authorYoungjae Cho <y0.cho@samsung.com>
Wed, 20 Oct 2021 06:29:14 +0000 (15:29 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Wed, 20 Oct 2021 06:45:44 +0000 (15:45 +0900)
Sorting dev_head, which is returned by get_device_list_head(),
changes the dev_head. But it is not applied to the original dev_head
in shared/devices.c. Therefore the original dev_head is not the head
of the list anymore. To avoid it, make dev_head global so that result
of list operation can be applied to the original dev_head.

Change-Id: I2e6ee2b3ea0ad91cb6de44c5e9f6e2d718eb727c
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/core/devices.c
src/dump/dump.c
src/shared/devices.c
src/shared/devices.h

index a3f9c3c..0dd4e15 100644 (file)
@@ -20,8 +20,6 @@
 #include <shared/devices.h>
 #include <shared/log.h>
 
-static GList *dev_head;
-
 static GVariant *dbus_device_list(GDBusConnection *conn,
        const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
        GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
@@ -62,7 +60,6 @@ void devices_init(void *data)
        const struct device_ops *dev;
        int ret;
 
-       dev_head = get_device_list_head();
        dev_head = g_list_sort(dev_head, compare_priority);
 
        SYS_G_LIST_FOREACH_SAFE(dev_head, elem, elem_n, dev) {
index a074940..980fdd1 100644 (file)
@@ -50,7 +50,6 @@ static void send_dump_signal(char *signal)
 
 static void dump_all_devices(int mode, char *path)
 {
-       GList *head = get_device_list_head();
        GList *elem;
        FILE *fp = NULL;
        char fname[PATH_MAX];
@@ -68,7 +67,7 @@ static void dump_all_devices(int mode, char *path)
                _I("Failed to open '%s', print to DLOG.", fname);
 
        /* save dump each device ops */
-       SYS_G_LIST_FOREACH(head, elem, dev) {
+       SYS_G_LIST_FOREACH(dev_head, elem, dev) {
                if (dev->dump) {
                        _D("[%s] Get dump.", dev->name);
                        LOG_DUMP(fp, "\n==== %s\n\n", dev->name);
index 66c1c9f..950c1d7 100644 (file)
@@ -27,12 +27,7 @@ static const struct device_ops default_ops = {
     DECLARE_NAME_LEN("default-ops"),
 };
 
-static GList *dev_head;
-
-GList *get_device_list_head(void)
-{
-       return dev_head;
-}
+GList *dev_head;
 
 void add_device(const struct device_ops *dev)
 {
index a7d4469..d42c490 100644 (file)
@@ -129,7 +129,7 @@ static void __DESTRUCTOR__ module_exit(void)        \
        remove_device(dev);     \
 }
 
-GList *get_device_list_head(void);
+extern GList *dev_head;
 void add_device(const struct device_ops *dev);
 void remove_device(const struct device_ops *dev);