From patchwork Tue Jul 14 14:10:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 6787531 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 12BB59F2E8 for ; Tue, 14 Jul 2015 14:06:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4BC0B20709 for ; Tue, 14 Jul 2015 14:06:09 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 692AB20585 for ; Tue, 14 Jul 2015 14:06:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 444926EA27; Tue, 14 Jul 2015 07:06:07 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by gabe.freedesktop.org (Postfix) with ESMTPS id E46BB6EA27 for ; Tue, 14 Jul 2015 07:06:05 -0700 (PDT) Received: by wibud3 with SMTP id ud3so56625253wib.1 for ; Tue, 14 Jul 2015 07:06:04 -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=T1aop2kKgMhW0V52R59YBWjAWPCtqL76cO5Qh3Cq0iQ=; b=qCUISDxEO0pFv1X4z9erFD8qKGerXYpyNq6XYFoS0qAgkIqiar6v0Z33/TSPl3TwRo PT2w3hIHQrZpk7rr1ikTXmxse2kg+VBhKLAwymQXovVuSpgv0aTTgq3tXswrpITOTL/s WscMtv79l4eGEubnsNthPg+m1Ar0HS46E/9mvFW9+7Xd3eiTpZC7OkwA1Abf0QosQ1dL C0hti9FplLHQ75F9rN7OgF7Z6jd1lEAy/fYM6ccXpQmTnAw6ubA6gCHHwRphnGdU+Pwl QPVc2F/EDMHiebyxeCCGf4rrxkL1RjqObLIbKtssFZ222EfskI3dgUDGxGEc5V8w6eSQ Yzrw== X-Received: by 10.181.12.20 with SMTP id em20mr34818686wid.28.1436882764374; Tue, 14 Jul 2015 07:06:04 -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 fb3sm20979888wib.21.2015.07.14.07.06.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Jul 2015 07:06:03 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 4/4] Consistently check the fd value Date: Tue, 14 Jul 2015 15:10:05 +0100 Message-Id: <1436883005-6163-4-git-send-email-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.4.5 In-Reply-To: <1436883005-6163-1-git-send-email-emil.l.velikov@gmail.com> References: <1436883005-6163-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=-5.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Follow the approach used through the rest of the project. Cc: Thierry Reding Suggested-by: Thierry Reding Signed-off-by: Emil Velikov Reviewed-by: Thierry Reding --- intel/test_decode.c | 2 +- tests/name_from_fd.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/intel/test_decode.c b/intel/test_decode.c index bef86bb..b4eddcd 100644 --- a/intel/test_decode.c +++ b/intel/test_decode.c @@ -56,7 +56,7 @@ read_file(const char *filename, void **ptr, size_t *size) struct stat st; fd = open(filename, O_RDONLY); - if (fd == -1) + if (fd < 0) errx(1, "couldn't open `%s'", filename); ret = fstat(fd, &st); diff --git a/tests/name_from_fd.c b/tests/name_from_fd.c index 24af6e6..5264681 100644 --- a/tests/name_from_fd.c +++ b/tests/name_from_fd.c @@ -45,7 +45,7 @@ int main(int argc, char **argv) char *v; fd = open("/dev/dri/card0", O_RDWR); - if (fd == -1) + if (fd < 0) return 0; v = drmGetDeviceNameFromFd(fd);