From patchwork Wed Sep 9 17:21:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 7147631 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 50254BEEC1 for ; Wed, 9 Sep 2015 17:17:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6FBF120A09 for ; Wed, 9 Sep 2015 17:17:31 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7A21220A06 for ; Wed, 9 Sep 2015 17:17:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A58766EC11; Wed, 9 Sep 2015 10:17:29 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) by gabe.freedesktop.org (Postfix) with ESMTPS id EFFF56EC88 for ; Wed, 9 Sep 2015 10:17:27 -0700 (PDT) Received: by wicge5 with SMTP id ge5so163582345wic.0 for ; Wed, 09 Sep 2015 10:17:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BekfBj7ruIsBjrw9JQAWAU0IJUDXFbxB9fZWfPNFrmk=; b=jMU+v54mYLMbLPpBwc4kRW2nhF2h595dvuocyn/vEmDC9xsRYJHnAoJjmx2CjsNIy5 8G9G5NqpQ2jNF5O8UOXrJhUK0TofnVb2ybZN4urEwaDKqDaGOzDH69JfbdRpw0d5pDly gPRP2DXEhBKqam9P+IM4NKPZ32HJFFEI/0tX/mtxfcxRqvFmF8Q0sVackulhPfbyxGuZ Rzw2pQ0XcTuVMaFRI+kfSuhjD/03JOfCrXmgJie/3iRNCld8Ds8AJcMENqC4We2FRTFl oDipKGD8mMwqqE8P1ocUMevDS+gyfIgncgDUJLq8lkrTJB7Hz2qUzdCxieFEvhGRNiOV i/Ag== X-Received: by 10.180.100.161 with SMTP id ez1mr49048351wib.60.1441819046782; Wed, 09 Sep 2015 10:17:26 -0700 (PDT) Received: from arch-x220.localdomain (cpc12-croy20-2-0-cust52.croy.cable.virginm.net. [82.44.54.53]) by smtp.gmail.com with ESMTPSA id j7sm11257042wjz.11.2015.09.09.10.17.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 Sep 2015 10:17:26 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 05/12] xf86drm: rename drmSameDevice to drmCompareBusInfo Date: Wed, 9 Sep 2015 18:21:26 +0100 Message-Id: <1441819293-25567-6-git-send-email-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1441819293-25567-1-git-send-email-emil.l.velikov@gmail.com> References: <1441819293-25567-1-git-send-email-emil.l.velikov@gmail.com> Cc: emil.l.velikov@gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move away form the boolean name, change the return value appropriately and check if either argument is NULL. Signed-off-by: Emil Velikov --- 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);