shithub: riscv

Download patch

ref: 0930f44febd25c27fb717e7323686e50c4fa0593
parent: c0d0f86b14593bbf608284b96920558756a69304
author: ftrvxmtrx <ftrvxmtrx@gmail.com>
date: Wed Nov 16 21:59:40 EST 2016

cmd: remove a bit of unused stuff

--- a/sys/src/cmd/9660srv/main.c
+++ b/sys/src/cmd/9660srv/main.c
@@ -28,7 +28,6 @@
 void	rwstat(void);
 
 static int	openflags(int);
-static void	rmservice(void);
 static void	usage(void);
 
 #define Reqsize (sizeof(Fcall)+Maxfdata)
--- a/sys/src/cmd/9nfs/authhostowner.c
+++ b/sys/src/cmd/9nfs/authhostowner.c
@@ -46,27 +46,6 @@
 	return p;
 }
 
-static uchar*
-convM2AI(uchar *p, int n, AuthInfo **aip)
-{
-	uchar *e = p+n;
-	AuthInfo *ai;
-
-	ai = mallocz(sizeof(*ai), 1);
-	if(ai == nil)
-		return nil;
-
-	p = gstring(p, e, &ai->cuid);
-	p = gstring(p, e, &ai->suid);
-	p = gstring(p, e, &ai->cap);
-	p = gcarray(p, e, &ai->secret, &ai->nsecret);
-	if(p == nil)
-		auth_freeAI(ai);
-	else
-		*aip = ai;
-	return p;
-}
-
 static int
 dorpc(AuthRpc *rpc, char *verb, char *val, int len, AuthGetkey *getkey)
 {
--- a/sys/src/cmd/9nfs/nfsmount.c
+++ b/sys/src/cmd/9nfs/nfsmount.c
@@ -182,18 +182,6 @@
 	return 0;
 }
 
-static char*
-Str2str(String s, char *buf, int nbuf)
-{
-	int i;
-	i = s.n;
-	if(i >= nbuf)
-		i = nbuf-1;
-	memmove(buf, s.s, i);
-	buf[i] = 0;
-	return buf;
-}
-
 static int
 mntmnt(int n, Rpccall *cmd, Rpccall *reply)
 {
--- a/sys/src/cmd/9nfs/server.c
+++ b/sys/src/cmd/9nfs/server.c
@@ -4,7 +4,6 @@
 static int	alarmflag;
 
 static int	Iconv(Fmt*);
-static void	openudp(int);
 static void	cachereply(Rpccall*, void*, int);
 static int	replycache(int, Rpccall*, long (*)(int, void*, long));
 static void	udpserver(int, Progmap*);
@@ -441,12 +440,6 @@
 		}
 	}
 	return nil;
-}
-
-static Namecache*
-domlookup(void *name)
-{
-	return domlookupl(name, strlen(name));
 }
 
 static Namecache*
--- a/sys/src/cmd/abaco/page.c
+++ b/sys/src/cmd/abaco/page.c
@@ -548,19 +548,6 @@
 static Rune right1[] = { L'}', L']', L')', L'>', L'»', 0 };
 static Rune left2[] =  { L'\'', L'"', L'`', 0 };
 
-static
-Rune *left[] = {
-	left1,
-	left2,
-	nil
-};
-static
-Rune *right[] = {
-	right1,
-	left2,
-	nil
-};
-
 void
 pagedoubleclick(Page *p)
 {
--- a/sys/src/cmd/abaco/scrl.c
+++ b/sys/src/cmd/abaco/scrl.c
@@ -199,14 +199,12 @@
 {
 	uint oldp0, p0;
 	Rectangle s;
-	Point mxy;
-	int i, m, om, first, d, size;
+	int m, om, first, d, size;
 	int smin, smax, ss, *pos;
 
 	if(horizontal){
 		s = insetrect(p->hscrollr, 1);
 		ss = s.max.x - s.min.x;
-		i = (s.min.y+s.max.y)/2;
 		d = Dx(p->r);
 		size = Dx(p->lay->r);
 		p0 = p->pos.x;
@@ -217,7 +215,6 @@
 	}else{
 		s = insetrect(p->vscrollr, 1);
 		ss = s.max.y-s.min.y;
-		i = (s.min.x+s.max.x)/2;
 		d = Dy(p->r);
 		size = Dy(p->lay->r);
 		p0 = p->pos.y;
@@ -248,10 +245,6 @@
 			m = smax;
 
 		om = m;
-		if(horizontal)
-			mxy = Pt(m, i);
-		else
-			mxy = Pt(i, m);
 		if(but == 2){
 			p0 = muldiv(m-smin, size, ss);
 			p0 = max(p0, 0);
--- a/sys/src/cmd/acme/acme.c
+++ b/sys/src/cmd/acme/acme.c
@@ -58,7 +58,6 @@
 	Column *c;
 	int ncol;
 	Display *d;
-	static void *arg[1];
 
 	rfork(RFENVG|RFNAMEG);
 
--- a/sys/src/cmd/acme/exec.c
+++ b/sys/src/cmd/acme/exec.c
@@ -1196,7 +1196,6 @@
 	int ac, w, inarg, i, n, fd, nincl, winid;
 	int pipechar;
 	char buf[512];
-	static void *parg[2];
 	void **argv;
 
 	argv = argvp;
--- a/sys/src/cmd/atazz/main.c
+++ b/sys/src/cmd/atazz/main.c
@@ -1511,25 +1511,6 @@
 	return -1;
 }
 
-static char *regtab[] = {
-	"Ftype",
-	"Fflags",
-	"Fcmd",
-	"Ffeat",
-	"Flba0",
-	"Flba8",
-	"Flba16",
-	"Fdev",
-	"Flba24",
-	"Flba32",
-	"Flba40",
-	"Ffeat8",
-	"Fsc",
-	"Fsc8",
-	"Fr",
-	"Fcontrol",
-};
-
 void
 setreg(Req *r, uint reg, uvlong v)
 {
@@ -1540,7 +1521,6 @@
 	case 0:
 		r->fisbits |= 1 << reg;
 		r->cmd.fis[reg] = v;
-//	print("%s: %.2ux\n", regtab[reg], (uchar)v);
 		break;
 	case Sbase:
 	case Sbase | Pbase:
--- a/sys/src/cmd/aux/timesync.c
+++ b/sys/src/cmd/aux/timesync.c
@@ -663,19 +663,6 @@
 static long order = 0x00010203;
 
 static uchar*
-be2long(long *to, uchar *f)
-{
-	uchar *t, *o;
-	int i;
-
-	t = (uchar*)to;
-	o = (uchar*)&order;
-	for(i = 0; i < sizeof(long); i++)
-		t[o[i]] = f[i];
-	return f+sizeof(long);
-}
-
-static uchar*
 long2be(uchar *t, long from)
 {
 	uchar *f, *o;
--- a/sys/src/cmd/cdfs/main.c
+++ b/sys/src/cmd/cdfs/main.c
@@ -22,7 +22,6 @@
 int vflag;
 
 static Drive *drive;
-static int nchange;
 
 enum {
 	Qdir = 0,
--- a/sys/src/cmd/cdfs/mmc.c
+++ b/sys/src/cmd/cdfs/mmc.c
@@ -73,15 +73,6 @@
 	return (a[0]<<24)|(a[1]<<16)|(a[2]<<8)|(a[3]<<0);
 }
 
-static ushort
-biges(void *p)
-{
-	uchar *a;
-
-	a = p;
-	return (a[0]<<8) | a[1];
-}
-
 ulong
 getnwa(Drive *drive)
 {
@@ -92,22 +83,6 @@
 }
 
 static void
-hexdump(void *v, int n)
-{
-	int i;
-	uchar *p;
-
-	p = v;
-	for(i=0; i<n; i++){
-		print("%.2ux ", p[i]);
-		if((i%8) == 7)
-			print("\n");
-	}
-	if(i%8)
-		print("\n");
-}
-
-static void
 initcdb(uchar *cdb, int len, int cmd)
 {
 	memset(cdb, 0, len);
@@ -220,18 +195,8 @@
 	cmd[1] = 0x10;			/* format not vendor-specific */
 	cmd[8] = len;
 
-//	print("set: sending cmd\n");
-//	hexdump(cmd, 10);
-//	print("parameter list header\n");
-//	hexdump(p, Mode10parmhdrlen);
-//	print("page\n");
-//	hexdump(p + Mode10parmhdrlen, len - Mode10parmhdrlen);
-
 	n = scsi(drive, cmd, sizeof(cmd), p, len, Swrite);
 
-//	print("set: got cmd\n");
-//	hexdump(cmd, 10);
-
 	free(p);
 	if(n < len)
 		return -1;
@@ -414,9 +379,6 @@
 	if(buf[Capmisc] & Capcdda)	/* CD-DA commands supported? */
 		cap |= Ccdda;		/* not used anywhere else */
 
-//	print("read %d max %d\n", biges(buf+14), biges(buf+8));
-//	print("write %d max %d\n", biges(buf+20), biges(buf+18));
-
 	/* cache optional page 05 (write parameter page) */
 	if(/* (cap & Cwrite) && */
 	    mmcgetpage(drive, Pagwrparams, aux->page05) >= 0) {
@@ -1255,9 +1217,6 @@
 
 	PUTBELONG(fmtdesc, nblks);
 	PUTBE24(fmtdesc + 5, blksize);
-
-//	print("format parameters:\n");
-//	hexdump(parms, sizeof parms);
 
 	if(vflag)
 		print("%lld ns: format\n", nsec());
--- a/sys/src/cmd/cifs/auth-testcase.c
+++ /dev/null
@@ -1,455 +1,0 @@
-/*
- * Beware the LM hash is easy to crack (google for l0phtCrack)
- * and though NTLM is more secure it is still breakable.
- * Ntlmv2 is better and seen as good enough by the Windows community.
- * For real security use Kerberos.
- */
-#include <u.h>
-#include <libc.h>
-#include <mp.h>
-#include <auth.h>
-#include <libsec.h>
-#include <ctype.h>
-#include <fcall.h>
-#include <thread.h>
-#include <9p.h>
-#include "cifs.h"
-
-#define NTLMV2_TEST	1
-#define DEF_AUTH 	"ntlmv2"
-
-static enum {
-	MACkeylen	= 40,	/* MAC key len */
-	MAClen		= 8,	/* signature length */
-	MACoff		= 14,	/* sign. offset from start of SMB (not netbios) pkt */
-	Bliplen		= 8,	/* size of LMv2 client nonce */
-};
-
-static void
-dmp(char *s, int seq, void *buf, int n)
-{
-	int i;
-	char *p = buf;
-
-	print("%s %3d      ", s, seq);
-	while(n > 0){
-		for(i = 0; i < 16 && n > 0; i++, n--)
-			print("%02x ", *p++ & 0xff);
-		if(n > 0)
-			print("\n");
-	}
-	print("\n");
-}
-
-static Auth *
-auth_plain(char *windom, char *keyp, uchar *chal, int len)
-{
-	UserPasswd *up;
-	static Auth *ap;
-
-	USED(chal, len);
-
-	up = auth_getuserpasswd(auth_getkey, "windom=%s proto=pass service=cifs %s",
-		windom, keyp);
-	if(! up)
-		sysfatal("cannot get key - %r");
-
-	ap = emalloc9p(sizeof(Auth));
-	memset(ap, 0, sizeof(ap));
-	ap->user = estrdup9p(up->user);
-	ap->windom = estrdup9p(windom);
-
-	ap->resp[0] = estrdup9p(up->passwd);
-	ap->len[0] = strlen(up->passwd);
-	memset(up->passwd, 0, strlen(up->passwd));
-	free(up);
-
-	return ap;
-}
-
-static Auth *
-auth_lm_and_ntlm(char *windom, char *keyp, uchar *chal, int len)
-{
-	int err;
-	Auth *ap;
-	char user[64];
-	MSchapreply mcr;
-
-	err = auth_respond(chal, len, user, sizeof user, &mcr, sizeof mcr,
-		auth_getkey, "windom=%s proto=mschap role=client service=cifs %s",
-		windom, keyp);
-	if(err == -1)
-		sysfatal("cannot get key - %r");
-
-	ap = emalloc9p(sizeof(Auth));
-	memset(ap, 0, sizeof(ap));
-	ap->user = estrdup9p(user);
-	ap->windom = estrdup9p(windom);
-
-	/* LM response */
-	ap->len[0] = sizeof(mcr.LMresp);
-	ap->resp[0] = emalloc9p(ap->len[0]);
-	memcpy(ap->resp[0], mcr.LMresp, ap->len[0]);
-
-	/* NTLM response */
-	ap->len[1] = sizeof(mcr.NTresp);
-	ap->resp[1] = emalloc9p(ap->len[1]);
-	memcpy(ap->resp[1], mcr.NTresp, ap->len[1]);
-
-	return ap;
-}
-
-/*
- * NTLM response only, the LM response is a just
- * copy of the NTLM one.  We do this because the lm
- * response is easily reversed - Google for l0pht for more info.
- */
-static Auth *
-auth_ntlm(char *windom, char *keyp, uchar *chal, int len)
-{
-	Auth *ap;
-
-	if((ap = auth_lm_and_ntlm(windom, keyp, chal, len)) == nil)
-		return nil;
-
-	free(ap->resp[0]);
-	ap->len[0] = ap->len[1];
-	ap->resp[0] = emalloc9p(ap->len[0]);
-	memcpy(ap->resp[0], ap->resp[1], ap->len[0]);
-	return ap;
-}
-
-/*
- * This is not really nescessary as all fields hmac_md5'ed
- * in the ntlmv2 protocol are less than 64 bytes long, however
- * I still do this for completeness.
- */
-static DigestState *
-hmac_t64(uchar *data, ulong dlen, uchar *key, ulong klen, uchar *digest,
-	DigestState *state)
-{
-	if(klen > 64)
-		klen = 64;
-	return hmac_md5(data, dlen, key, klen, digest, state);
-}
-
-
-static int
-ntv2_blob(uchar *blob, int len, char *windom)
-{
-	uvlong t;
-	uchar *p;
-	enum {			/* name types */
-		Beof,		/* end of name list */
-		Bhost,		/* Netbios host name */
-		Bdomain,	/* Windows Domain name (NT) */
-		Bdnshost,	/* DNS host name */
-		Bdnsdomain,	/* DNS domain name */
-	};
-
-	p = blob;
-	*p++ = 1;		/* 8bit: response type */
-	*p++ = 1;		/* 8bit: max response type understood by client */
-
-	*p++ = 0;		/* 16bit: reserved */
-	*p++ = 0;
-
-	*p++ = 0;		/* 32bit: unknown */
-	*p++ = 0;
-	*p++ = 0;
-	*p++ = 0;
-
-
-#ifdef NTLMV2_TEST
-	*p++ = 0xf0;
-	*p++ = 0x20;
-	*p++ = 0xd0;
-	*p++ = 0xb6;
-	*p++ = 0xc2;
-	*p++ = 0x92;
-	*p++ = 0xbe;
-	*p++ = 0x01;
-#else
-	t = time(nil);	/* 64bit: time in NT format */
-	t += 11644473600LL;
-	t *= 10000000LL;
-	*p++ = t;
-	*p++ = t >> 8;
-	*p++ = t >> 16;
-	*p++ = t >> 24;
-	*p++ = t >> 32;
-	*p++ = t >> 40;
-	*p++ = t >> 48;
-	*p++ = t >> 56;
-#endif
-
-#ifdef NTLMV2_TEST
-	*p++ = 0x05;
-	*p++ = 0x83;
-	*p++ = 0x32;
-	*p++ = 0xec;
-	*p++ = 0xfa;
-	*p++ = 0xe4;
-	*p++ = 0xf3;
-	*p++ = 0x6d;
-#else
-	genrandom(p, 8);
-	p += 8;			/* 64bit: client nonce */
-#endif
-
-	*p++ = 0;		/* 32bit: unknown data */
-	*p++ = 0;
-	*p++ = 0;
-	*p++ = 0;
-
-	p += putname(p, len - (p-blob), windom, Bdomain);
-	p += putname(p, len - (p-blob), "", Beof);
-
-	return p - blob;
-}
-
-static Auth *
-auth_ntlmv2(char *windom, char *keyp, uchar *chal, int len)
-{
-	int i, n;
-	Rune r;
-	char *p, *u;
-	uchar c, lm_hmac[MD5dlen], nt_hmac[MD5dlen], nt_sesskey[MD5dlen];
-	uchar lm_sesskey[MD5dlen];
-	uchar v1hash[MD5dlen], blip[Bliplen], blob[1024], v2hash[MD5dlen];
-	DigestState *ds;
-	UserPasswd *up;
-	static Auth *ap;
-
-	up = auth_getuserpasswd(auth_getkey, "windom=%s proto=pass service=cifs-ntlmv2 %s",
-		windom, keyp);
-	if(! up)
-		sysfatal("cannot get key - %r");
-
-#ifdef NTLMV2_TEST
-{
-	static uchar srvchal[] = { 0x52, 0xaa, 0xc8, 0xe8, 0x2c, 0x06, 0x7f, 0xa1 };
-	up->user = "ADMINISTRATOR";
-	windom = "rocknroll";
-	chal = srvchal;
-}
-#endif
-	ap = emalloc9p(sizeof(Auth));
-	memset(ap, 0, sizeof(ap));
-
-	/* Standard says unlimited length, experience says 128 max */
-	if((n = strlen(up->passwd)) > 128)
-		n = 128;
-
-	ds = md4(nil, 0, nil, nil);
-	for(i = 0, p = up->passwd; i < n; i++) {
-		p += chartorune(&r, p);
-		c = r;
-		md4(&c, 1, nil, ds);
-		c = r >> 8;
-		md4(&c, 1, nil, ds);
-	}
-	md4(nil, 0, v1hash, ds);
-
-#ifdef NTLMV2_TEST
-{
-	uchar v1[] = {
-		0x0c, 0xb6, 0x94, 0x88, 0x05, 0xf7, 0x97, 0xbf,
-		0x2a, 0x82, 0x80, 0x79, 0x73, 0xb8, 0x95, 0x37
-	;
-	memcpy(v1hash, v1, sizeof(v1));
-}
-#endif
-	/*
-	 * Some documentation insists that the username must be forced to
-	 * uppercase, but the domain name should not be. Other shows both
-	 * being forced to uppercase.  I am pretty sure this is irrevevant as
-	 * the domain name passed from the remote server always seems to be in
-	 * uppercase already.
-	 */
-        ds = hmac_t64(nil, 0, v1hash, MD5dlen, nil, nil);
-	u = up->user;
-	while(*u){
-		u += chartorune(&r, u);
-		r = toupperrune(r);
-		c = r & 0xff;
-        	hmac_t64(&c, 1, v1hash, MD5dlen, nil, ds);
-		c = r >> 8;
-        	hmac_t64(&c, 1, v1hash, MD5dlen, nil, ds);
-	}
-	u = windom;
-
-	while(*u){
-		u += chartorune(&r, u);
-		c = r;
-        	hmac_t64(&c, 1, v1hash, MD5dlen, nil, ds);
-		c = r >> 8;
-        	hmac_t64(&c, 1, v1hash, MD5dlen, nil, ds);
-	}
-        hmac_t64(nil, 0, v1hash, MD5dlen, v2hash, ds);
-#ifdef NTLMV2_TEST
-	print("want:               40 e1 b3 24...\n");
-	dmp("v2hash==kr", 0, v2hash, MD5dlen);
-#endif
-	ap->user = estrdup9p(up->user);
-	ap->windom = estrdup9p(windom);
-
-	/* LM v2 */
-
-	genrandom(blip, Bliplen);
-#ifdef NTLMV2_TEST
-{
-	uchar t[] = { 0x05, 0x83, 0x32, 0xec, 0xfa, 0xe4, 0xf3, 0x6d };
-	memcpy(blip, t, 8);
-}
-#endif
-        ds = hmac_t64(chal, len, v2hash, MD5dlen, nil, nil);
-	hmac_t64(blip, Bliplen, v2hash, MD5dlen, lm_hmac, ds);
-	ap->len[0] = MD5dlen+Bliplen;
-	ap->resp[0] = emalloc9p(ap->len[0]);
-	memcpy(ap->resp[0], lm_hmac, MD5dlen);
-	memcpy(ap->resp[0]+MD5dlen, blip, Bliplen);
-#ifdef NTLMV2_TEST
-	print("want:               38 6b ae...\n");
-	dmp("lmv2 resp ", 0, lm_hmac, MD5dlen);
-#endif
-
-	/* LM v2 session key */
-	hmac_t64(lm_hmac, MD5dlen, v2hash, MD5dlen, lm_sesskey, nil);
-
-	/* LM v2 MAC key */
-	ap->mackey[0] = emalloc9p(MACkeylen);
-	memcpy(ap->mackey[0], lm_sesskey, MD5dlen);
-	memcpy(ap->mackey[0]+MD5dlen, ap->resp[0], MACkeylen-MD5dlen);
-
-	/* NTLM v2 */
-	n = ntv2_blob(blob, sizeof(blob), windom);
-        ds = hmac_t64(chal, len, v2hash, MD5dlen, nil, nil);
-	hmac_t64(blob, n, v2hash, MD5dlen, nt_hmac, ds);
-	ap->len[1] = MD5dlen+n;
-	ap->resp[1] = emalloc9p(ap->len[1]);
-	memcpy(ap->resp[1], nt_hmac, MD5dlen);
-	memcpy(ap->resp[1]+MD5dlen, blob, n);
-#ifdef NTLMV2_TEST
-	print("want:               1a ad 55...\n");
-	dmp("ntv2 resp ", 0, nt_hmac, MD5dlen);
-#endif
-
-	/* NTLM v2 session key */
-	hmac_t64(nt_hmac, MD5dlen, v2hash, MD5dlen, nt_sesskey, nil);
-
-	/* NTLM v2 MAC key */
-	ap->mackey[1] = emalloc9p(MACkeylen);
-	memcpy(ap->mackey[1], nt_sesskey, MD5dlen);
-	memcpy(ap->mackey[1]+MD5dlen, ap->resp[1], MACkeylen-MD5dlen);
-	free(up);
-
-	return ap;
-}
-
-struct {
-	char	*name;
-	Auth	*(*func)(char *, char *, uchar *, int);
-} methods[] = {
-	{ "plain",	auth_plain },
-	{ "lm+ntlm",	auth_lm_and_ntlm },
-	{ "ntlm",	auth_ntlm },
-	{ "ntlmv2",	auth_ntlmv2 },
-//	{ "kerberos",	auth_kerberos },
-};
-
-void
-autherr(void)
-{
-	int i;
-
-	fprint(2, "supported auth methods:\t");
-	for(i = 0; i < nelem(methods); i++)
-		fprint(2, "%s ", methods[i].name);
-	fprint(2, "\n");
-	exits("usage");
-}
-
-Auth *
-getauth(char *name, char *windom, char *keyp, int secmode, uchar *chal, int len)
-{
-	int i;
-	Auth *ap;
-
-	if(name == nil){
-		name = DEF_AUTH;
-		if((secmode & SECMODE_PW_ENCRYPT) == 0)
-			sysfatal("plaintext authentication required, use '-a plain'");
-	}
-
-	ap = nil;
-	for(i = 0; i < nelem(methods); i++)
-		if(strcmp(methods[i].name, name) == 0){
-			ap = methods[i].func(windom, keyp, chal, len);
-			break;
-		}
-
-	if(! ap){
-		fprint(2, "%s: %s - unknown auth method\n", argv0, name);
-		autherr();		/* never returns */
-	}
-	return ap;
-}
-
-static int
-genmac(uchar *buf, int len, int seq, uchar key[MACkeylen], uchar mine[MAClen])
-{
-	DigestState *ds;
-	uchar *sig, digest[MD5dlen], their[MAClen];
-
-	sig = buf+MACoff;
-	memcpy(their, sig, MAClen);
-	memset(sig, 0, MAClen);
-	sig[0] = seq;
-	sig[1] = seq >> 8;
-	sig[2] = seq >> 16;
-	sig[3] = seq >> 24;
-
-	ds = md5(key, MACkeylen, nil, nil);
-	md5(buf, len, nil, ds);
-	md5(nil, 0, digest, ds);
-	memcpy(mine, digest, MAClen);
-
-	return memcmp(their, mine, MAClen);
-}
-
-int
-macsign(Pkt *p)
-{
-	int i, len;
-	uchar *sig, *buf, mac[MAClen], zeros[MACkeylen];
-
-	sig = p->buf + NBHDRLEN + MACoff;
-	buf = p->buf + NBHDRLEN;
-	len = (p->pos - p->buf) - NBHDRLEN;
-
-	for(i = -3; i < 4; i++){
-		memset(zeros, 0, sizeof(zeros));
-		if(genmac(buf, len, p->seq+i, zeros, mac) == 0){
-			dmp("got", 0, buf, len);
-			dmp("Zero OK", p->seq, mac, MAClen);
-			return 0;
-		}
-
-		if(genmac(buf, len, p->seq+i, p->s->auth->mackey[0], mac) == 0){
-			dmp("got", 0, buf, len);
-			dmp("LM-hash OK", p->seq, mac, MAClen);
-			return 0;
-		}
-
-		if(genmac(buf, len, p->seq+i, p->s->auth->mackey[1], mac) == 0){
-			dmp("got", 0, buf, len);
-			dmp("NT-hash OK", p->seq, mac, MAClen);
-			return 0;
-		}
-	}
-	genmac(buf, len, p->seq, p->s->auth->mackey[0], mac);
-
-	memcpy(sig, mac, MAClen);
-	return -1;
-}
--- a/sys/src/cmd/cifs/auth.c
+++ b/sys/src/cmd/cifs/auth.c
@@ -23,6 +23,7 @@
 	MACoff		= 14,	/* sign. offset from start of SMB (not netbios) pkt */
 };
 
+#ifdef DEBUG_MAC
 static void
 dmp(char *s, int seq, void *buf, int n)
 {
@@ -38,6 +39,7 @@
 	}
 	print("\n");
 }
+#endif
 
 static Auth *
 auth_plain(char *windom, char *keyp, uchar *chal, int len)
--- a/sys/src/cmd/cifs/cifs.c
+++ b/sys/src/cmd/cifs/cifs.c
@@ -125,20 +125,6 @@
 	p->bytebase = pl16(p, 0);	/* filled in by cifsrpc() */
 }
 
-static void
-dmp(int seq, uchar *buf)
-{
-	int i;
-
-	if(seq == 99)
-		print("\n   ");
-	else
-		print("%+2d ", seq);
-	for(i = 0; i < 8; i++)
-		print("%02x ", buf[i] & 0xff);
-	print("\n");
-}
-
 int
 cifsrpc(Pkt *p)
 {
--- a/sys/src/cmd/cifs/main.c
+++ b/sys/src/cmd/cifs/main.c
@@ -1145,7 +1145,6 @@
 	long svrtime;
 	char windom[64], cname[64];
 	char *method, *sysname, *keyp, *mtpt, *svs;
-	static char *sh[1024];
 
 	*cname = 0;
 	keyp = "";
--- a/sys/src/cmd/cifs/netbios.c
+++ b/sys/src/cmd/cifs/netbios.c
@@ -68,19 +68,6 @@
 		*str++ = *(*p)++;
 }
 
-
-static ulong
-GB32(uchar **p)
-{
-	ulong n;
-
-	n  = *(*p)++ << 24;
-	n |= *(*p)++ << 16;
-	n |= *(*p)++ << 8;
-	n |= *(*p)++;
-	return n;
-}
-
 static ushort
 GB16(uchar **p)
 {
--- a/sys/src/cmd/cifs/trans.c
+++ b/sys/src/cmd/cifs/trans.c
@@ -103,13 +103,6 @@
 	p->pos = p->tparam;
 }
 
-static void
-gtdata(Pkt *p)
-{
-	p->pos = p->tdata;
-}
-
-
 int
 RAPshareenum(Session *s, Share *sp, Share **ent)
 {
--- a/sys/src/cmd/cifs/transnt.c
+++ b/sys/src/cmd/cifs/transnt.c
@@ -96,12 +96,6 @@
 }
 
 static void
-gtntparam(Pkt *p)
-{
-	p->pos = p->tparam;
-}
-
-static void
 gtntdata(Pkt *p)
 {
 	p->pos = p->tdata;
--- a/sys/src/cmd/cpp/lex.c
+++ b/sys/src/cmd/cpp/lex.c
@@ -309,7 +309,6 @@
 	int runelen;
 	Source *s = cursource;
 	int nmac = 0;
-	extern char outbuf[];
 
 	tp = trp->lp;
 	ip = s->inp;
--- a/sys/src/cmd/dossrv/xfile.c
+++ b/sys/src/cmd/dossrv/xfile.c
@@ -10,15 +10,6 @@
 static Xfile	*xfiles[FIDMOD], *freelist;
 static MLock	xlock, xlocks[FIDMOD], freelock;
 
-static int
-okmode(int omode, int fmode)
-{
-	if(omode == OREAD)
-		return fmode & 4;
-	/* else ORDWR */
-	return (fmode & 6) == 6;
-}
-
 Xfs *
 getxfs(char *user, char *name)
 {
--- a/sys/src/cmd/eqn/eqnbox.c
+++ b/sys/src/cmd/eqn/eqnbox.c
@@ -4,7 +4,6 @@
 {
 	double b, h;
 	char *sh;
-	extern char *IRspace;
 
 	yyval = p1;
 	b = max(ebase[p1], ebase[p2]);
--- a/sys/src/cmd/jpg/close.c
+++ b/sys/src/cmd/jpg/close.c
@@ -14,7 +14,6 @@
 	double r, g, b;
 	double diff, min;
 	int rgb, R, G, B, v, i;
-	int y1, cb1, cr1;
 
 	Cb -= 128;
 	Cr -= 128;
--- a/sys/src/cmd/jpg/jpegdump.c
+++ b/sys/src/cmd/jpg/jpegdump.c
@@ -90,7 +90,7 @@
 }
 
 void eatmarker (int kind) {
-	int l, c;
+	int l;
 	l = get2();
 	printf ("%02x len=%d\n", kind, l);
 	for (l -= 2; l > 0; l--)
@@ -211,7 +211,7 @@
 }
 
 int get1dht (void) {
-	int l, tcth, p, i, j, v[16], vv[16][256];
+	int l, tcth, i, j, v[16], vv[16][256];
 	tcth = get1();
 	printf ("DHT:\tclass = %d, table = %d\n", tcth >> 4, tcth & 0xf);
 	for (i = 0; i < 16; i++)
--- a/sys/src/cmd/jpg/writegif.c
+++ b/sys/src/cmd/jpg/writegif.c
@@ -41,7 +41,6 @@
 static void		writeheader(Biobuf*, Rectangle, int, ulong, int);
 static void		writedescriptor(Biobuf*, Rectangle);
 static char*	writedata(Biobuf*, Image*, Memimage*);
-static void		writetrailer(Biobuf *fd);
 static void		writecomment(Biobuf *fd, char*);
 static void		writegraphiccontrol(Biobuf *fd, int, int);
 static void*	gifmalloc(ulong);
--- a/sys/src/cmd/jpg/writetif.c
+++ b/sys/src/cmd/jpg/writetif.c
@@ -162,17 +162,6 @@
 	[Tcolor] {0x0140, Tshort}
 };
 
-/*
-* imported from libdraw/arith.c to permit
-* extern log2 function
-*/
-static int log2[] = {
-	-1, 0, 1, -1, 2, -1, -1, -1, 3,
-	-1, -1, -1, -1, -1, -1, -1, 4,
-	-1, -1, -1, -1, -1, -1, -1, 4 /* BUG */,
-	-1, -1, -1, -1, -1, -1, -1, 5
-};
-
 static Tab faxwhite[Nfaxtab] = {
 	{8, 0x35, 0}, /* 0011 0101 */
 	{6, 0x7, 1}, /* 0001 11 */
--- a/sys/src/cmd/ndb/cs.c
+++ b/sys/src/cmd/ndb/cs.c
@@ -985,19 +985,6 @@
 	return ipcmp(ip, IPnoaddr) != 0 && ipcmp(ip, v4prefix) != 0;
 }
 
-static uchar loopbacknet[IPaddrlen] = {
-	0, 0, 0, 0,
-	0, 0, 0, 0,
-	0, 0, 0xff, 0xff,
-	127, 0, 0, 0
-};
-static uchar loopbackmask[IPaddrlen] = {
-	0xff, 0xff, 0xff, 0xff,
-	0xff, 0xff, 0xff, 0xff,
-	0xff, 0xff, 0xff, 0xff,
-	0xff, 0, 0, 0
-};
-
 void
 readipinterfaces(void)
 {
@@ -1114,7 +1101,6 @@
 {
 	char clone[Maxpath];
 	Network *np;
-	static int working;
 
 	if(background){
 		switch(rfork(RFPROC|RFNOTEG|RFMEM|RFNOWAIT)){
@@ -1310,7 +1296,6 @@
 	char *p;
 	int alpha = 0;
 	int restr = 0;
-	char port[10];
 	Ndbtuple *t, *nt;
 	Ndbs s;
 
@@ -1321,7 +1306,6 @@
 	}
 
 	/*  see if it's numeric or symbolic */
-	port[0] = 0;
 	for(p = name; *p; p++){
 		if(isdigit(*p))
 			{}
--- a/sys/src/cmd/ndb/dblookup.c
+++ b/sys/src/cmd/ndb/dblookup.c
@@ -561,16 +561,6 @@
 	return 0;
 }
 
-static RR**
-linkrr(RR *rp, DN *dp, RR **l)
-{
-	rp->owner = dp;
-	rp->auth = 1;
-	rp->db = 1;
-	*l = rp;
-	return &rp->next;
-}
-
 /* these are answered specially by the tcp version */
 static RR*
 doaxfr(Ndb *db, char *name)
--- a/sys/src/cmd/ndb/dn.c
+++ b/sys/src/cmd/ndb/dn.c
@@ -672,8 +672,6 @@
 void
 putactivity(int recursive)
 {
-	static ulong lastclean;
-
 	if(traceactivity)
 		dnslog("put: %d active by pid %d",
 			dnvars.active, getpid());
@@ -706,7 +704,6 @@
 	dnageall(0);
 
 	/* let others back in */
-	lastclean = now;
 	needrefresh = 0;
 	dnvars.mutex = 0;
 }
--- a/sys/src/cmd/ndb/dnsdebug.c
+++ b/sys/src/cmd/ndb/dnsdebug.c
@@ -13,7 +13,6 @@
 Cfg cfg;
 
 static char *servername;
-static RR *serverrr;
 static RR *serveraddrs;
 
 char	*dbfile;
--- a/sys/src/cmd/plumb/match.c
+++ b/sys/src/cmd/plumb/match.c
@@ -6,14 +6,6 @@
 #include <plumb.h>
 #include "plumber.h"
 
-static char*
-nonnil(char *s)
-{
-	if(s == nil)
-		return "";
-	return s;
-}
-
 int
 verbis(int obj, Plumbmsg *m, Rule *r)
 {
--- a/sys/src/cmd/plumb/rules.c
+++ b/sys/src/cmd/plumb/rules.c
@@ -144,7 +144,7 @@
 getline(void)
 {
 	static int n = 0;
-	static char *s, *incl;
+	static char *s;
 	int c, i;
 
 	i = 0;
--- a/sys/src/cmd/proof/font.c
+++ b/sys/src/cmd/proof/font.c
@@ -10,7 +10,6 @@
 Font	*fonttab[NFONT][NSIZE];	/* pointers to fonts */
 int	fmap[NFONT];		/* what map to use with this font */
 
-static void	bufchar(Point, Subfont *, uchar *);
 static void	loadfont(int, int);
 static void	fontlookup(int, char *);
 static void	buildxheight(Biobuf*);
--- a/sys/src/cmd/proof/htroff.c
+++ b/sys/src/cmd/proof/htroff.c
@@ -44,7 +44,6 @@
 static int	getn(void);
 static int	botpage(int);
 static void	getstr(char *);
-static void	getutf(char *);
 
 #define Do screen->r.min
 #define Dc screen->r.max
@@ -450,24 +449,6 @@
 		;
 	ungetc();
 	*s = 0;
-}
-
-static void
-getutf(char *s)		/* get next utf char, as bytes */
-{
-	int c, i;
-
-	for (i=0;;) {
-		c = getc();
-		if (c < 0)
-			return;
-		s[i++] = c;
-
-		if (fullrune(s, i)) {
-			s[i] = 0;
-			return;
-		}
-	}
 }
 
 static void
--- a/sys/src/cmd/proof/screen.c
+++ b/sys/src/cmd/proof/screen.c
@@ -123,14 +123,6 @@
 
 #define	butcvt(b)	(1 << ((b) - 1))
 
-static int buttondown(void)	/* report state of buttons, if any */
-{
-	if (!ecanmouse())	/* no event pending */
-		return 0;
-	mouse = emouse();	/* something, but it could be motion */
-	return mouse.buttons & 7;
-}
-
 int waitdown(void)	/* wait until some button is down */
 {
 	while (!(mouse.buttons & 7))
--- a/sys/src/cmd/ratfs/proto.c
+++ b/sys/src/cmd/ratfs/proto.c
@@ -11,10 +11,10 @@
 	RNONE,
 };
 
-static void	rflush(Fcall*),		rnop(Fcall*),
+static void	rflush(Fcall*),
 		rauth(Fcall*),	rattach(Fcall*),
 		rclone(Fcall*),		rwalk(Fcall*),
-		rclwalk(Fcall*),	ropen(Fcall*),
+		ropen(Fcall*),
 		rcreate(Fcall*),	rread(Fcall*),
 		rwrite(Fcall*),		rclunk(Fcall*),
 		rremove(Fcall*),	rstat(Fcall*),
--- a/sys/src/cmd/rio/fsys.c
+++ b/sys/src/cmd/rio/fsys.c
@@ -54,7 +54,6 @@
 static	Xfid*	filsysflush(Filsys*, Xfid*, Fid*);
 static	Xfid*	filsysversion(Filsys*, Xfid*, Fid*);
 static	Xfid*	filsysauth(Filsys*, Xfid*, Fid*);
-static	Xfid*	filsysnop(Filsys*, Xfid*, Fid*);
 static	Xfid*	filsysattach(Filsys*, Xfid*, Fid*);
 static	Xfid*	filsyswalk(Filsys*, Xfid*, Fid*);
 static	Xfid*	filsysopen(Filsys*, Xfid*, Fid*);
--- a/sys/src/cmd/rio/rio.c
+++ b/sys/src/cmd/rio/rio.c
@@ -121,7 +121,6 @@
 threadmain(int argc, char *argv[])
 {
 	char *initstr, *kbdin, *s;
-	static void *arg[1];
 	char buf[256];
 	Image *i;
 	Rectangle r;