summaryrefslogtreecommitdiff
path: root/sys/src/ape/lib/ap/stdio
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/lib/ap/stdio
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/lib/ap/stdio')
-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
5 files changed, 82 insertions, 43 deletions
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);