Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
lots of warnings removed
Browse files Browse the repository at this point in the history
  • Loading branch information
fefe committed Feb 23, 2002
1 parent 5e45351 commit 453e506
Show file tree
Hide file tree
Showing 83 changed files with 273 additions and 145 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,8 @@ $(OBJDIR)/adjtimex.o: include/sys/timex.h

$(OBJDIR)/fgetc_unlocked.o $(OBJDIR)/fread.o $(OBJDIR)/ungetc.o: dietstdio.h

# these depend on dietfeatures.h for WANT_LINKER_WARNINGS
$(OBJDIR)/setlinebuf.o $(OBJDIR)/bzero.o $(OBJDIR)/setegid.o \
$(OBJDIR)/seteuid.o: dietfeatures.h

# CFLAGS+=-W -Wshadow -Wid-clash-31 -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wwrite-strings
1 change: 1 addition & 0 deletions PORTING
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ To port the diet libc to a new architecture, you need to:
- edit include/sys/mman.h
- edit include/sys/shm.h
- edit include/sys/stat.h
- edit include/errno.h
- edit syscalls.h

(I may have missed a few)
1 change: 1 addition & 0 deletions include/arpa/inet.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ int inet_aton(const char *cp, struct in_addr *inp) __THROW;
unsigned long int inet_addr(const char *cp) __THROW;
unsigned long int inet_network(const char *cp) __THROW;
char *inet_ntoa(struct in_addr in) __THROW;
char *inet_ntoa_r(struct in_addr in,char* buf) __THROW;
struct in_addr inet_makeaddr(int net, int host) __THROW;
unsigned long int inet_lnaof(struct in_addr in) __THROW;
unsigned long int inet_netof(struct in_addr in) __THROW;
Expand Down
13 changes: 13 additions & 0 deletions include/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,17 @@ int isnan(double d) __attribute__((__const__));
int isinf(double d) __attribute__((__const__));
int finite(double d) __attribute__((__const__));

double j0(double x);
double j1(double x);
double jn(int n, double x);
double y0(double x);
double y1(double x);
double yn(int n, double x);
double erf(double x);
double erfc(double x);
double lgamma(double x);
double ipow(double mant, int expo);

double rint(double x);

#endif
4 changes: 4 additions & 0 deletions include/netinet/in.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define _NETINET_IN_H

#include <sys/types.h>
#include <sys/socket.h>
#include <endian.h>

/* Standard well-defined IP protocols. */
Expand Down Expand Up @@ -376,4 +377,7 @@ unsigned short int ntohs(unsigned short int netshort);
&& (((__const uint32_t *) (a))[2] == ((__const uint32_t *) (b))[2]) \
&& (((__const uint32_t *) (a))[3] == ((__const uint32_t *) (b))[3]))

/* old legacy bullshit */
int bindresvport(int sd, struct sockaddr_in* sin);

#endif
4 changes: 4 additions & 0 deletions include/signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,8 @@ extern const char *const sys_siglist[];

#define killpg(pgrp,sig) kill(-pgrp,sig)

#ifdef _GNU_SOURCE
const char* strsignal(int sig) __THROW;
#endif

#endif
3 changes: 3 additions & 0 deletions include/stdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,7 @@ FILE* tmpfile(void) __THROW;
#define L_cuserid 9
#endif

void flockfile(FILE* f) __THROW;
void funlockfile(FILE* f) __THROW;

#endif
8 changes: 6 additions & 2 deletions include/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ void *memccpy(void *dest, const void *src, int c, size_t n) __THROW;
void *memmove(void *dest, const void *src, size_t n) __THROW;

int memccmp(const void *s1, const void *s2, int c, size_t n) __THROW __pure__;
#if !defined(__GNUC__) || defined(__mips__) || defined(__alpha__)

/* gcc unfortunately has some internal prototypes that are not compliant
* to the single unix specification and if we define the correct
* prototypes here, gcc emits warnings. */
int memcmp(const void *s1, const void *s2, size_t n) __THROW __pure__;
#if !defined(__GNUC__) || defined(__mips__) || defined(__alpha__) || defined(__arm__)
void* memset(void *s, int c, size_t n) __THROW;
int memcmp(const void *s1, const void *s2, size_t n) __THROW __pure__;
void* memcpy(void *dest, const void *src, size_t n) __THROW;
#endif

Expand Down Expand Up @@ -80,6 +81,9 @@ int strcoll(const char *s1, const char *s2) __THROW;
#define rindex(a,b) strrchr(a,b)
#endif

/* this macro causes gcc -Wall to warn about using strncpy and
* discarding the return value. If that bothers you, use memccpy
* directly. */
#define strncpy(dest,src,n) (memccpy(dest,src,0,n), dest)

#endif
2 changes: 2 additions & 0 deletions include/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ struct tm* gmtime(const time_t* t) __THROW;
struct tm* localtime_r(const time_t* t, struct tm* r) __THROW;
struct tm* gmtime_r(const time_t* t, struct tm* r) __THROW;

clock_t clock(void);

#endif
1 change: 1 addition & 0 deletions lib/atol.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <endian.h>
#include <ctype.h>
#include <stdlib.h>

long int atol(const char* s) {
long int v=0;
Expand Down
1 change: 1 addition & 0 deletions lib/atoll.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <endian.h>
#include <ctype.h>
#include <stdlib.h>

#if __WORDSIZE != 64
long long int atoll(const char* s) {
Expand Down
1 change: 1 addition & 0 deletions lib/creat.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <fcntl.h>

int __libc_creat(const char *file,mode_t mode);
int __libc_creat(const char *file,mode_t mode) {
return open(file,O_WRONLY|O_CREAT|O_TRUNC,mode);
}
Expand Down
10 changes: 5 additions & 5 deletions lib/ftw.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
#include <stdlib.h>

int ftw(const char*dir,int(*f)(const char*file,const struct stat*sb,int flag),int dpth){
char*cd;
char* cd;
size_t cdl;
DIR*d;
struct dirent*de;
DIR* d;
struct dirent* de;
struct stat sb;
int r;
int oldlen=0;
char*filename;
unsigned int oldlen=0;
char* filename; /* the warning gcc issues here is bogus */
if(chdir(dir))return-1;
cd=alloca(PATH_MAX+1);
if(!getcwd(cd,PATH_MAX))return-1;
Expand Down
1 change: 1 addition & 0 deletions lib/htonl.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <endian.h>
#include <netinet/in.h>

unsigned long int htonl(unsigned long int hostlong) {
#if __BYTE_ORDER==__LITTLE_ENDIAN
Expand Down
1 change: 1 addition & 0 deletions lib/htons.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <endian.h>
#include <netinet/in.h>

unsigned short int htons(unsigned short int hostshort) {
#if __BYTE_ORDER==__LITTLE_ENDIAN
Expand Down
2 changes: 2 additions & 0 deletions lib/memcmp.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <sys/types.h>

/* gcc is broken and has a non-SUSv2 compliant internal prototype.
* This causes it to warn about a type mismatch here. Ignore it. */
int memcmp(const void *dst, const void *src, size_t count) {
register int r;
register const char *d=dst;
Expand Down
2 changes: 2 additions & 0 deletions lib/memcpy.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <sys/types.h>

/* gcc is broken and has a non-SUSv2 compliant internal prototype.
* This causes it to warn about a type mismatch here. Ignore it. */
void* memcpy(void* dst, const void* src, size_t count) {
register char *d=dst;
register const char *s=src;
Expand Down
4 changes: 3 additions & 1 deletion lib/memset.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <sys/types.h>

void * memset(void * dst, int s, size_t count) {
/* gcc is broken and has a non-SUSv2 compliant internal prototype.
* This causes it to warn about a type mismatch here. Ignore it. */
void* memset(void * dst, int s, size_t count) {
register char * a = dst;
count++; /* this actually creates smaller code than using count-- */
while (--count)
Expand Down
1 change: 1 addition & 0 deletions lib/readdir64.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <dirent.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>

#ifndef WANT_LARGEFILE_BACKCOMPAT
struct dirent64* readdir64(DIR *d) {
Expand Down
1 change: 1 addition & 0 deletions lib/semctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ union semun {
void *__pad;
};

int semctl(int semid, int semnum, int cmd, union semun arg);
int semctl(int semid, int semnum, int cmd, union semun arg) {
return __ipc(SEMCTL,semid,semnum,cmd,&arg);
}
6 changes: 6 additions & 0 deletions lib/setlinebuf.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#include <stdio.h>
#include "dietwarning.h"
#undef setlinebuf

/* there is no previous prototype because it is a #define */
void setlinebuf(FILE* stream);

void setlinebuf(FILE* stream) {
setvbuf(stream,0,_IOLBF,BUFSIZ);
}

link_warning("setlinebuf","warning: you used setlinebuf without including <stdio.h>")
2 changes: 2 additions & 0 deletions lib/strncat.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* the last written bytes is always '\0'. */
#endif

/* gcc is broken and has a non-SUSv2 compliant internal prototype.
* This causes it to warn about a type mismatch here. Ignore it. */
char *strncat(char *s, const char *t, size_t n) {
char *dest=s;
register char *max;
Expand Down
2 changes: 2 additions & 0 deletions lib/strncmp.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <sys/types.h>
#include <string.h>

/* gcc is broken and has a non-SUSv2 compliant internal prototype.
* This causes it to warn about a type mismatch here. Ignore it. */
int strncmp(const char *s1, const char *s2, size_t n) {
register const char* a=s1;
register const char* b=s2;
Expand Down
3 changes: 3 additions & 0 deletions lib/strncpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#include <string.h>

#undef strncpy
/* gcc is broken and has a non-SUSv2 compliant internal prototype.
* This causes it to warn about a type mismatch here. Ignore it. */
char *strncpy(char *dest, const char *src, size_t n);
char *strncpy(char *dest, const char *src, size_t n) {
memccpy(dest,src,0,n);
return dest;
Expand Down
7 changes: 3 additions & 4 deletions lib/strtod.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#include <string.h>
#include <stdlib.h>
#include <ctype.h>

extern char isspace (char c);

double strtod ( const char* s, const char** endptr )
{
double strtod(const char* s, char** endptr) {
register const char* p = s;
register long double value = 0.L;
int sign = +1;
Expand Down
1 change: 1 addition & 0 deletions lib/ttyname.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "dietfeatures.h"
#include <unistd.h>
#include <sys/stat.h>
#include <string.h>

#ifdef __linux__

Expand Down
1 change: 1 addition & 0 deletions lib/write12.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <unistd.h>
#include <string.h>
#include <write12.h>

int __write1 (const char* s) {
return write(1, s, strlen(s));
Expand Down
1 change: 1 addition & 0 deletions libcruft/alphasort.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <dirent.h>
#include <string.h>

int alphasort(const struct dirent **a, const struct dirent **b) {
return strcmp((*a)->d_name,(*b)->d_name);
Expand Down
1 change: 1 addition & 0 deletions libcruft/bcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

extern void memmove(char*,const char*,size_t);

void bcopy(const void *src, void *dest, size_t n);
void bcopy(const void *src, void *dest, size_t n) {
memmove(dest,src,n);
}
Expand Down
1 change: 1 addition & 0 deletions libcruft/bzero.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <string.h>
#include "dietwarning.h"

void bzero(void *s, size_t n);
void bzero(void *s, size_t n) {
memset(s,0,n);
}
Expand Down
16 changes: 7 additions & 9 deletions libcruft/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@
#include <time.h>
#include <unistd.h>

clock_t clock ( void )
{
struct tms buf;

times ( &buf );
clock_t clock(void) {
struct tms buf;
times(&buf);

/* printf("utime %d, stime %d, CLOCKS_PER_SEC %d, HZ %d\n",buf.tms_utime,buf.tms_stime,CLOCKS_PER_SEC,HZ); */

#if CLOCKS_PER_SEC == HZ
return (unsigned long) buf.tms_utime + buf.tms_stime;
return (unsigned long) buf.tms_utime + buf.tms_stime;
#elif CLOCKS_PER_SEC % HZ == 0
return ((unsigned long) buf.tms_utime + buf.tms_stime) * (CLOCKS_PER_SEC / HZ);
return ((unsigned long) buf.tms_utime + buf.tms_stime) * (CLOCKS_PER_SEC / HZ);
#elif HZ % CLOCKS_PER_SEC == 0
return ((unsigned long) buf.tms_utime + buf.tms_stime) / (HZ / CLOCKS_PER_SEC);
return ((unsigned long) buf.tms_utime + buf.tms_stime) / (HZ / CLOCKS_PER_SEC);
#else
return ((unsigned long long) buf.tms_utime + buf.tms_stime) * CLOCKS_PER_SEC / HZ;
return ((unsigned long long) buf.tms_utime + buf.tms_stime) * CLOCKS_PER_SEC / HZ;
#endif
}
4 changes: 4 additions & 0 deletions libcruft/dn_expand.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>

extern int __dns_decodename(unsigned char *packet,unsigned int offset,unsigned char *dest,unsigned int maxlen);

int dn_expand(unsigned char *msg, unsigned char *eomorig, unsigned char *comp_dn, unsigned char *exp_dn, int length) {
(void)eomorig; /* shut gcc up warning about unused eomorig */
return __dns_decodename(msg,comp_dn-msg,exp_dn,length)-(comp_dn-msg);
}

5 changes: 5 additions & 0 deletions libcruft/dnscruft.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@

int __dns_fd=-1;

/* the ad-hoc internal API from hell ;-) */
void __dns_make_fd(void);
void __dns_readstartfiles(void);
int __dns_decodename(unsigned char *packet,unsigned int offset,unsigned char *dest,unsigned int maxlen);

void __dns_make_fd(void) {
int tmp;
struct sockaddr_in si;
Expand Down
1 change: 1 addition & 0 deletions libcruft/dnscruft4.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
size_t __dns_buflen=0;
char* __dns_buf=0;

void __dns_makebuf(size_t x);
void __dns_makebuf(size_t x) {
char* tmp=realloc(__dns_buf,__dns_buflen=x);
if (tmp) __dns_buf=tmp; else { free(__dns_buf); __dns_buf=0; }
Expand Down
1 change: 1 addition & 0 deletions libcruft/getgrent_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <sys/types.h>
#include <sys/mman.h>
#include <paths.h>
#include <string.h>
#include "parselib.h"

static struct state __ps;
Expand Down
2 changes: 0 additions & 2 deletions libcruft/gethostbyaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include <errno.h>
#include "dietwarning.h"

extern int h_errno;

static const int hostentsize=((sizeof(struct hostent)+15)&(-16));

extern size_t __dns_buflen;
Expand Down
1 change: 1 addition & 0 deletions libcruft/gethostbyaddr_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ int gethostbyaddr_r(const char* addr, size_t length, int format,
char tmpbuf[100];
char* tmp;
int res;
(void)length; /* shut gcc up about unused length. The length is implicit with format */
#ifdef WANT_ETC_HOSTS
{
struct hostent* r;
Expand Down
2 changes: 0 additions & 2 deletions libcruft/gethostbyname2.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include <errno.h>
#include "dietwarning.h"

extern int h_errno;

static const int hostentsize=((sizeof(struct hostent)+15)&(-16));

extern size_t __dns_buflen;
Expand Down
1 change: 1 addition & 0 deletions libcruft/getlogin.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <stdlib.h>
#include <unistd.h>

char* getlogin(void) {
return getenv("LOGNAME");
Expand Down
Loading

0 comments on commit 453e506

Please sign in to comment.