[PATCH libdrm 05/12] xf86drm: rename drmSameDevice to drmCompareBusInfo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Move away form the boolean name, change the return value
appropriately and check if either argument is NULL.

Signed-off-by: Emil Velikov <emil.l.velikov@xxxxxxxxx>
---
 xf86drm.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/xf86drm.c b/xf86drm.c
index dc1782d..310d1e8 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -2893,20 +2893,22 @@ static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
     return 0;
 }
 
-static int drmSameDevice(drmDevicePtr a, drmDevicePtr b)
+static int drmCompareBusInfo(drmDevicePtr a, drmDevicePtr b)
 {
+    if (a == NULL || b == NULL)
+        return -1;
+
     if (a->bustype != b->bustype)
-        return 0;
+        return -1;
 
     switch (a->bustype) {
     case DRM_BUS_PCI:
-        if (memcmp(a->businfo.pci, b->businfo.pci, sizeof(drmPciBusInfo)) == 0)
-            return 1;
+        return memcmp(a->businfo.pci, b->businfo.pci, sizeof(drmPciBusInfo));
     default:
         break;
     }
 
-    return 0;
+    return -1;
 }
 
 static int drmGetNodeType(const char *name)
@@ -3104,7 +3106,7 @@ int drmGetDevices(drmDevicePtr devices[], int max_devices)
         for (j = i+1; j < node_count; j++) {
             if (duplicated[i] || duplicated[j])
                 continue;
-            if (drmSameDevice(&devs[i], &devs[j])) {
+            if (drmCompareBusInfo(&devs[i], &devs[j]) == 0) {
                 duplicated[j] = 1;
                 devs[i].available_nodes |= devs[j].available_nodes;
                 node_type = log2(devs[j].available_nodes);
-- 
2.5.0

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux