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: 132151 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1170001ljb; Tue, 20 Mar 2018 10:54:05 -0700 (PDT) X-Google-Smtp-Source: AG47ELsR9lmuYocoVBBqYrcLsFI+QuDyihpnKZLQgaP9E907ixZoUWjIVvq96cVheH6QYCaIKDTN X-Received: by 10.101.93.17 with SMTP id e17mr13000166pgr.239.1521568445369; Tue, 20 Mar 2018 10:54:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521568445; cv=none; d=google.com; s=arc-20160816; b=xoGltyz+FEHqcZizmPzzzqpGacrVVEUtrkNQjDR02AuWJ5xey7rrPQ6ku7YMcwOmCB +9ZOpE8elYJDh1jyoeTz3D2EdhMA8xwPFayTVsO4/6crcNDCQHrbOE3l6jnUIN/xIKKa TrvKYxmqSr00lE8l6jTDDH56dmZmg0HnKahqPVQmneaQBOZMLTbQNcdp34aCwdXWg6vR N1EJGl0PLwXBvWlLv5iQDyB0oLrRQel7OWs329ih9VH8Y3mJ6e2hz4bk2dmSeT1NhdPh 9KqUyJR4kaSrNI7hOiVllyjenProa5u9anWr6Sg71JwcdIi6rVKxyBB+mBOxK2skUBDx eI9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:message-id:date:subject:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=HDkYFRqPJP1r+PgANviaI5t+ug283SBp9f730kMt1hw=; b=k+BmS77xMjMgaEhVW9cyxjOo1HY3KwQ40T7mPr+Z3tQRKkDpdhVuhkjY9IGqiGfgOb QN/C/5b1gh5s3VUnXImLQfsEQDPif3g7FAksbsomnXJFTsWCYZqp04edT6JmlrWcgWwI aqsObx+ZlRMrX9FzjpEY+Eg/XOvRsxB8lYBqlsxKDi7hGVAHXP2jk6Q3a9AKEqnWlpPc aJz7FvV/BoE3px/emxxkNO3BlR8Utg1s6MRuRG+/n3ipMMSyxzzTETzBUm8l5pkhk0V5 6dAN90CmqaUz5g9lkin6wQADDdS2KSnZ4r9o0mbFF3M9fsmVQ+bAB0sFKJO544/7SAUn e/wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=M/NibNn8; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id f9si1505282pgn.241.2018.03.20.10.54.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Mar 2018 10:54:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=M/NibNn8; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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-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" 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)