]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic/strv: use existing qsort_safe() helper
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 10 Jul 2017 18:55:14 +0000 (14:55 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 10 Jul 2017 19:40:47 +0000 (15:40 -0400)
strv_sort() predates qsort_safe(), but we can convert it to it to
save a few lines.

src/basic/strv.c

index 0eec868eed1f5e0dc46288eadf16b89830d49b7c..c63f11c6ade9627a6fa3af6a2eeb863a82dd71d0 100644 (file)
@@ -770,11 +770,7 @@ static int str_compare(const void *_a, const void *_b) {
 }
 
 char **strv_sort(char **l) {
-
-        if (strv_isempty(l))
-                return l;
-
-        qsort(l, strv_length(l), sizeof(char*), str_compare);
+        qsort_safe(l, strv_length(l), sizeof(char*), str_compare);
         return l;
 }