Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage-utils:master commit in: libq/
Date: Fri, 10 May 2019 15:33:04
Message-Id: 1557495296.be69812ae6332bbd3a00f00dbdcb928176c3a1dc.grobian@gentoo
1 commit: be69812ae6332bbd3a00f00dbdcb928176c3a1dc
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Fri May 10 13:34:56 2019 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Fri May 10 13:34:56 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=be69812a
7
8 libq/scandirat: support compar being NULL
9
10 The specs say that if compar is NULL no sorting happens, so just don't
11 sort if it is NULL (instead of crashing).
12
13 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
14
15 libq/scandirat.c | 3 ++-
16 1 file changed, 2 insertions(+), 1 deletion(-)
17
18 diff --git a/libq/scandirat.c b/libq/scandirat.c
19 index b3d0cfe..f28ba0d 100644
20 --- a/libq/scandirat.c
21 +++ b/libq/scandirat.c
22 @@ -64,7 +64,8 @@ scandirat(int dir_fd, const char *dir, struct dirent ***dirlist,
23 }
24 *dirlist = ret;
25
26 - qsort(ret, retlen, sizeof(*ret), (void *)compar);
27 + if (compar != NULL)
28 + qsort(ret, retlen, sizeof(*ret), (void *)compar);
29
30 /* closes underlying fd */
31 closedir(dirp);