summaryrefslogtreecommitdiff
path: root/sys/src/ape
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2019-06-21 10:00:58 -0700
committerOri Bernstein <ori@eigenstate.org>2019-06-21 10:00:58 -0700
commitd4bc9052beb3305d64a353a16641740380eb87af (patch)
treee90babcf3b3b295d9ad218cbf8f4e852df7e6d89 /sys/src/ape
parent0af7d1fe35093690f2d8dd0613b3bf3b777674c6 (diff)
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.
Diffstat (limited to 'sys/src/ape')
-rw-r--r--sys/src/ape/config2
-rw-r--r--sys/src/ape/lib/ap/amd64/mkfile2
-rw-r--r--sys/src/ape/lib/ap/gen/getenv.c2
-rw-r--r--sys/src/ape/lib/ap/gen/memchr.c2
-rw-r--r--sys/src/ape/lib/ap/gen/memcmp.c4
-rw-r--r--sys/src/ape/lib/ap/gen/memmove.c2
-rw-r--r--sys/src/ape/lib/ap/gen/mkfile2
-rw-r--r--sys/src/ape/lib/ap/gen/putenv.c6
-rw-r--r--sys/src/ape/lib/ap/gen/rand.c2
-rw-r--r--sys/src/ape/lib/ap/gen/strcspn.c2
-rw-r--r--sys/src/ape/lib/ap/gen/strpbrk.c2
-rw-r--r--sys/src/ape/lib/ap/gen/strrchr.c2
-rw-r--r--sys/src/ape/lib/ap/gen/strspn.c2
-rw-r--r--sys/src/ape/lib/ap/gen/strstr.c8
-rw-r--r--sys/src/ape/lib/ap/math/mkfile2
-rw-r--r--sys/src/ape/lib/ap/plan9/_buf.c10
-rw-r--r--sys/src/ape/lib/ap/plan9/_envsetup.c2
-rw-r--r--sys/src/ape/lib/ap/plan9/_getpw.c4
-rw-r--r--sys/src/ape/lib/ap/plan9/brk.c3
-rw-r--r--sys/src/ape/lib/ap/plan9/cfgetospeed.c8
-rw-r--r--sys/src/ape/lib/ap/plan9/execle.c2
-rw-r--r--sys/src/ape/lib/ap/plan9/execve.c2
-rw-r--r--sys/src/ape/lib/ap/plan9/fsync.c2
-rw-r--r--sys/src/ape/lib/ap/plan9/getgrnam.c2
-rw-r--r--sys/src/ape/lib/ap/plan9/getgroups.c2
-rw-r--r--sys/src/ape/lib/ap/plan9/getpwnam.c2
-rw-r--r--sys/src/ape/lib/ap/plan9/link.c2
-rw-r--r--sys/src/ape/lib/ap/plan9/mkfile2
-rw-r--r--sys/src/ape/lib/ap/plan9/opendir.c2
-rw-r--r--sys/src/ape/lib/ap/plan9/pause.c2
-rw-r--r--sys/src/ape/lib/ap/plan9/read.c2
-rw-r--r--sys/src/ape/lib/ap/plan9/rename.c52
-rw-r--r--sys/src/ape/lib/ap/plan9/setgid.c2
-rw-r--r--sys/src/ape/lib/ap/plan9/setuid.c2
-rw-r--r--sys/src/ape/lib/ap/plan9/signal.c2
-rw-r--r--sys/src/ape/lib/ap/plan9/sigsuspend.c2
-rw-r--r--sys/src/ape/lib/ap/plan9/tcgetattr.c2
-rw-r--r--sys/src/ape/lib/ap/plan9/umask.c2
-rw-r--r--sys/src/ape/lib/ap/plan9/unlink.c1
-rw-r--r--sys/src/ape/lib/ap/posix/getpwent.c2
-rw-r--r--sys/src/ape/lib/ap/posix/mkfifo.c2
-rw-r--r--sys/src/ape/lib/ap/posix/mkfile2
-rw-r--r--sys/src/ape/lib/ap/posix/pathconf.c6
-rw-r--r--sys/src/ape/lib/ap/posix/tzset.c1
-rw-r--r--sys/src/ape/lib/ap/stdio/_fconv.c4
-rw-r--r--sys/src/ape/lib/ap/stdio/ftoa.c2
-rw-r--r--sys/src/ape/lib/ap/stdio/mkfile2
-rw-r--r--sys/src/ape/lib/ap/stdio/vfprintf.c13
-rw-r--r--sys/src/ape/lib/ap/stdio/vfscanf.c104
49 files changed, 168 insertions, 126 deletions
diff --git a/sys/src/ape/config b/sys/src/ape/config
index ee135fc74..0a370d997 100644
--- a/sys/src/ape/config
+++ b/sys/src/ape/config
@@ -5,7 +5,7 @@ APEBIN=/$objtype/bin/ape # where installed ape binaries go
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
diff --git a/sys/src/ape/lib/ap/amd64/mkfile b/sys/src/ape/lib/ap/amd64/mkfile
index 5bb7f3271..8f1d89824 100644
--- a/sys/src/ape/lib/ap/amd64/mkfile
+++ b/sys/src/ape/lib/ap/amd64/mkfile
@@ -16,5 +16,5 @@ OFILES=\
</sys/src/cmd/mksyslib
-CFLAGS=-c -D_POSIX_SOURCE -D_PLAN9_SOURCE
+CFLAGS=$CFLAGS -c -D_POSIX_SOURCE -D_PLAN9_SOURCE
diff --git a/sys/src/ape/lib/ap/gen/getenv.c b/sys/src/ape/lib/ap/gen/getenv.c
index e911d3298..6ff0df06f 100644
--- a/sys/src/ape/lib/ap/gen/getenv.c
+++ b/sys/src/ape/lib/ap/gen/getenv.c
@@ -6,7 +6,7 @@ char *
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++)
diff --git a/sys/src/ape/lib/ap/gen/memchr.c b/sys/src/ape/lib/ap/gen/memchr.c
index e63aefe8e..dbe440d66 100644
--- a/sys/src/ape/lib/ap/gen/memchr.c
+++ b/sys/src/ape/lib/ap/gen/memchr.c
@@ -5,7 +5,7 @@ memchr(const void *ap, int c, size_t n)
{
unsigned char *sp;
- sp = ap;
+ sp = (unsigned char*)ap;
c &= 0xFF;
while(n > 0) {
if(*sp++ == c)
diff --git a/sys/src/ape/lib/ap/gen/memcmp.c b/sys/src/ape/lib/ap/gen/memcmp.c
index c07fbd0e9..e94ed8052 100644
--- a/sys/src/ape/lib/ap/gen/memcmp.c
+++ b/sys/src/ape/lib/ap/gen/memcmp.c
@@ -6,8 +6,8 @@ memcmp(const void *a1, const void *a2, size_t n)
char *s1, *s2;
unsigned c1, c2;
- s1 = a1;
- s2 = a2;
+ s1 = (char*)a1;
+ s2 = (char*)a2;
while(n > 0) {
c1 = *s1++;
c2 = *s2++;
diff --git a/sys/src/ape/lib/ap/gen/memmove.c b/sys/src/ape/lib/ap/gen/memmove.c
index 7eec93f68..1dacece35 100644
--- a/sys/src/ape/lib/ap/gen/memmove.c
+++ b/sys/src/ape/lib/ap/gen/memmove.c
@@ -11,7 +11,7 @@ memmove(void *a1, const void *a2, size_t n)
if(a1 > a2)
goto back;
s1 = a1;
- s2 = a2;
+ s2 = (char*)a2;
while(n > 0) {
*s1++ = *s2++;
n--;
diff --git a/sys/src/ape/lib/ap/gen/mkfile b/sys/src/ape/lib/ap/gen/mkfile
index 54ff7a617..65b62ab13 100644
--- a/sys/src/ape/lib/ap/gen/mkfile
+++ b/sys/src/ape/lib/ap/gen/mkfile
@@ -63,4 +63,4 @@ OFILES= `{rc ./reduce $O $objtype $ALLOFILES}
</sys/src/cmd/mksyslib
-CFLAGS=-c -D_POSIX_SOURCE
+CFLAGS=$CFLAGS -c -D_POSIX_SOURCE
diff --git a/sys/src/ape/lib/ap/gen/putenv.c b/sys/src/ape/lib/ap/gen/putenv.c
index 56a1184ba..f92efda3e 100644
--- a/sys/src/ape/lib/ap/gen/putenv.c
+++ b/sys/src/ape/lib/ap/gen/putenv.c
@@ -9,16 +9,16 @@ putenv(const char *str)
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*));
if(e == 0)
return -1;
environ = e;
- e[n++] = str;
+ e[n++] = (char*)str;
e[n] = 0;
return 0;
}
diff --git a/sys/src/ape/lib/ap/gen/rand.c b/sys/src/ape/lib/ap/gen/rand.c
index c73ad826c..80127af93 100644
--- a/sys/src/ape/lib/ap/gen/rand.c
+++ b/sys/src/ape/lib/ap/gen/rand.c
@@ -27,8 +27,6 @@ srand(unsigned int seed)
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;
diff --git a/sys/src/ape/lib/ap/gen/strcspn.c b/sys/src/ape/lib/ap/gen/strcspn.c
index f7628e8ae..2aff3336d 100644
--- a/sys/src/ape/lib/ap/gen/strcspn.c
+++ b/sys/src/ape/lib/ap/gen/strcspn.c
@@ -13,7 +13,7 @@ strcspn(const char *s, const char *b)
if(*b++ == 0)
break;
}
- os = s;
+ os = (char*)s;
while(map[*(unsigned char*)s++] == 0)
;
return s - os - 1;
diff --git a/sys/src/ape/lib/ap/gen/strpbrk.c b/sys/src/ape/lib/ap/gen/strpbrk.c
index 407f1c266..b44c73548 100644
--- a/sys/src/ape/lib/ap/gen/strpbrk.c
+++ b/sys/src/ape/lib/ap/gen/strpbrk.c
@@ -15,6 +15,6 @@ strpbrk(const char *s, const char *b)
while(map[*s++] == 0)
;
if(*--s)
- return s;
+ return (char*)s;
return 0;
}
diff --git a/sys/src/ape/lib/ap/gen/strrchr.c b/sys/src/ape/lib/ap/gen/strrchr.c
index 038b06ad2..d88aa0a51 100644
--- a/sys/src/ape/lib/ap/gen/strrchr.c
+++ b/sys/src/ape/lib/ap/gen/strrchr.c
@@ -9,6 +9,6 @@ strrchr(const char *s, int c)
return strchr(s, 0);
r = 0;
while(s = strchr(s, c))
- r = s++;
+ r = (char*)s++;
return r;
}
diff --git a/sys/src/ape/lib/ap/gen/strspn.c b/sys/src/ape/lib/ap/gen/strspn.c
index 57ebfd1b5..b7b7bf7ac 100644
--- a/sys/src/ape/lib/ap/gen/strspn.c
+++ b/sys/src/ape/lib/ap/gen/strspn.c
@@ -10,7 +10,7 @@ strspn(const char *s, const char *b)
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;
diff --git a/sys/src/ape/lib/ap/gen/strstr.c b/sys/src/ape/lib/ap/gen/strstr.c
index 4e6828571..520f992b8 100644
--- a/sys/src/ape/lib/ap/gen/strstr.c
+++ b/sys/src/ape/lib/ap/gen/strstr.c
@@ -2,19 +2,19 @@
/* 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;
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;
diff --git a/sys/src/ape/lib/ap/math/mkfile b/sys/src/ape/lib/ap/math/mkfile
index 43ba976fd..8908e3bc8 100644
--- a/sys/src/ape/lib/ap/math/mkfile
+++ b/sys/src/ape/lib/ap/math/mkfile
@@ -25,4 +25,4 @@ OFILES=\
</sys/src/cmd/mksyslib
-CFLAGS=-c -D_POSIX_SOURCE
+CFLAGS=$CFLAGS -c -D_POSIX_SOURCE
diff --git a/sys/src/ape/lib/ap/plan9/_buf.c b/sys/src/ape/lib/ap/plan9/_buf.c
index 906c2335d..185095c8c 100644
--- 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 @@ _startbuf(int fd)
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 @@ Found:
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 @@ _copyproc(int fd, Muxbuf *b)
* 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 @@ select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *timeo
}
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 @@ _detachbuf(void)
}
static int
-copynotehandler(void *u, char *msg)
+copynotehandler(void *, char *)
{
if(_finishing)
_finish(0, 0);
diff --git a/sys/src/ape/lib/ap/plan9/_envsetup.c b/sys/src/ape/lib/ap/plan9/_envsetup.c
index 6d76da87e..58ed05342 100644
--- a/sys/src/ape/lib/ap/plan9/_envsetup.c
+++ b/sys/src/ape/lib/ap/plan9/_envsetup.c
@@ -40,6 +40,8 @@ _envsetup(void)
char **pp;
Dir *d9, *d9a;
+ ps = 0;
+ psize = 0;
nohandle = 0;
fdinited = 0;
cnt = 0;
diff --git a/sys/src/ape/lib/ap/plan9/_getpw.c b/sys/src/ape/lib/ap/plan9/_getpw.c
index 2c6a740a7..c75f1dbfe 100644
--- a/sys/src/ape/lib/ap/plan9/_getpw.c
+++ b/sys/src/ape/lib/ap/plan9/_getpw.c
@@ -59,6 +59,7 @@ _getpw(int *pnum, char **pname, char **plist)
return 0;
au[n] = 0;
}
+ mem = nil;
matchnum = (*pname == NULL);
matched = 0;
/* try using memo */
@@ -68,9 +69,8 @@ _getpw(int *pnum, char **pname, char **plist)
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){
diff --git a/sys/src/ape/lib/ap/plan9/brk.c b/sys/src/ape/lib/ap/plan9/brk.c
index 0b3240377..b99fddbbc 100644
--- 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 @@ brk(char *p)
{
unsigned long n;
- n = (unsigned long)p;
+ n = (uintptr_t)p;
n += 3;
n &= ~3;
if(_BRK_((void*)n) < 0){
diff --git a/sys/src/ape/lib/ap/plan9/cfgetospeed.c b/sys/src/ape/lib/ap/plan9/cfgetospeed.c
index cc89f4a86..bfb9f42a2 100644
--- 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;
}
diff --git a/sys/src/ape/lib/ap/plan9/execle.c b/sys/src/ape/lib/ap/plan9/execle.c
index f607c4914..b01fe3be2 100644
--- 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;
diff --git a/sys/src/ape/lib/ap/plan9/execve.c b/sys/src/ape/lib/ap/plan9/execve.c
index e11ca1c21..1761f3183 100644
--- a/sys/src/ape/lib/ap/plan9/execve.c
+++ b/sys/src/ape/lib/ap/plan9/execve.c
@@ -85,7 +85,7 @@ execve(const char *name, const char *argv[], const char *envp[])
_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? */
diff --git a/sys/src/ape/lib/ap/plan9/fsync.c b/sys/src/ape/lib/ap/plan9/fsync.c
index f37d35c04..b3d0f78ae 100644
--- 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;
diff --git a/sys/src/ape/lib/ap/plan9/getgrnam.c b/sys/src/ape/lib/ap/plan9/getgrnam.c
index de2a7d33d..f4bd6b3b2 100644
--- a/sys/src/ape/lib/ap/plan9/getgrnam.c
+++ b/sys/src/ape/lib/ap/plan9/getgrnam.c
@@ -13,7 +13,7 @@ getgrnam(const char *name)
char *nam, *mem;
num = 0;
- nam = name;
+ nam = (char *)name;
mem = 0;
if(_getpw(&num, &nam, &mem)){
holdgroup.gr_name = nam;
diff --git a/sys/src/ape/lib/ap/plan9/getgroups.c b/sys/src/ape/lib/ap/plan9/getgroups.c
index e226a65b4..c26caaeb3 100644
--- 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;
diff --git a/sys/src/ape/lib/ap/plan9/getpwnam.c b/sys/src/ape/lib/ap/plan9/getpwnam.c
index 9cb18294f..e54b86c95 100644
--- a/sys/src/ape/lib/ap/plan9/getpwnam.c
+++ b/sys/src/ape/lib/ap/plan9/getpwnam.c
@@ -14,7 +14,7 @@ getpwnam(const char *name)
char *nam, *mem;
num = 0;
- nam = name;
+ nam = (char*)name;
mem = 0;
if(_getpw(&num, &nam, &mem)){
holdpw.pw_name = nam;
diff --git a/sys/src/ape/lib/ap/plan9/link.c b/sys/src/ape/lib/ap/plan9/link.c
index 9bf3755fb..293cb60c1 100644
--- 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;
diff --git a/sys/src/ape/lib/ap/plan9/mkfile b/sys/src/ape/lib/ap/plan9/mkfile
index 8f9099e22..1ddb3f4f8 100644
--- a/sys/src/ape/lib/ap/plan9/mkfile
+++ b/sys/src/ape/lib/ap/plan9/mkfile
@@ -107,6 +107,6 @@ UPDATE=\
</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
diff --git a/sys/src/ape/lib/ap/plan9/opendir.c b/sys/src/ape/lib/ap/plan9/opendir.c
index bb26214de..a78ccf31a 100644
--- a/sys/src/ape/lib/ap/plan9/opendir.c
+++ b/sys/src/ape/lib/ap/plan9/opendir.c
@@ -26,7 +26,7 @@ opendir(const char *filename)
s[n++] = '/';
s[n] = 0;
} else
- s = filename;
+ s = (char*)filename;
f = open(s, O_RDONLY);
if(s != filename)
free(s);
diff --git a/sys/src/ape/lib/ap/plan9/pause.c b/sys/src/ape/lib/ap/plan9/pause.c
index 38fd96162..f24e0f276 100644
--- a/sys/src/ape/lib/ap/plan9/pause.c
+++ b/sys/src/ape/lib/ap/plan9/pause.c
@@ -7,5 +7,5 @@ pause(void)
{
for(;;)
if(_SLEEP(1000*1000) < 0)
- return;
+ return -1;
}
diff --git a/sys/src/ape/lib/ap/plan9/read.c b/sys/src/ape/lib/ap/plan9/read.c
index 435a6d7f2..e4526905d 100644
--- a/sys/src/ape/lib/ap/plan9/read.c
+++ b/sys/src/ape/lib/ap/plan9/read.c
@@ -12,7 +12,7 @@ read(int d, void *buf, size_t nbytes)
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;
}
diff --git a/sys/src/ape/lib/ap/plan9/rename.c b/sys/src/ape/lib/ap/plan9/rename.c
index 182f49ce2..c02948316 100644
--- 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 @@ rename(const char *from, const char *to)
}
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;
}
diff --git a/sys/src/ape/lib/ap/plan9/setgid.c b/sys/src/ape/lib/ap/plan9/setgid.c
index 7c9075c3f..0411b06a5 100644
--- 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;
diff --git a/sys/src/ape/lib/ap/plan9/setuid.c b/sys/src/ape/lib/ap/plan9/setuid.c
index a34f2de6f..2790bffe5 100644
--- 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;
diff --git a/sys/src/ape/lib/ap/plan9/signal.c b/sys/src/ape/lib/ap/plan9/signal.c
index b9bfbb715..ac5a46e06 100644
--- a/sys/src/ape/lib/ap/plan9/signal.c
+++ b/sys/src/ape/lib/ap/plan9/signal.c
@@ -107,7 +107,7 @@ _notehandler(Ureg *u, char *msg)
/* notetramp is machine-dependent; doesn't return to here */
}
_NOTED(0); /* NCONT */
- return;
+ return 0;
}
}
_doatexits();
diff --git a/sys/src/ape/lib/ap/plan9/sigsuspend.c b/sys/src/ape/lib/ap/plan9/sigsuspend.c
index 290c15d0f..029e3b45a 100644
--- 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;
diff --git a/sys/src/ape/lib/ap/plan9/tcgetattr.c b/sys/src/ape/lib/ap/plan9/tcgetattr.c
index c93c21b5b..e53feadac 100644
--- a/sys/src/ape/lib/ap/plan9/tcgetattr.c
+++ b/sys/src/ape/lib/ap/plan9/tcgetattr.c
@@ -87,7 +87,7 @@ tcgetattr(int fd, struct termios *t)
/* 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];
diff --git a/sys/src/ape/lib/ap/plan9/umask.c b/sys/src/ape/lib/ap/plan9/umask.c
index b45b7576c..04eb8c5f9 100644
--- 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;
}
diff --git a/sys/src/ape/lib/ap/plan9/unlink.c b/sys/src/ape/lib/ap/plan9/unlink.c
index c79f1b83b..90085419f 100644
--- a/sys/src/ape/lib/ap/plan9/unlink.c
+++ b/sys/src/ape/lib/ap/plan9/unlink.c
@@ -26,6 +26,7 @@ unlink(const char *path)
_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) {
diff --git a/sys/src/ape/lib/ap/posix/getpwent.c b/sys/src/ape/lib/ap/posix/getpwent.c
index 779ae3a54..64d386d4b 100644
--- a/sys/src/ape/lib/ap/posix/getpwent.c
+++ b/sys/src/ape/lib/ap/posix/getpwent.c
@@ -49,7 +49,7 @@ pwdecode(char *p)
passwd.pw_dir = p;
p = pwskip(p);
passwd.pw_shell = p;
- p = pwskip(p);
+ pwskip(p);
return(&passwd);
}
diff --git a/sys/src/ape/lib/ap/posix/mkfifo.c b/sys/src/ape/lib/ap/posix/mkfifo.c
index 7dbc8f5b6..ffd8cb8ea 100644
--- 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
diff --git a/sys/src/ape/lib/ap/posix/mkfile b/sys/src/ape/lib/ap/posix/mkfile
index 387208c5e..725694358 100644
--- a/sys/src/ape/lib/ap/posix/mkfile
+++ b/sys/src/ape/lib/ap/posix/mkfile
@@ -14,4 +14,4 @@ OFILES=\
</sys/src/cmd/mksyslib
-CFLAGS=-c -D_POSIX_SOURCE
+CFLAGS=$CFLAGS -c -D_POSIX_SOURCE
diff --git a/sys/src/ape/lib/ap/posix/pathconf.c b/sys/src/ape/lib/ap/posix/pathconf.c
index 9fdf47684..c09302d93 100644
--- 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 @@ pathconf(const char *path, int name)
}
long
-fpathconf(int fd, int name)
+fpathconf(int, int name)
{
-#pragma ref fd
-
return pathconf(0, name);
}
diff --git a/sys/src/ape/lib/ap/posix/tzset.c b/sys/src/ape/lib/ap/posix/tzset.c
index f4cbac075..67a367d61 100644
--- a/sys/src/ape/lib/ap/posix/tzset.c
+++ b/sys/src/ape/lib/ap/posix/tzset.c
@@ -20,6 +20,7 @@ tzset(void)
{
char *env, *p, *q;
+ env = NULL;
if((p = getenv("timezone")) == 0)
goto error;
if((env = malloc(strlen(p) + 1)) == 0)
diff --git a/sys/src/ape/lib/ap/stdio/_fconv.c b/sys/src/ape/lib/ap/stdio/_fconv.c
index fc72d4731..1f6d750d4 100644
--- a/sys/src/ape/lib/ap/stdio/_fconv.c
+++ b/sys/src/ape/lib/ap/stdio/_fconv.c
@@ -509,7 +509,7 @@ _d2b(double darg, int *e, int *bits)
}
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 @@ _d2b(double darg, int *e, int *bits)
#endif
k = lo0bits(&z);
x[0] = z;
- i = b->wds = 1;
+ b->wds = 1;
k += 32;
}
#else
diff --git a/sys/src/ape/lib/ap/stdio/ftoa.c b/sys/src/ape/lib/ap/stdio/ftoa.c
index b241d2d43..b0e5adc80 100644
--- a/sys/src/ape/lib/ap/stdio/ftoa.c
+++ b/sys/src/ape/lib/ap/stdio/ftoa.c
@@ -27,7 +27,7 @@ int ftoa(double f, char *bp){
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;
diff --git a/sys/src/ape/lib/ap/stdio/mkfile b/sys/src/ape/lib/ap/stdio/mkfile
index 76e51b27b..a8f392c82 100644
--- a/sys/src/ape/lib/ap/stdio/mkfile
+++ b/sys/src/ape/lib/ap/stdio/mkfile
@@ -66,4 +66,4 @@ OFILES=\
</sys/src/cmd/mksyslib
-CFLAGS=-c -D_POSIX_SOURCE
+CFLAGS=$CFLAGS -c -D_POSIX_SOURCE
diff --git a/sys/src/ape/lib/ap/stdio/vfprintf.c b/sys/src/ape/lib/ap/stdio/vfprintf.c
index d346cb29a..67e703380 100644
--- 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 @@ vfprintf(FILE *f, const char *s, va_list args)
}
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 @@ ocvt_s(FILE *f, va_list *args, int flags, int width, int precision)
}
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 @@ ocvt_fixed(FILE *f, va_list *args, int flags, int width, int precision,
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 @@ ocvt_fixed(FILE *f, va_list *args, int flags, int width, int precision,
}
} 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);
diff --git a/sys/src/ape/lib/ap/stdio/vfscanf.c b/sys/src/ape/lib/ap/stdio/vfscanf.c
index 14a55956c..c44bd7576 100644
--- a/sys/src/ape/lib/ap/stdio/vfscanf.c
+++ b/sys/src/ape/lib/ap/stdio/vfscanf.c
@@ -60,7 +60,8 @@ icvt_x, 0, 0, 0, 0, 0, 0, 0, /* x y z { | } ~ ^? */
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 @@ int vfscanf(FILE *f, const char *s, va_list args){
}
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 @@ static int icvt_n(FILE *f, va_list *args, int store, int width, int type){
}
return 1;
}
+
#define SIGNED 1
#define UNSIGNED 2
#define POINTER 3
@@ -132,7 +135,8 @@ static int icvt_n(FILE *f, va_list *args, int store, int width, int type){
* 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 @@ Done:
}
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 @@ Done:
}
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 @@ static int icvt_s(FILE *f, va_list *args, int store, int width, int type){
else goto Done;
}
nn++;
- if(store) *s++=c;
+ if(store)
+ *s++=c;
wgetc(c, f, Done);
}
nungetc(c, f);
@@ -306,21 +336,27 @@ Done:
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 @@ static int match(int c, const char *pat){
}
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 @@ static int icvt_sq(FILE *f, va_list *args, int store, int width, int type){
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);