st/egl/drm: only unref the udev device if needed
authorTobias Droste <tdroste@gmx.de>
Thu, 29 Nov 2012 16:02:28 +0000 (17:02 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 11 Dec 2012 17:53:58 +0000 (12:53 -0500)
Fixes compiler warning:

drm/native_drm.c: In function ‘native_create_display’:
drm/native_drm.c:180:21: warning: ‘device’ may be used uninitialized in this function [-Wmaybe-uninitialized]
drm/native_drm.c:157:24: note: ‘device’ was declared here

Signed-off-by: Tobias Droste <tdroste@gmx.de>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
src/gallium/state_trackers/egl/drm/native_drm.c

index 23fc137b834a073139000b50bd58e5e2fdd44801..f0c0f5487774949717b33bc2424ee16cbea40824 100644 (file)
@@ -161,23 +161,24 @@ drm_get_device_name(int fd)
    udev = udev_new();
    if (fstat(fd, &buf) < 0) {
       _eglLog(_EGL_WARNING, "failed to stat fd %d", fd);
-      goto out;
+      goto outudev;
    }
 
    device = udev_device_new_from_devnum(udev, 'c', buf.st_rdev);
    if (device == NULL) {
       _eglLog(_EGL_WARNING,
               "could not create udev device for fd %d", fd);
-      goto out;
+      goto outdevice;
    }
 
    tmp = udev_device_get_devnode(device);
    if (!tmp)
-      goto out;
+      goto outdevice;
    device_name = strdup(tmp);
 
-out:
+outdevice:
    udev_device_unref(device);
+outudev:
    udev_unref(udev);
 
 #endif