svn commit: r345891 - head/usr.bin/sort
Conrad Meyer
cem at FreeBSD.org
Thu Apr 4 20:27:15 UTC 2019
Author: cem
Date: Thu Apr 4 20:27:13 2019
New Revision: 345891
URL: https://svnweb.freebsd.org/changeset/base/345891
Log:
sort(1): randomcoll: Don't sort on ENOMEM
PR: 230792 (1/many)
Sponsored by: Dell EMC Isilon
Modified:
head/usr.bin/sort/coll.c
Modified: head/usr.bin/sort/coll.c
==============================================================================
--- head/usr.bin/sort/coll.c Thu Apr 4 20:24:58 2019 (r345890)
+++ head/usr.bin/sort/coll.c Thu Apr 4 20:27:13 2019 (r345891)
@@ -991,6 +991,7 @@ randomcoll(struct key_value *kv1, struct key_value *kv
struct bwstring *s1, *s2;
MD5_CTX ctx1, ctx2;
char *b1, *b2;
+ int cmp_res;
s1 = kv1->k;
s2 = kv2->k;
@@ -1010,28 +1011,17 @@ randomcoll(struct key_value *kv1, struct key_value *kv
MD5Update(&ctx2, bwsrawdata(s2), bwsrawlen(s2));
b1 = MD5End(&ctx1, NULL);
b2 = MD5End(&ctx2, NULL);
- if (b1 == NULL) {
- if (b2 == NULL)
- return (0);
- else {
- sort_free(b2);
- return (-1);
- }
- } else if (b2 == NULL) {
- sort_free(b1);
- return (+1);
- } else {
- int cmp_res;
+ if (b1 == NULL || b2 == NULL)
+ err(2, "MD5End");
- cmp_res = strcmp(b1,b2);
- sort_free(b1);
- sort_free(b2);
+ cmp_res = strcmp(b1,b2);
+ sort_free(b1);
+ sort_free(b2);
- if (!cmp_res)
- cmp_res = bwscoll(s1, s2, 0);
+ if (!cmp_res)
+ cmp_res = bwscoll(s1, s2, 0);
- return (cmp_res);
- }
+ return (cmp_res);
}
/*
More information about the svn-src-all
mailing list