ecore-drm: Remove need to use an extra variable for storing device.
authorChris Michael <cp.michael@samsung.com>
Wed, 24 Sep 2014 13:06:47 +0000 (09:06 -0400)
committerChris Michael <cp.michael@samsung.com>
Wed, 24 Sep 2014 13:06:47 +0000 (09:06 -0400)
Summary: This commit just modifies the internal code to remove the
need for an extra variable. There really is no need to store the
device twice. We already have it in the list of returned devices.

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
src/lib/ecore_drm/ecore_drm_device.c

index 4b7c4e3..2f7495d 100644 (file)
@@ -153,7 +153,7 @@ ecore_drm_device_find(const char *name, const char *seat)
    Ecore_Drm_Device *dev = NULL;
    Eina_Bool found = EINA_FALSE;
    Eina_List *devs, *l;
-   const char *device, *tmpdevice;
+   const char *device;
 
    /* try to get a list of drm devics */
    if (!(devs = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRM, name)))
@@ -200,26 +200,19 @@ ecore_drm_device_find(const char *name, const char *seat)
 
 cont:
         eina_stringshare_del(devpath);
-        if (found) 
-          {
-             tmpdevice = eina_stringshare_add(device);
-             break;
-          }
+        if (found) break;
      }
 
-   EINA_LIST_FREE(devs, device)
-     eina_stringshare_del(device);
-
-   if (!found) return NULL;
+   if (!found) goto out;
 
    if ((dev = calloc(1, sizeof(Ecore_Drm_Device))))
      {
-        dev->drm.name = eeze_udev_syspath_get_devpath(tmpdevice);
-        dev->drm.path = eina_stringshare_add(tmpdevice);
+        dev->drm.name = eeze_udev_syspath_get_devpath(device);
+        dev->drm.path = eina_stringshare_add(device);
 
-        dev->id = eeze_udev_syspath_get_sysnum(tmpdevice);
+        dev->id = eeze_udev_syspath_get_sysnum(device);
 
-        dev->seat = eeze_udev_syspath_get_property(tmpdevice, "ID_SEAT");
+        dev->seat = eeze_udev_syspath_get_property(device, "ID_SEAT");
         if (!dev->seat) dev->seat = eina_stringshare_add("seat0");
 
         dev->format = 0;
@@ -228,7 +221,9 @@ cont:
         DBG("Using Drm Device: %s", dev->drm.name);
      }
 
-   eina_stringshare_del(tmpdevice);
+out:
+   EINA_LIST_FREE(devs, device)
+     eina_stringshare_del(device);
 
    return dev;
 }