shithub: riscv

Download patch

ref: d4bc9052beb3305d64a353a16641740380eb87af
parent: 0af7d1fe35093690f2d8dd0613b3bf3b777674c6
author: Ori Bernstein <[email protected]>
date: Fri Jun 21 06:00:58 EDT 2019

Turn on warnings when building libap.

For ape, we never enabled warnings in cflags.
Turning it on brings up a lot of warnings. Most are noise,
but a few caught unused variables and trunctaions of pointers.
to smaller integers (int, long).

A few warnings remain.

--- a/sys/src/ape/config
+++ b/sys/src/ape/config
@@ -5,7 +5,7 @@
 APELIB=/rc/bin/ape		# where helper programs go
 CC=pcc				# compiler (must be ansi)
 LD=pcc				# loader
-CFLAGS=				# global defaults
+CFLAGS=-Fw			# global defaults
 FAMILY=plan9
 AR=ar				# manipulating libraries
 RANLIB=echo			# for updating libraries
--- a/sys/src/ape/lib/ap/amd64/mkfile
+++ b/sys/src/ape/lib/ap/amd64/mkfile
@@ -16,5 +16,5 @@
 
 </sys/src/cmd/mksyslib
 
-CFLAGS=-c -D_POSIX_SOURCE -D_PLAN9_SOURCE
+CFLAGS=$CFLAGS -c -D_POSIX_SOURCE -D_PLAN9_SOURCE
 
--- a/sys/src/ape/lib/ap/gen/getenv.c
+++ b/sys/src/ape/lib/ap/gen/getenv.c
@@ -6,7 +6,7 @@
 getenv(const char *name)
 {
 	char **p = environ;
-	char *v, *s1, *s2;
+	char *s1, *s2;
 
 	while (*p != NULL){
 		for(s1 = (char *)name, s2 = *p++; *s1 == *s2; s1++, s2++)
--- a/sys/src/ape/lib/ap/gen/memchr.c
+++ b/sys/src/ape/lib/ap/gen/memchr.c
@@ -5,7 +5,7 @@
 {
 	unsigned char *sp;
 
-	sp = ap;
+	sp = (unsigned char*)ap;
 	c &= 0xFF;
 	while(n > 0) {
 		if(*sp++ == c)
--- a/sys/src/ape/lib/ap/gen/memcmp.c
+++ b/sys/src/ape/lib/ap/gen/memcmp.c
@@ -6,8 +6,8 @@
 	char *s1, *s2;
 	unsigned c1, c2;
 
-	s1 = a1;
-	s2 = a2;
+	s1 = (char*)a1;
+	s2 = (char*)a2;
 	while(n > 0) {
 		c1 = *s1++;
 		c2 = *s2++;
--- a/sys/src/ape/lib/ap/gen/memmove.c
+++ b/sys/src/ape/lib/ap/gen/memmove.c
@@ -11,7 +11,7 @@
 	if(a1 > a2)
 		goto back;
 	s1 = a1;
-	s2 = a2;
+	s2 = (char*)a2;
 	while(n > 0) {
 		*s1++ = *s2++;
 		n--;
--- a/sys/src/ape/lib/ap/gen/mkfile
+++ b/sys/src/ape/lib/ap/gen/mkfile
@@ -63,4 +63,4 @@
 
 </sys/src/cmd/mksyslib
 
-CFLAGS=-c -D_POSIX_SOURCE
+CFLAGS=$CFLAGS -c -D_POSIX_SOURCE
--- a/sys/src/ape/lib/ap/gen/putenv.c
+++ b/sys/src/ape/lib/ap/gen/putenv.c
@@ -9,9 +9,9 @@
 	int n;
 
 	for(n = 0; s2 = environ[n]; n++)
-		for(s1 = str; *s1 == *s2; s1++, s2++)
+		for(s1 = (char *)str; *s1 == *s2; s1++, s2++)
 			if(*s1 == '\0' || *s1 == '='){
-				environ[n] = str;
+				environ[n] = (char*)str;
 				return 0;
 			}
 	e = realloc(environ, (n+1) * sizeof(char*));
@@ -18,7 +18,7 @@
 	if(e == 0)
 		return -1;
 	environ = e;
-	e[n++] = str;
+	e[n++] = (char*)str;
 	e[n] = 0;
 	return 0;
 }
--- a/sys/src/ape/lib/ap/gen/rand.c
+++ b/sys/src/ape/lib/ap/gen/rand.c
@@ -27,8 +27,6 @@
 	rng_tap = rng_vec;
 	rng_feed = rng_vec+LEN-TAP;
 	seed = seed%M;
-	if(seed < 0)
-		seed += M;
 	if(seed == 0)
 		seed = 89482311;
 	x = seed;
--- a/sys/src/ape/lib/ap/gen/strcspn.c
+++ b/sys/src/ape/lib/ap/gen/strcspn.c
@@ -13,7 +13,7 @@
 		if(*b++ == 0)
 			break;
 	}
-	os = s;
+	os = (char*)s;
 	while(map[*(unsigned char*)s++] == 0)
 		;
 	return s - os - 1;
--- a/sys/src/ape/lib/ap/gen/strpbrk.c
+++ b/sys/src/ape/lib/ap/gen/strpbrk.c
@@ -15,6 +15,6 @@
 	while(map[*s++] == 0)
 		;
 	if(*--s)
-		return s;
+		return (char*)s;
 	return 0;
 }
--- a/sys/src/ape/lib/ap/gen/strrchr.c
+++ b/sys/src/ape/lib/ap/gen/strrchr.c
@@ -9,6 +9,6 @@
 		return strchr(s, 0);
 	r = 0;
 	while(s = strchr(s, c))
-		r = s++;
+		r = (char*)s++;
 	return r;
 }
--- a/sys/src/ape/lib/ap/gen/strspn.c
+++ b/sys/src/ape/lib/ap/gen/strspn.c
@@ -10,7 +10,7 @@
 	memset(map, 0, N);
 	while(*b)
 		map[*(unsigned char *)b++] = 1;
-	os = s;
+	os = (char*)s;
 	while(map[*(unsigned char *)s++])
 		;
 	return s - os - 1;
--- a/sys/src/ape/lib/ap/gen/strstr.c
+++ b/sys/src/ape/lib/ap/gen/strstr.c
@@ -2,8 +2,8 @@
 
 /* Return pointer to first occurrence of s2 in s1, NULL if none */
 
-char
-*strstr(const char *s1, const char *s2)
+char*
+strstr(const char *s1, const char *s2)
 {
 	char *p, *pa, *pb;
 	int c0, c;
@@ -10,11 +10,11 @@
 
 	c0 = *s2;
 	if(c0 == 0)
-		return s1;
+		return (char *)s1;
 	s2++;
 	for(p=strchr(s1, c0); p; p=strchr(p+1, c0)) {
 		pa = p;
-		for(pb=s2;; pb++) {
+		for(pb=(char*)s2;; pb++) {
 			c = *pb;
 			if(c == 0)
 				return p;
--- a/sys/src/ape/lib/ap/math/mkfile
+++ b/sys/src/ape/lib/ap/math/mkfile
@@ -25,4 +25,4 @@
 
 </sys/src/cmd/mksyslib
 
-CFLAGS=-c -D_POSIX_SOURCE
+CFLAGS=$CFLAGS -c -D_POSIX_SOURCE
--- a/sys/src/ape/lib/ap/plan9/_buf.c
+++ b/sys/src/ape/lib/ap/plan9/_buf.c
@@ -2,6 +2,7 @@
 #define _LOCK_EXTENSION
 #include "lib.h"
 #include <stdlib.h>
+#include <stdint.h>
 #include <errno.h>
 #include <unistd.h>
 #include <signal.h>
@@ -57,7 +58,7 @@
 	if(mux == 0){
 		_RFORK(RFREND);
 		mux = (Muxseg*)_SEGATTACH(0, "shared", 0, sizeof(Muxseg));
-		if((long)mux == -1){
+		if(mux == (void*)-1){
 			_syserrno();
 			return -1;
 		}
@@ -124,7 +125,7 @@
 
 	while((v = _RENDEZVOUS(&b->copypid, 0)) == (void*)~0)
 		;
-	_muxsid = (int)v;
+	_muxsid = (uintptr_t)v;
 
 	/* leave fd open in parent so system doesn't reuse it */
 	return 0;
@@ -182,6 +183,7 @@
 		 * happened, or it might mean eof; try several times to
 		 * disambiguate (posix read() discards 0-length messages)
 		 */
+		n = 0;
 		nzeros = 0;
 		do {
 			if(b->fd != fd)
@@ -395,7 +397,7 @@
 	}
 	mux->selwait = 1;
 	unlock(&mux->lock);
-	fd = (int)_RENDEZVOUS(&mux->selwait, 0);
+	fd = (int)(uintptr_t)_RENDEZVOUS(&mux->selwait, 0);
 	if(fd >= 0 && fd < nfds) {
 		b = _fdinfo[fd].buf;
 		if(b == 0 || b->fd != fd) {
@@ -504,7 +506,7 @@
 }
 
 static int
-copynotehandler(void *u, char *msg)
+copynotehandler(void *, char *)
 {
 	if(_finishing)
 		_finish(0, 0);
--- a/sys/src/ape/lib/ap/plan9/_envsetup.c
+++ b/sys/src/ape/lib/ap/plan9/_envsetup.c
@@ -40,6 +40,8 @@
 	char **pp;
 	Dir *d9, *d9a;
 
+	ps = 0;
+	psize = 0;
 	nohandle = 0;
 	fdinited = 0;
 	cnt = 0;
--- a/sys/src/ape/lib/ap/plan9/_getpw.c
+++ b/sys/src/ape/lib/ap/plan9/_getpw.c
@@ -59,6 +59,7 @@
 			return 0;
 		au[n] = 0;
 	}
+	mem = nil;
 	matchnum = (*pname == NULL);
 	matched = 0;
 	/* try using memo */
@@ -68,9 +69,8 @@
 			matched = (mem->num == *pnum);
 		else
 			matched = (strcmp(mem->name, *pname) == 0);
-		if(matched) {
+		if(matched)
 			break;
-		}
 	}
 	if(!matched)
 		for(f1 = au, eline = au; !matched && *eline; f1 = eline+1){
--- a/sys/src/ape/lib/ap/plan9/brk.c
+++ b/sys/src/ape/lib/ap/plan9/brk.c
@@ -1,5 +1,6 @@
 #include "lib.h"
 #include <errno.h>
+#include <stdint.h>
 #include "sys9.h"
 
 char	end[];
@@ -11,7 +12,7 @@
 {
 	unsigned long n;
 
-	n = (unsigned long)p;
+	n = (uintptr_t)p;
 	n += 3;
 	n &= ~3;
 	if(_BRK_((void*)n) < 0){
--- a/sys/src/ape/lib/ap/plan9/cfgetospeed.c
+++ b/sys/src/ape/lib/ap/plan9/cfgetospeed.c
@@ -1,25 +1,25 @@
 #include <termios.h>
 
 speed_t
-cfgetospeed(const struct termios *p)
+cfgetospeed(const struct termios *)
 {
 	return B0;
 }
 
 int
-cfsetospeed(struct termios *p, speed_t s)
+cfsetospeed(struct termios *, speed_t)
 {
 	return 0;
 }
 
 speed_t
-cfgetispeed(const struct termios *p)
+cfgetispeed(const struct termios *)
 {
 	return B0;
 }
 
 int
-cfsetispeed(struct termios *p, speed_t s)
+cfsetispeed(struct termios *, speed_t)
 {
 	return 0;
 }
--- a/sys/src/ape/lib/ap/plan9/execle.c
+++ b/sys/src/ape/lib/ap/plan9/execle.c
@@ -1,7 +1,7 @@
 #include <unistd.h>
 
 int
-execle(const char *name, const char *arg0, const char *aore, ...)
+execle(const char *name, const char *arg0, const char *, ...)
 {
 	char *p;
 
--- a/sys/src/ape/lib/ap/plan9/execve.c
+++ b/sys/src/ape/lib/ap/plan9/execve.c
@@ -85,7 +85,7 @@
 		_CLOSE(f);
 	}
 	if(envp){
-		for(e = envp; (ss = *e); e++) {
+		for(e = (char**)envp; (ss = *e); e++) {
 			se = strchr(ss, '=');
 			if(!se || ss==se)
 				continue;	/* what is name? value? */
--- a/sys/src/ape/lib/ap/plan9/fsync.c
+++ b/sys/src/ape/lib/ap/plan9/fsync.c
@@ -3,7 +3,7 @@
 #include <errno.h>
 
 int
-fsync(int fd)
+fsync(int)
 {
 	errno = EINVAL;
 	return -1;
--- a/sys/src/ape/lib/ap/plan9/getgrnam.c
+++ b/sys/src/ape/lib/ap/plan9/getgrnam.c
@@ -13,7 +13,7 @@
 	char *nam, *mem;
 
 	num = 0;
-	nam = name;
+	nam = (char *)name;
 	mem = 0;
 	if(_getpw(&num, &nam, &mem)){
 		holdgroup.gr_name = nam;
--- a/sys/src/ape/lib/ap/plan9/getgroups.c
+++ b/sys/src/ape/lib/ap/plan9/getgroups.c
@@ -3,7 +3,7 @@
 #include <errno.h>
 
 int
-getgroups(int gidsize, gid_t grouplist[])
+getgroups(int, gid_t*)
 {
 	errno = EINVAL;
 	return -1;
--- a/sys/src/ape/lib/ap/plan9/getpwnam.c
+++ b/sys/src/ape/lib/ap/plan9/getpwnam.c
@@ -14,7 +14,7 @@
 	char *nam, *mem;
 
 	num = 0;
-	nam = name;
+	nam = (char*)name;
 	mem = 0;
 	if(_getpw(&num, &nam, &mem)){
 		holdpw.pw_name = nam;
--- a/sys/src/ape/lib/ap/plan9/link.c
+++ b/sys/src/ape/lib/ap/plan9/link.c
@@ -5,7 +5,7 @@
  * BUG: LINK_MAX==1 isn't really allowed
  */
 int
-link(const char *name1, const char *name2)
+link(const char *, const char *)
 {
 	errno = EMLINK;
 	return -1;
--- a/sys/src/ape/lib/ap/plan9/mkfile
+++ b/sys/src/ape/lib/ap/plan9/mkfile
@@ -107,6 +107,6 @@
 
 </sys/src/cmd/mksyslib
 
-CFLAGS=-c -D_POSIX_SOURCE -D_PLAN9_SOURCE -D_BSD_EXTENSION
+CFLAGS=$CFLAGS -c -D_POSIX_SOURCE -D_PLAN9_SOURCE -D_BSD_EXTENSION
 
 $OFILES: lib.h
--- a/sys/src/ape/lib/ap/plan9/opendir.c
+++ b/sys/src/ape/lib/ap/plan9/opendir.c
@@ -26,7 +26,7 @@
 		s[n++] = '/';
 		s[n] = 0;
 	} else
-		s = filename;
+		s = (char*)filename;
 	f = open(s, O_RDONLY);
 	if(s != filename)
 		free(s);
--- a/sys/src/ape/lib/ap/plan9/pause.c
+++ b/sys/src/ape/lib/ap/plan9/pause.c
@@ -7,5 +7,5 @@
 {
 	for(;;)
 		if(_SLEEP(1000*1000) < 0)
-			return;
+			return -1;
 }
--- a/sys/src/ape/lib/ap/plan9/read.c
+++ b/sys/src/ape/lib/ap/plan9/read.c
@@ -12,7 +12,7 @@
 	int n, noblock, isbuf;
 	Fdinfo *f;
 
-	if(d<0 || d>=OPEN_MAX || !((f = &_fdinfo[d])->flags&FD_ISOPEN)){
+	if(d<0 || d>=OPEN_MAX || !(_fdinfo[d].flags & FD_ISOPEN)){
 		errno = EBADF;
 		return -1;
 	}
--- a/sys/src/ape/lib/ap/plan9/rename.c
+++ b/sys/src/ape/lib/ap/plan9/rename.c
@@ -10,7 +10,7 @@
 int
 rename(const char *from, const char *to)
 {
-	int n, i;
+	int n, ffd, tfd;
 	char *f, *t;
 	Dir *d, nd;
 
@@ -31,45 +31,45 @@
 	}
 	f = strrchr(from, '/');
 	t = strrchr(to, '/');
-	f = f? f+1 : from;
-	t = t? t+1 : to;
-	n = 0;
+	f = f? f+1 : (char*)from;
+	t = t? t+1 : (char*)to;
 	if(f-from==t-to && strncmp(from, to, f-from)==0){
 		/* from and to are in same directory (we miss some cases) */
-		i = strlen(t);
 		_nulldir(&nd);
 		nd.name = t;
 		if(_dirwstat(from, &nd) < 0){
 			_syserrno();
-			n = -1;
+			return -1;
 		}
 	}else{
 		/* different directories: have to copy */
-		int ffd, tfd;
 		char buf[8192];
 
-		if((ffd = _OPEN(from, OREAD)) < 0 ||
-		   (tfd = _CREATE(to, OWRITE, d->mode)) < 0){
-			_CLOSE(ffd);
-			_syserrno();
-			n = -1;
+
+		if((ffd = _OPEN(from, OREAD)) == -1)
+			goto err1;
+		if((tfd = _CREATE(to, OWRITE, d->mode)) == -1)
+			goto err2;
+		n = 0;
+		while(n>=0){
+			if((n = _READ(ffd, buf, sizeof(buf))) == -1)
+				goto err2;
+			if(_WRITE(tfd, buf, n) != n)
+				goto err2;
 		}
-		while(n>=0 && (n = _READ(ffd, buf, sizeof(buf))) > 0)
-			if(_WRITE(tfd, buf, n) != n){
-				_syserrno();
-				n = -1;
-			}
 		_CLOSE(ffd);
 		_CLOSE(tfd);
-		if(n>0)
-			n = 0;
-		if(n == 0) {
-			if(_REMOVE(from) < 0){
-				_syserrno();
-				return -1;
-			}
-		}
+		if(_REMOVE(from) < 0)
+			goto err2;
 	}
 	free(d);
-	return n;
+	return 0;
+
+err2:
+	_CLOSE(tfd);
+err1:
+	_CLOSE(ffd);
+	_syserrno();
+	free(d);
+	return -1;
 }
--- a/sys/src/ape/lib/ap/plan9/setgid.c
+++ b/sys/src/ape/lib/ap/plan9/setgid.c
@@ -7,7 +7,7 @@
  */
 
 int
-setgid(gid_t gid)
+setgid(gid_t)
 {
 	errno = EPERM;
 	return -1;
--- a/sys/src/ape/lib/ap/plan9/setuid.c
+++ b/sys/src/ape/lib/ap/plan9/setuid.c
@@ -7,7 +7,7 @@
  */
 
 int
-setuid(uid_t uid)
+setuid(uid_t)
 {
 	errno = EPERM;
 	return -1;
--- a/sys/src/ape/lib/ap/plan9/signal.c
+++ b/sys/src/ape/lib/ap/plan9/signal.c
@@ -107,7 +107,7 @@
 				/* notetramp is machine-dependent; doesn't return to here */
 			}
 			_NOTED(0); /* NCONT */
-			return;
+			return 0;
 		}
 	}
 	_doatexits();
--- a/sys/src/ape/lib/ap/plan9/sigsuspend.c
+++ b/sys/src/ape/lib/ap/plan9/sigsuspend.c
@@ -6,7 +6,7 @@
  */
 
 int
-sigsuspend(sigset_t *set)
+sigsuspend(sigset_t *)
 {
 	errno = EINVAL;
 	return -1;
--- a/sys/src/ape/lib/ap/plan9/tcgetattr.c
+++ b/sys/src/ape/lib/ap/plan9/tcgetattr.c
@@ -87,7 +87,7 @@
 /* BUG: ignores optional actions */
 
 int
-tcsetattr(int fd, int optactions, const struct termios *t)
+tcsetattr(int fd, int, const struct termios *t)
 {
 	int n, i;
 	char buf[100];
--- a/sys/src/ape/lib/ap/plan9/umask.c
+++ b/sys/src/ape/lib/ap/plan9/umask.c
@@ -7,7 +7,7 @@
  */
 
 mode_t
-umask(mode_t numask)
+umask(mode_t)
 {
 	return 0;
 }
--- a/sys/src/ape/lib/ap/plan9/unlink.c
+++ b/sys/src/ape/lib/ap/plan9/unlink.c
@@ -26,6 +26,7 @@
 		_syserrno();
 		return -1;
 	}
+	n = -1;
 	fd = -1;
 	for(i=0, f = _fdinfo;i < OPEN_MAX; i++, f++) {
 		if((f->flags&FD_ISOPEN) && (db2=_dirfstat(i)) != nil) {
--- a/sys/src/ape/lib/ap/posix/getpwent.c
+++ b/sys/src/ape/lib/ap/posix/getpwent.c
@@ -49,7 +49,7 @@
 	passwd.pw_dir = p;
 	p = pwskip(p);
 	passwd.pw_shell = p;
-	p = pwskip(p);
+	pwskip(p);
 	return(&passwd);
 }
 
--- a/sys/src/ape/lib/ap/posix/mkfifo.c
+++ b/sys/src/ape/lib/ap/posix/mkfifo.c
@@ -3,7 +3,7 @@
 #include	<errno.h>
 
 int
-mkfifo(char *path, mode_t mode)
+mkfifo(char *, mode_t)
 {
 #pragma ref path
 #pragma ref mode
--- a/sys/src/ape/lib/ap/posix/mkfile
+++ b/sys/src/ape/lib/ap/posix/mkfile
@@ -14,4 +14,4 @@
 
 </sys/src/cmd/mksyslib
 
-CFLAGS=-c -D_POSIX_SOURCE
+CFLAGS=$CFLAGS -c -D_POSIX_SOURCE
--- a/sys/src/ape/lib/ap/posix/pathconf.c
+++ b/sys/src/ape/lib/ap/posix/pathconf.c
@@ -4,7 +4,7 @@
 #include	<sys/limits.h>
 
 long
-pathconf(const char *path, int name)
+pathconf(const char *, int name)
 {
 #pragma ref path
 
@@ -46,10 +46,8 @@
 }
 
 long
-fpathconf(int fd, int name)
+fpathconf(int, int name)
 {
-#pragma ref fd
-
 	return pathconf(0, name);
 }
 
--- a/sys/src/ape/lib/ap/posix/tzset.c
+++ b/sys/src/ape/lib/ap/posix/tzset.c
@@ -20,6 +20,7 @@
 {
 	char *env, *p, *q;
 	
+	env = NULL;
 	if((p = getenv("timezone")) == 0)
 		goto error;
 	if((env = malloc(strlen(p) + 1)) == 0)
--- a/sys/src/ape/lib/ap/stdio/_fconv.c
+++ b/sys/src/ape/lib/ap/stdio/_fconv.c
@@ -509,7 +509,7 @@
 			}
 		else
 			x[0] = y;
-		i = b->wds = (x[1] = z) ? 2 : 1;
+		b->wds = (x[1] = z) ? 2 : 1;
 		}
 	else {
 #ifdef DEBUG
@@ -518,7 +518,7 @@
 #endif
 		k = lo0bits(&z);
 		x[0] = z;
-		i = b->wds = 1;
+		b->wds = 1;
 		k += 32;
 		}
 #else
--- a/sys/src/ape/lib/ap/stdio/ftoa.c
+++ b/sys/src/ape/lib/ap/stdio/ftoa.c
@@ -27,7 +27,7 @@
 		e1=e/2;
 		e2=e-e1;
 		p=f*pow10(e2);
-		while((g=p*pow10(e1))<1.) e1++;
+		while((p*pow10(e1))<1.) e1++;
 		while((g=p*pow10(e1))>=10.) --e1;
 		e=e1+e2;
 		f=g;
--- a/sys/src/ape/lib/ap/stdio/mkfile
+++ b/sys/src/ape/lib/ap/stdio/mkfile
@@ -66,4 +66,4 @@
 
 </sys/src/cmd/mksyslib
 
-CFLAGS=-c -D_POSIX_SOURCE
+CFLAGS=$CFLAGS -c -D_POSIX_SOURCE
--- a/sys/src/ape/lib/ap/stdio/vfprintf.c
+++ b/sys/src/ape/lib/ap/stdio/vfprintf.c
@@ -3,6 +3,7 @@
  */
 #include "iolib.h"
 #include <stdarg.h>
+#include <stdint.h>
 #include <math.h>
 #include <stdlib.h>
 #include <string.h>
@@ -218,9 +219,8 @@
 }
 
 static int
-ocvt_c(FILE *f, va_list *args, int flags, int width, int precision)
+ocvt_c(FILE *f, va_list *args, int flags, int width, int)
 {
-#pragma ref precision
 	int i;
 
 	if(!(flags&LEFT)) for(i=1; i<width; i++) putc(' ', f);
@@ -269,11 +269,8 @@
 }
 
 static int
-ocvt_n(FILE *f, va_list *args, int flags, int width, int precision)
+ocvt_n(FILE *, va_list *args, int flags, int, int)
 {
-#pragma ref f
-#pragma ref width
-#pragma ref precision
 	if(flags&SHORT)
 		*va_arg(*args, short *) = nprint;
 	else if(flags&LONG)
@@ -307,7 +304,7 @@
 	int nout, npad, nlzero;
 
 	if(sgned){
-		if(flags&PTR) snum = (long)va_arg(*args, void *);
+		if(flags&PTR) snum = (uintptr_t)va_arg(*args, void *);
 		else if(flags&SHORT) snum = va_arg(*args, short);
 		else if(flags&LONG) snum = va_arg(*args, long);
 		else if(flags&VLONG) snum = va_arg(*args, long long);
@@ -323,7 +320,7 @@
 		}
 	} else {
 		sign = "";
-		if(flags&PTR) num = (long)va_arg(*args, void *);
+		if(flags&PTR) num = (uintptr_t)va_arg(*args, void *);
 		else if(flags&SHORT) num = va_arg(*args, unsigned short);
 		else if(flags&LONG) num = va_arg(*args, unsigned long);
 		else if(flags&VLONG) num = va_arg(*args, unsigned long long);
--- a/sys/src/ape/lib/ap/stdio/vfscanf.c
+++ b/sys/src/ape/lib/ap/stdio/vfscanf.c
@@ -60,7 +60,8 @@
 static int nread, ncvt;
 static const char *fmtp;
 
-int vfscanf(FILE *f, const char *s, va_list args){
+int vfscanf(FILE *f, const char *s, va_list args)
+{
 	int c, width, type, store;
 	nread=0;
 	ncvt=0;
@@ -105,9 +106,10 @@
 	}
 	return ncvt;	
 }
-static int icvt_n(FILE *f, va_list *args, int store, int width, int type){
-#pragma ref f
-#pragma ref width
+
+static int
+icvt_n(FILE *, va_list *args, int store, int, int type)
+{
 	if(store){
 		--ncvt;	/* this assignment doesn't count! */
 		switch(type){
@@ -119,6 +121,7 @@
 	}
 	return 1;
 }
+
 #define	SIGNED		1
 #define	UNSIGNED	2
 #define	POINTER		3
@@ -132,7 +135,8 @@
  *	unsgned is SIGNED, UNSIGNED or POINTER, giving part of the type to store in;
  *	base is the number base -- if 0, C number syntax is used.
  */
-static int icvt_fixed(FILE *f, va_list *args,
+static int
+icvt_fixed(FILE *f, va_list *args,
 				int store, int width, int type, int unsgned, int base){
 	unsigned long int num=0;
 	int sign=1, ndig=0, dig;
@@ -211,26 +215,46 @@
 	}
 	return 1;
 }
-static int icvt_d(FILE *f, va_list *args, int store, int width, int type){
+
+static int
+icvt_d(FILE *f, va_list *args, int store, int width, int type)
+{
 	return icvt_fixed(f, args, store, width, type, SIGNED, 10);
 }
-static int icvt_x(FILE *f, va_list *args, int store, int width, int type){
+
+static int
+icvt_x(FILE *f, va_list *args, int store, int width, int type)
+{
 	return icvt_fixed(f, args, store, width, type, UNSIGNED, 16);
 }
-static int icvt_o(FILE *f, va_list *args, int store, int width, int type){
+
+static int
+icvt_o(FILE *f, va_list *args, int store, int width, int type)
+{
 	return icvt_fixed(f, args, store, width, type, UNSIGNED, 8);
 }
-static int icvt_i(FILE *f, va_list *args, int store, int width, int type){
+
+static int
+icvt_i(FILE *f, va_list *args, int store, int width, int type)
+{
 	return icvt_fixed(f, args, store, width, type, SIGNED, 0);
 }
-static int icvt_u(FILE *f, va_list *args, int store, int width, int type){
+
+static int
+icvt_u(FILE *f, va_list *args, int store, int width, int type)
+{
 	return icvt_fixed(f, args, store, width, type, UNSIGNED, 10);
 }
-static int icvt_p(FILE *f, va_list *args, int store, int width, int type){
+
+static int
+icvt_p(FILE *f, va_list *args, int store, int width, int type)
+{
 	return icvt_fixed(f, args, store, width, type, POINTER, 16);
 }
 #define	NBUF	509
-static int icvt_f(FILE *f, va_list *args, int store, int width, int type){
+static int
+icvt_f(FILE *f, va_list *args, int store, int width, int type)
+{
 	char buf[NBUF+1];
 	char *s=buf;
 	int c, ndig=0, ndpt=0, nexp=1;
@@ -278,11 +302,16 @@
 	}
 	return 1;
 }
-static int icvt_s(FILE *f, va_list *args, int store, int width, int type){
-#pragma ref type
+
+static int
+icvt_s(FILE *f, va_list *args, int store, int width, int)
+{
 	int c, nn;
-	register char *s;
-	if(store) s=va_arg(*args, char *);
+	char *s;
+
+	s = 0;
+	if(store)
+		s=va_arg(*args, char *);
 	do
 		c=ngetc(f);
 	while(isspace(c));
@@ -298,7 +327,8 @@
 			else goto Done;
 		}
 		nn++;
-		if(store) *s++=c;
+		if(store)
+			*s++=c;
 		wgetc(c, f, Done);
 	}
 	nungetc(c, f);
@@ -306,21 +336,27 @@
 	if(store) *s='\0';
 	return 1;
 }
-static int icvt_c(FILE *f, va_list *args, int store, int width, int type){
-#pragma ref type
+static int
+icvt_c(FILE *f, va_list *args, int store, int width, int)
+{
 	int c;
-	register char *s;
-	if(store) s=va_arg(*args, char *);
+	char *s;
+
+	s = 0;
+	if(store)
+		s=va_arg(*args, char *);
 	if(width<0) width=1;
 	for(;;){
 		wgetc(c, f, Done);
 		if(c==EOF) return 0;
-		if(store) *s++=c;
+		if(store)
+			*s++=c;
 	}
 Done:
 	return 1;
 }
-static int match(int c, const char *pat){
+static int match(int c, const char *pat)
+{
 	int ok=1;
 	if(*pat=='^'){
 		ok=!ok;
@@ -338,16 +374,20 @@
 	}
 	return !ok;
 }
-static int icvt_sq(FILE *f, va_list *args, int store, int width, int type){
-#pragma ref type
+static int
+icvt_sq(FILE *f, va_list *args, int store, int width, int)
+{
 	int c, nn;
-	register char *s;
-	register const char *pat;
-	pat=++fmtp;
+	char *s;
+	char *pat;
+
+	s = 0;
+	pat=(char*)++fmtp;
 	if(*fmtp=='^') fmtp++;
 	if(*fmtp!='\0') fmtp++;
 	while(*fmtp!='\0' && *fmtp!=']') fmtp++;
-	if(store) s=va_arg(*args, char *);
+	if(store)
+		s=va_arg(*args, char *);
 	nn=0;
 	for(;;){
 		wgetc(c, f, Done);
@@ -356,8 +396,10 @@
 			if(nn==0) return 0;
 			else goto Done;
 		}
-		if(!match(c, pat)) break;
-		if(store) *s++=c;
+		if(!match(c, pat))
+			break;
+		if(store)
+			*s++=c;
 		nn++;
 	}
 	nungetc(c, f);