Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Apr 2019 20:27:14 +0000 (UTC)
From:      Conrad Meyer <cem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r345891 - head/usr.bin/sort
Message-ID:  <201904042027.x34KRE8o029815@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 }
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904042027.x34KRE8o029815>