From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 35F66138334 for ; Fri, 10 May 2019 15:33:04 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 09305E0849; Fri, 10 May 2019 15:33:03 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D76E9E0826 for ; Fri, 10 May 2019 15:33:02 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 59731343F78 for ; Fri, 10 May 2019 15:33:01 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id AD7B6549 for ; Fri, 10 May 2019 15:32:59 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1557495296.be69812ae6332bbd3a00f00dbdcb928176c3a1dc.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: libq/ X-VCS-Repository: proj/portage-utils X-VCS-Files: libq/scandirat.c X-VCS-Directories: libq/ X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: be69812ae6332bbd3a00f00dbdcb928176c3a1dc X-VCS-Branch: master Date: Fri, 10 May 2019 15:32:59 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 1234927d-3ea2-43e1-858c-1f10b54525ea X-Archives-Hash: 4d3b4d69e630c2e8f16df0fb8ebc64ba commit: be69812ae6332bbd3a00f00dbdcb928176c3a1dc Author: Fabian Groffen gentoo org> AuthorDate: Fri May 10 13:34:56 2019 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Fri May 10 13:34:56 2019 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=be69812a libq/scandirat: support compar being NULL The specs say that if compar is NULL no sorting happens, so just don't sort if it is NULL (instead of crashing). Signed-off-by: Fabian Groffen gentoo.org> libq/scandirat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libq/scandirat.c b/libq/scandirat.c index b3d0cfe..f28ba0d 100644 --- a/libq/scandirat.c +++ b/libq/scandirat.c @@ -64,7 +64,8 @@ scandirat(int dir_fd, const char *dir, struct dirent ***dirlist, } *dirlist = ret; - qsort(ret, retlen, sizeof(*ret), (void *)compar); + if (compar != NULL) + qsort(ret, retlen, sizeof(*ret), (void *)compar); /* closes underlying fd */ closedir(dirp);