shithub: riscv

Download patch

ref: 6eba362810c398e59727e8286b1e3f24178b6618
parent: 9babf6a347c71b01cdc8c057185083b96447af62
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Mar 11 14:09:48 EDT 2015

ndb/dns: reduce sencodefmt() to not link in enc32()/enc64() encoders

the special sencodefmt() in ndb/dn.c is only used with %H format for
hexadecimal printing for binary strings. removing the unused
calls to enc32() and enc64() reduces the code size by arround 4K.
(this is usefull for ndb/getip which gets linked into the kernel).

--- a/sys/src/cmd/ndb/dn.c
+++ b/sys/src/cmd/ndb/dn.c
@@ -1713,20 +1713,7 @@
 	ilen = f->prec;
 	f->prec = 0;
 	f->flags &= ~FmtPrec;
-	switch(f->r){
-	case '<':
-		len = (8*ilen+4)/5 + 3;
-		break;
-	case '[':
-		len = (8*ilen+5)/6 + 4;
-		break;
-	case 'H':
-		len = 2*ilen + 1;
-		break;
-	default:
-		goto error;
-	}
-
+	len = 2*ilen + 1;
 	if(len > sizeof(obuf)){
 		buf = malloc(len);
 		if(buf == nil)
@@ -1736,20 +1723,7 @@
 
 	/* convert */
 	out = buf;
-	switch(f->r){
-	case '<':
-		rv = enc32(out, len, b, ilen);
-		break;
-	case '[':
-		rv = enc64(out, len, b, ilen);
-		break;
-	case 'H':
-		rv = enc16(out, len, b, ilen);
-		break;
-	default:
-		rv = -1;
-		break;
-	}
+	rv = enc16(out, len, b, ilen);
 	if(rv < 0)
 		goto error;