summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/inet/addr.c1
-rw-r--r--libc/inet/resolv.c16
-rw-r--r--libc/pwd_grp/pwent.c2
-rw-r--r--libc/stdio/scanf.c54
-rw-r--r--libc/stdio/stdio.c56
-rw-r--r--libc/stdlib/bsearch.c2
-rw-r--r--libc/stdlib/mkstemp.c4
-rw-r--r--libc/stdlib/mktemp.c4
-rw-r--r--libc/stdlib/putenv.c2
-rw-r--r--libc/stdlib/qsort.c11
-rw-r--r--libc/stdlib/rand.c2
-rw-r--r--libc/stdlib/setenv.c3
-rw-r--r--libc/stdlib/system.c2
-rw-r--r--libc/string/strsep.c2
-rw-r--r--libc/string/strstr.c2
-rw-r--r--libc/sysdeps/linux/Makefile2
-rw-r--r--libc/sysdeps/linux/common/mkfifo.c3
17 files changed, 87 insertions, 81 deletions
diff --git a/libc/inet/addr.c b/libc/inet/addr.c
index bb27753bf..dcdd06cd4 100644
--- a/libc/inet/addr.c
+++ b/libc/inet/addr.c
@@ -7,6 +7,7 @@
#include <ctype.h>
#include <netinet/in.h>
+int inet_aton(const char *cp, struct in_addr *inp);
#ifdef L_inet_aton
int
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index b4cfab104..27daaf4d6 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -312,9 +312,9 @@ int decode_answer(unsigned char * message, int offset,
#ifdef L_encodep
int encode_packet(struct resolv_header * h,
struct resolv_question ** q,
- struct resolv_question ** an,
- struct resolv_question ** ns,
- struct resolv_question ** ar,
+ struct resolv_answer ** an,
+ struct resolv_answer ** ns,
+ struct resolv_answer ** ar,
unsigned char * dest, int maxlen)
{
int i, total=0;
@@ -694,12 +694,12 @@ int resolve_mailbox(const char * address,
#endif
extern int nameservers;
-extern const char * nameserver[3];
+extern const char *__const nameserver[3];
#ifdef L_opennameservers
int nameservers;
-const char * nameserver[3];
+const char *__const nameserver[3];
int open_nameservers()
{
@@ -707,8 +707,8 @@ int open_nameservers()
char **arg;
int i;
- if (fp = fopen("/etc/resolv.conf", "r")) {
- if (arg = cfgfind(fp, "nameserver")) {
+ if ((fp = fopen("/etc/resolv.conf", "r"))) {
+ if ((arg = cfgfind(fp, "nameserver"))) {
for (i=1; arg[i]; i++) {
nameserver[nameservers++] = strdup(arg[i]);
}
@@ -730,7 +730,7 @@ void close_nameservers(void) {
#ifdef L_resolvename
-char * resolve_name(const char * name, int mailbox)
+const char * resolve_name(const char * name, int mailbox)
{
struct in_addr in;
int i;
diff --git a/libc/pwd_grp/pwent.c b/libc/pwd_grp/pwent.c
index fd65db21a..51f76b53f 100644
--- a/libc/pwd_grp/pwent.c
+++ b/libc/pwd_grp/pwent.c
@@ -54,7 +54,7 @@ struct passwd *
getpwent(void)
{
if (pw_fd!=-1)
- return __getpwent(pw_fd);
+ return (__getpwent(pw_fd));
return NULL;
}
diff --git a/libc/stdio/scanf.c b/libc/stdio/scanf.c
index 7c5f52183..593e01d25 100644
--- a/libc/stdio/scanf.c
+++ b/libc/stdio/scanf.c
@@ -1,3 +1,5 @@
+#include <stdlib.h>
+#include <unistd.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
@@ -30,27 +32,27 @@ va_dcl
#ifdef L_sscanf
#ifdef __STDC__
-int sscanf(char * sp, const char * fmt, ...)
+int sscanf(const char * sp, const char * fmt, ...)
#else
int sscanf(sp, fmt, va_alist)
-char * sp;
+__const char * sp;
__const char *fmt;
va_dcl
#endif
{
-static FILE string[1] =
-{
- {0, (char*)(unsigned) -1, 0, 0, (char*) (unsigned) -1, -1,
- _IOFBF | __MODE_READ}
-};
-
- va_list ptr;
- int rv;
- va_strt(ptr, fmt);
- string->bufpos = sp;
- rv = vfscanf(string,fmt,ptr);
- va_end(ptr);
- return rv;
+ FILE string[1] =
+ {
+ {0, (char*)(unsigned) -1, 0, 0, (char*) (unsigned) -1, -1,
+ _IOFBF | __MODE_READ}
+ };
+
+ va_list ptr;
+ int rv;
+ va_strt(ptr, fmt);
+ string->bufpos = (unsigned char *)((void*)sp);
+ rv = vfscanf(string,fmt,ptr);
+ va_end(ptr);
+ return rv;
}
#endif
@@ -83,18 +85,16 @@ va_list ap;
#endif
#ifdef L_vsscanf
-int vsscanf(sp, fmt, ap)
-char * sp;
-__const char *fmt;
+int vsscanf(__const char *sp, __const char *fmt, va_list ap)
{
-static FILE string[1] =
-{
- {0, (char*)(unsigned) -1, 0, 0, (char*) (unsigned) -1, -1,
- _IOFBF | __MODE_READ}
-};
-
- string->bufpos = sp;
- return vfscanf(string,fmt,ap);
+ FILE string[1] =
+ {
+ {0, (char*)(unsigned) -1, 0, 0, (char*) (unsigned) -1, -1,
+ _IOFBF | __MODE_READ}
+ };
+
+ string->bufpos = (unsigned char *)((void*)sp);
+ return vfscanf(string,fmt,ap);
}
#endif
@@ -170,7 +170,7 @@ int fp_sval[NSTATE] = {
int
vfscanf(fp, fmt, ap)
register FILE *fp;
-register char *fmt;
+register const char *fmt;
va_list ap;
{
diff --git a/libc/stdio/stdio.c b/libc/stdio/stdio.c
index 98d0ba3b4..9043e6199 100644
--- a/libc/stdio/stdio.c
+++ b/libc/stdio/stdio.c
@@ -6,15 +6,19 @@
/* This is an implementation of the C standard IO package.
*/
+#include <stdlib.h>
#include <stdio.h>
-
+#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <malloc.h>
#include <errno.h>
+#include <string.h>
#undef STUB_FWRITE
+void __io_init_vars(void);
+
extern FILE *__IO_list; /* For fflush at exit */
#define FIXED_BUFFERS 2
@@ -80,10 +84,7 @@ FILE stderr[1] =
/* Call the stdio initiliser; it's main job it to call atexit */
-#define STATIC
-
-STATIC int
-__stdio_close_all()
+void __stdio_close_all(void)
{
FILE *fp;
fflush(stdout);
@@ -103,8 +104,7 @@ static int first_time = 0;
struct fixed_buffer _fixed_buffers[2];
-STATIC void
-__io_init_vars()
+void __io_init_vars(void)
{
if( first_time ) return;
first_time = 1;
@@ -206,7 +206,9 @@ FILE *fp;
if (fp->mode & __MODE_WRITING)
fflush(fp);
+#if __MODE_IOTRAN
try_again:
+#endif
/* Can't read or there's been an EOF or error then return EOF */
if ((fp->mode & (__MODE_READ | __MODE_EOF | __MODE_ERR)) != __MODE_READ)
return EOF;
@@ -319,7 +321,7 @@ FILE *fp;
char *
fgets(s, count, f)
char *s;
-size_t count;
+int count;
FILE *f;
{
char *ret;
@@ -368,7 +370,7 @@ char *str;
#ifdef L_fputs
int
fputs(str, fp)
-char *str;
+const char *str;
FILE *fp;
{
register int n = 0;
@@ -385,7 +387,7 @@ FILE *fp;
#ifdef L_puts
int
puts(str)
-char *str;
+const char *str;
{
register int n;
@@ -405,12 +407,12 @@ char *str;
* This ignores __MODE__IOTRAN; probably exactly what you want. (It _is_ what
* fgetc wants)
*/
-int
+size_t
fread(buf, size, nelm, fp)
-char *buf;
-int size;
-int nelm;
-FILE *fp;
+void *buf;
+size_t size;
+size_t nelm;
+FILE *fp;
{
int len, v;
unsigned bytes, got = 0;
@@ -467,12 +469,12 @@ FILE *fp;
*
* Again this ignores __MODE__IOTRAN.
*/
-int
+size_t
fwrite(buf, size, nelm, fp)
-char *buf;
-int size;
-int nelm;
-FILE *fp;
+const void *buf;
+size_t size;
+size_t nelm;
+FILE *fp;
{
register int v;
int len;
@@ -606,7 +608,6 @@ int ref;
long ftell(fp)
FILE * fp;
{
- long rv;
if (fflush(fp) == EOF)
return EOF;
return lseek(fp->fd, 0L, SEEK_CUR);
@@ -620,10 +621,10 @@ FILE * fp;
*/
FILE *
__fopen(fname, fd, fp, mode)
-char *fname;
+const char *fname;
int fd;
FILE *fp;
-char *mode;
+const char *mode;
{
int open_mode = 0;
#if __MODE_IOTRAN
@@ -875,8 +876,8 @@ size_t size;
if( mode == _IOFBF || mode == _IOLBF )
{
- if( size <= 0 ) size = BUFSIZ;
- if( buf == 0 )
+ if( size <= 0 ) { size = BUFSIZ; }
+ if( buf == 0 ) {
if (size == BUFSIZ) {
int i;
for(i=0;i<FIXED_BUFFERS;i++)
@@ -887,8 +888,10 @@ size_t size;
}
if(i==FIXED_BUFFERS)
buf = malloc(size);
- } else
+ } else {
buf = malloc(size);
+ }
+ }
if( buf == 0 ) return EOF;
fp->bufstart = buf;
@@ -896,6 +899,7 @@ size_t size;
fp->mode |= mode;
}
fp->bufpos = fp->bufread = fp->bufwrite = fp->bufstart;
+ return 0;
}
#endif
diff --git a/libc/stdlib/bsearch.c b/libc/stdlib/bsearch.c
index 989866743..72ba2617a 100644
--- a/libc/stdlib/bsearch.c
+++ b/libc/stdlib/bsearch.c
@@ -28,7 +28,7 @@ register int (*cmp) (); /* comparison function */
while (a <= b)
{
c = (a + b) >> 1; /* == ((a + b) / 2) */
- if (dir = (*cmp) ((base + (c * size)), key))
+ if ((dir = (*cmp) ((base + (c * size)), key)))
{
if (dir > 0)
b = c - 1;
diff --git a/libc/stdlib/mkstemp.c b/libc/stdlib/mkstemp.c
index d65ada4f7..de3c682b2 100644
--- a/libc/stdlib/mkstemp.c
+++ b/libc/stdlib/mkstemp.c
@@ -1,4 +1,4 @@
-
+#include <string.h>
#include <features.h>
#include <unistd.h>
#include <fcntl.h>
@@ -7,7 +7,7 @@ int mkstemp(template)
char * template;
{
int i;
- int num; /* UNINITIALIZED */
+ int num __attribute__ ((unused)); /* UNINITIALIZED */
int n2;
int l = strlen(template);
diff --git a/libc/stdlib/mktemp.c b/libc/stdlib/mktemp.c
index 08b356710..bbe589efc 100644
--- a/libc/stdlib/mktemp.c
+++ b/libc/stdlib/mktemp.c
@@ -1,4 +1,4 @@
-
+#include <string.h>
#include <features.h>
#include <unistd.h>
#include <fcntl.h>
@@ -8,7 +8,7 @@ char * mktemp(template)
char * template;
{
int i;
- int num; /* UNINITIALIZED */
+ int num __attribute__ ((unused)); /* UNINITIALIZED */
int n2;
int l = strlen(template);
struct stat stbuf;
diff --git a/libc/stdlib/putenv.c b/libc/stdlib/putenv.c
index a7a453d5f..692aefb5e 100644
--- a/libc/stdlib/putenv.c
+++ b/libc/stdlib/putenv.c
@@ -33,7 +33,7 @@ static int extras = 0;
{
if( memcmp(var, *p, len) == 0 && (*p)[len] == '=' )
{
- while( p[0] = p[1] ) p++;
+ while( (p[0] = p[1]) ) p++;
extras++;
break;
}
diff --git a/libc/stdlib/qsort.c b/libc/stdlib/qsort.c
index cee53c398..b45716c83 100644
--- a/libc/stdlib/qsort.c
+++ b/libc/stdlib/qsort.c
@@ -14,7 +14,7 @@ char *_qbuf = 0; /* pointer to storage for qsort() */
#define PIVOT ((i+j)>>1)
#define moveitem(dst,src,size) if(dst != src) memcpy(dst, src, size)
-static
+static void
_wqsort(base, lo, hi, cmp)
register int *base;
register int lo;
@@ -56,7 +56,7 @@ register int (*cmp) ();
}
}
-static
+static void
_lqsort(base, lo, hi, cmp)
register long *base;
register int lo;
@@ -98,7 +98,7 @@ register int (*cmp) ();
}
}
-static
+static void
_nqsort(base, lo, hi, size, cmp)
register char *base;
register int lo;
@@ -141,7 +141,7 @@ register int (*cmp) ();
}
}
-qsort(base, num, size, cmp)
+extern int qsort(base, num, size, cmp)
char *base;
int num;
int size;
@@ -152,7 +152,7 @@ int (*cmp) ();
if (_qbuf == 0)
{
if (size > sizeof(_qtemp))/* records too large! */
- return;
+ return 1;
_qbuf = _qtemp;
}
if (size == 2)
@@ -163,4 +163,5 @@ int (*cmp) ();
_nqsort(base, 0, num - 1, size, cmp);
if (_qbuf == _qtemp)
_qbuf = 0;
+ return 0;
}
diff --git a/libc/stdlib/rand.c b/libc/stdlib/rand.c
index 4eb07894b..4bf98d5bc 100644
--- a/libc/stdlib/rand.c
+++ b/libc/stdlib/rand.c
@@ -41,7 +41,7 @@ static int seed3 = 1;
int rand()
{
- register int q, z;
+ register int q;
CRANK(206, 157, 31, 32363, seed1);
CRANK(217, 146, 45, 31727, seed2);
CRANK(222, 142, 133, 31657, seed3);
diff --git a/libc/stdlib/setenv.c b/libc/stdlib/setenv.c
index 0990fdec2..afe5676d1 100644
--- a/libc/stdlib/setenv.c
+++ b/libc/stdlib/setenv.c
@@ -35,7 +35,8 @@ static int extras = 0;
{
if (!overwrite)
return -1;
- while( p[0] = p[1] ) p++;
+ /* Overwrite stuff */
+ while( (p[0] = p[1]) ) p++;
extras++;
break;
}
diff --git a/libc/stdlib/system.c b/libc/stdlib/system.c
index b764613be..74ac27b64 100644
--- a/libc/stdlib/system.c
+++ b/libc/stdlib/system.c
@@ -7,7 +7,7 @@ int
system(command)
char * command;
{
- int wait_val, wait_ret, pid;
+ int wait_val, pid;
__sighandler_t save_quit, save_int, save_chld;
if( command == 0 ) return 1;
diff --git a/libc/string/strsep.c b/libc/string/strsep.c
index 21aa1bb58..703fe5c69 100644
--- a/libc/string/strsep.c
+++ b/libc/string/strsep.c
@@ -27,7 +27,7 @@ char *delim;
if (!(p = *pp))
return 0;
- if (q = strpbrk (p, delim))
+ if ((q = strpbrk (p, delim)))
{
*pp = q + 1;
*q = '\0';
diff --git a/libc/string/strstr.c b/libc/string/strstr.c
index aafcaf967..3c853ac52 100644
--- a/libc/string/strstr.c
+++ b/libc/string/strstr.c
@@ -17,7 +17,7 @@ char *s1; char *s2;
if( l==0 ) return p;
- while (p = strchr(p, *s2))
+ while ((p = strchr(p, *s2)))
{
if( memcmp(p, s2, l) == 0 )
return p;
diff --git a/libc/sysdeps/linux/Makefile b/libc/sysdeps/linux/Makefile
index a81bb9a21..16980d1b3 100644
--- a/libc/sysdeps/linux/Makefile
+++ b/libc/sysdeps/linux/Makefile
@@ -5,7 +5,7 @@ ARCH = $(shell uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/')
all: $(ARCH) common
$(ARCH): dummy
- echo Building for ARCH=$(ARCH)
+ @echo Building for ARCH=$(ARCH)
make -C $(ARCH)
common: dummy
diff --git a/libc/sysdeps/linux/common/mkfifo.c b/libc/sysdeps/linux/common/mkfifo.c
index dbaa9aa3b..876f36b5a 100644
--- a/libc/sysdeps/linux/common/mkfifo.c
+++ b/libc/sysdeps/linux/common/mkfifo.c
@@ -29,6 +29,5 @@
int
mkfifo (const char *path, mode_t mode)
{
- dev_t dev = 0;
- return mknod (path, mode | S_IFIFO, &dev);
+ return mknod (path, mode | S_IFIFO, 0);
}