shithub: drawterm

Download patch

ref: 21b830b1ac2409159dfc3ccea59a6fffab805053
parent: 3c84c725ef4bd925be08518cce59161edf905ca6
author: Russ Cox <rsc@swtch.com>
date: Thu Dec 29 18:15:58 EST 2005

cleanups spotted by irix cc

--- a/exportfs/exportsrv.c
+++ b/exportfs/exportsrv.c
@@ -30,7 +30,6 @@
 	return v;
 }
 
-ulong messagesize;
 
 void
 Xversion(Fsrpc *t)
@@ -392,7 +391,7 @@
 		return;
 	}
 	strings = emallocz(t->work.nstat);	/* ample */
-	if(convM2D(t->work.stat, t->work.nstat, &d, strings) < 0){
+	if(convM2D(t->work.stat, t->work.nstat, &d, strings) <= BIT16SZ){
 		rerrstr(err, sizeof err);
 		reply(&t->work, &rhdr, err);
 		t->busy = 0;
--- a/gui-x11/alloc.c
+++ b/gui-x11/alloc.c
@@ -159,7 +159,6 @@
 	Xmem *xm;
 	XImage *xi;
 	GC g;
-	int offset;
 	Point xdelta, delta;
 	Point tp;
 	int x, y;
@@ -175,10 +174,6 @@
 	xi = xm->xi;
 
 	g = (m->chan == GREY1) ? xgccopy0 : xgccopy;
-	if(m->depth == 24)
-		offset = r.min.x % 4;
-	else
-		offset = m->r.min.x & (31/m->depth);
 
 	delta = subpt(r.min, m->r.min);
 	tp = xm->r.min;	/* avoid unaligned access on digital unix */
--- a/gui-x11/screen.c
+++ b/gui-x11/screen.c
@@ -73,8 +73,6 @@
 Atom text;
 Atom compoundtext;
 
-static	XModifierKeymap *modmap;
-static	int		keypermod;
 static	Drawable	xdrawable;
 /* static	Atom		wm_take_focus; */
 static	void		xexpose(XEvent*);
@@ -288,7 +286,6 @@
 	XSetWindowAttributes attrs;
 	XPixmapFormatValues *pfmt;
 	int n;
-	Memdata *md;
  
 	xscreenid = 0;
 	xdrawable = 0;
@@ -378,14 +375,11 @@
 		initmap(rootwin);
 	}
 
-	if((modmap = XGetModifierMapping(xdisplay)))
-		keypermod = modmap->max_keypermod;
 
 	r.min = ZP;
 	r.max.x = WidthOfScreen(screen);
 	r.max.y = HeightOfScreen(screen);
 
-	md = mallocz(sizeof(Memdata), 1);
 	
 	xsize = Dx(r)*3/4;
 	ysize = Dy(r)*3/4;
@@ -644,11 +638,7 @@
 	if(e->type != MappingNotify)
 		return;
 	xe = (XMappingEvent*)e;
-	if(modmap)
-		XFreeModifiermap(modmap);
-	modmap = XGetModifierMapping(xe->display);
-	if(modmap)
-		keypermod = modmap->max_keypermod;
+	USED(xe);
 }
 
 
--- a/kern/devip-posix.c
+++ b/kern/devip-posix.c
@@ -72,7 +72,7 @@
 void
 so_getsockname(int fd, unsigned long *laddr, unsigned short *lport)
 {
-	uint len;
+	socklen_t len;
 	struct sockaddr_in sin;
 
 	len = sizeof(sin);
@@ -97,7 +97,7 @@
 so_accept(int fd, unsigned long *raddr, unsigned short *rport)
 {
 	int nfd;
-	uint len;
+	socklen_t len;
 	struct sockaddr_in sin;
 
 	len = sizeof(sin);
--- a/kern/posix.c
+++ b/kern/posix.c
@@ -126,6 +126,7 @@
 	/* BUG: leaks Proc */
 	pthread_setspecific(prdakey, 0);
 	pthread_exit(0);
+	return 0;
 }
 
 void
@@ -161,9 +162,13 @@
 void
 randominit(void)
 {
+#ifdef USE_RANDOM
+	srandom(getpid()+fastticks(nil)+ticks());
+#else
 	if((randfd = open("/dev/urandom", OREAD)) < 0)
 	if((randfd = open("/dev/random", OREAD)) < 0)
 		panic("open /dev/random: %r");
+#endif
 }
 
 #undef read
@@ -170,11 +175,19 @@
 ulong
 randomread(void *v, ulong n)
 {
+#ifdef USE_RANDOM
+	int i;
+
+	for(i=0; i<n; i++)
+		((uchar*)v)[i] = random();
+	return n;
+#else
 	int m;
 
 	if((m = read(randfd, v, n)) != n)
 		panic("short read from /dev/random: %d but %d", n, m);
 	return m;
+#endif
 }
 
 #undef time
--- a/kern/qio.c
+++ b/kern/qio.c
@@ -1159,7 +1159,6 @@
 qbwrite(Queue *q, Block *b)
 {
 	int n, dowakeup;
-	Proc *p;
 
 	n = BLEN(b);
 
@@ -1222,10 +1221,11 @@
 
 	/* wakeup anyone consuming at the other end */
 	if(dowakeup){
-		p = wakeup(&q->rr);
+		wakeup(&q->rr);
 
 		/* if we just wokeup a higher priority process, let it run */
 	/*
+		p = wakeup(&q->rr);
 		if(p != nil && p->priority > up->priority)
 			sched();
 	 */
--- a/kern/term.c
+++ b/kern/term.c
@@ -27,10 +27,9 @@
 static Rectangle flushr;
 static Rectangle window;
 static Point curpos;
-static int h, w;
+static int h;
 static void	termscreenputs(char*, int);
 
-Point ZP;
 
 static void
 screenflush(void)
@@ -51,7 +50,7 @@
 static void
 screenwin(void)
 {
-	Point p, q;
+	Point p;
 	char *greet;
 	Memimage *grey;
 
@@ -60,7 +59,6 @@
 	conscol = memblack;
 	memfillcolor(gscreen, 0x444488FF);
 	
-	w = memdefont->info[' '].width;
 	h = memdefont->height;
 
 	window.min = addpt(gscreen->r.min, Pt(20,20));
@@ -83,7 +81,6 @@
 
 	greet = " Plan 9 Console ";
 	p = addpt(window.min, Pt(10, 0));
-	q = memsubfontwidth(memdefont, greet);
 	memimagestring(gscreen, p, conscol, ZP, memdefont, greet);
 	window.min.y += h+6;
 	curpos = window.min;
--- a/libmemdraw/draw.c
+++ b/libmemdraw/draw.c
@@ -308,9 +308,6 @@
  * Conversion tables.
  */
 static uchar replbit[1+8][256];		/* replbit[x][y] is the replication of the x-bit quantity y to 8-bit depth */
-static uchar conv18[256][8];		/* conv18[x][y] is the yth pixel in the depth-1 pixel x */
-static uchar conv28[256][4];		/* ... */
-static uchar conv48[256][2];
 
 /*
  * bitmap of how to replicate n bits to fill 8, for 1 ≤ n ≤ 8.
@@ -344,7 +341,7 @@
 static void
 mktables(void)
 {
-	int i, j, mask, sh, small;
+	int i, j, small;
 		
 	if(tablesbuilt)
 		return;
@@ -361,17 +358,6 @@
 		}
 	}
 
-	/* bit unpacking up to 8 bits, only powers of 2 */
-	for(i=0; i<256; i++){
-		for(j=0, sh=7, mask=1; j<8; j++, sh--)
-			conv18[i][j] = replbit[1][(i>>sh)&mask];
-
-		for(j=0, sh=6, mask=3; j<4; j++, sh-=2)
-			conv28[i][j] = replbit[2][(i>>sh)&mask];
-
-		for(j=0, sh=4, mask=15; j<2; j++, sh-=4)
-			conv48[i][j] = replbit[4][(i>>sh)&mask];
-	}
 }
 
 static uchar ones = 0xff;