From patchwork Tue Mar 20 17:48:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 10297671 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BE61260349 for ; Tue, 20 Mar 2018 17:53:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB37326538 for ; Tue, 20 Mar 2018 17:53:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BEC72876D; Tue, 20 Mar 2018 17:53:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 17C2326538 for ; Tue, 20 Mar 2018 17:53:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 887D76E828; Tue, 20 Mar 2018 17:53:33 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id E0A296E828 for ; Tue, 20 Mar 2018 17:53:31 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id i189so2881658wmf.0 for ; Tue, 20 Mar 2018 10:53:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=067i0j+AEldoV59V9CxZTmLUTcarQ+m1ISE7XKxchgY=; b=M/NibNn8vTq7/8vrJxBAE0/y9F0FiECSzqYglXJaE3GAcOm7OoSvdQ5b0mTw50g8nj 7n03MRmgu8rNp0FtSGTMjqOyWkFcYQyjwBmtfN36pzzm53KTiNf2lYEWeKh6fNyDukxT g9USI8/bj3bnuWTt8ZPpwyPmSJj1aaT6RNmzWMJd0PdQWCKzh9SknZgW5VfO8pJbbd1q SkP7C4nrLIyTK0Y+9J00keqRmrM9gkhO7ME1/LxPqekAoy1wANVbUSV5quRSZj1SkFbk +PTUi3d91oeHcgaHJQtlh89JbksuSs1Y794EP3pEBeq8DJQh5F5LE8Zc1udVOObc39Xc NNkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=067i0j+AEldoV59V9CxZTmLUTcarQ+m1ISE7XKxchgY=; b=uHXnpVDpCXZnJUdRAzKP8nHfEufvSvnTOWgnNCILrLJTppWxb3d5eKCoYU8dK42OCr /e2a8/8vMge9enhGZc1OKmPrxJ2cQzrBs5fEZPngGog8uToeUf8A41kNCGFqX3CWn7/6 ERcEZ81yek2hGwg9TpvZ1gZZ5tGc2F5O9mqZNLjvd0cFlxmL8p896N73DicU1MWu0ulE r7u3BDrKxkOisUkhv7gL+tUkin/bKyPk/yiVgJ7E//RENCn50aMnK9d0Js8PnHAwe0QM 7ImFJgtO88yQBv5S2yIfZLrdloqU0wvJYmfbCAImWwVdD0Kq5thua5AO6YZetIHW2htd rrTw== X-Gm-Message-State: AElRT7EgA1zO/1YlHGTOOv+VNJ8PkCkm/JOq2FAYuZacq+RALxCuCv8w 6Cx5wP1ZLTBPvERoeQDnvM9s4w== X-Google-Smtp-Source: AG47ELtjpDWnHWevTuJlAour0PWqqB3USgpuc5g2knhell0vTz7H4EZy0DFnkyv6MFk+sxM/qz+u+Q== X-Received: by 10.28.149.71 with SMTP id x68mr477839wmd.78.1521568410027; Tue, 20 Mar 2018 10:53:30 -0700 (PDT) Received: from arch-x1c3.cbg.collabora.co.uk ([2a00:5f00:102:0:9665:9cff:feee:aa4d]) by smtp.gmail.com with ESMTPSA id z3sm3437786wme.3.2018.03.20.10.53.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Mar 2018 10:53:28 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm v2] libdrm: Use readdir instead of readdir_r to avoid build warnings Date: Tue, 20 Mar 2018 17:48:23 +0000 Message-Id: <20180320174823.6281-1-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.16.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Robert Foss , emil.l.velikov@gmail.com, Stefan Schake MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: John Stultz Building libdrm under AOSP, we see the following build warning: external/libdrm/xf86drm.c:2861:12: warning: 'readdir_r' is deprecated: readdir_r is deprecated; use readdir instead [-Wdeprecated-declarations] while (readdir_r(sysdir, pent, &ent) == 0 && ent != NULL) { ^ Building on Linux with glibc produces the same warning. Thus, this patch replaces readdir_r with readdir. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102031 Cc: Robert Foss Cc: Rob Herring Cc: Stefan Schake Cc: John Stultz Cc: Eric Engestrom Signed-off-by: John Stultz Reviewed-by: Emil Velikov [Emil Velikov: remove unused variables, Eric] Signed-off-by: Emil Velikov Reviewed-by: Eric Engestrom --- xf86drm.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/xf86drm.c b/xf86drm.c index 9328bf5a..97f87e02 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -2822,12 +2822,11 @@ static char *drmGetMinorNameForFD(int fd, int type) { #ifdef __linux__ DIR *sysdir; - struct dirent *pent, *ent; + struct dirent *ent; struct stat sbuf; const char *name = drmGetMinorName(type); int len; char dev_name[64], buf[64]; - long name_max; int maj, min; if (!name) @@ -2850,30 +2849,16 @@ static char *drmGetMinorNameForFD(int fd, int type) if (!sysdir) return NULL; - name_max = fpathconf(dirfd(sysdir), _PC_NAME_MAX); - if (name_max == -1) - goto out_close_dir; - - pent = malloc(offsetof(struct dirent, d_name) + name_max + 1); - if (pent == NULL) - goto out_close_dir; - - while (readdir_r(sysdir, pent, &ent) == 0 && ent != NULL) { + while ((ent = readdir(sysdir))) { if (strncmp(ent->d_name, name, len) == 0) { snprintf(dev_name, sizeof(dev_name), DRM_DIR_NAME "/%s", ent->d_name); - free(pent); closedir(sysdir); - return strdup(dev_name); } } - - free(pent); - -out_close_dir: - closedir(sysdir); + return NULL; #else struct stat sbuf; char buf[PATH_MAX + 1]; @@ -2914,7 +2899,6 @@ out_close_dir: return strdup(buf); #endif - return NULL; } char *drmGetPrimaryDeviceNameFromFd(int fd)