Fix many more comiler warnings

Most warnings were harmless, some real bugs. Test set should now compile
cleanly with ack, gcc, and clang.
This commit is contained in:
Thomas Veerman 2011-11-28 10:07:55 +00:00
parent b4fb061802
commit 92b61c816d
53 changed files with 120 additions and 125 deletions

View file

@ -177,7 +177,7 @@ static struct block *block_find(const void *ptr)
/* locate block based on pointer, then check whether it is valid */ /* locate block based on pointer, then check whether it is valid */
block = (struct block *) page_round_down( block = (struct block *) page_round_down(
(unsigned long) ((struct block *) ptr - 1)); (unsigned long) ((struct block *) __UNCONST(ptr) - 1));
block_check(block); block_check(block);
LOG(("block_find; block=0x%x\n", block)); LOG(("block_find; block=0x%x\n", block));
return block; return block;

View file

@ -546,7 +546,7 @@ device_connect_callback
break; break;
} }
if (_devices[i].dev!= NULL) { if (i >= MAX_DEVS) {
DEBUG_MSG("Too much devices..."); DEBUG_MSG("Too much devices...");
} else { } else {
_devices[i].dev = dev; _devices[i].dev = dev;

View file

@ -279,6 +279,8 @@ fuse_opt_parse(struct fuse_args *args, void *data,
char *buf; char *buf;
int i, rv = 0; int i, rv = 0;
memset(&foo, '\0', sizeof(foo));
if (!args || !args->argv || !args->argc || !proc) if (!args || !args->argv || !args->argc || !proc)
return 0; return 0;

View file

@ -27,7 +27,7 @@ PRIVATE u32_t get_hz(void)
if ((fp = fopen(_PATH_PROC "hz", "r")) != NULL) if ((fp = fopen(_PATH_PROC "hz", "r")) != NULL)
{ {
r = fscanf(fp, "%lu", &hz); r = fscanf(fp, "%u", &hz);
fclose(fp); fclose(fp);

View file

@ -7,9 +7,7 @@
#include <string.h> #include <string.h>
#include <utime.h> #include <utime.h>
PUBLIC int utime(name, timp) PUBLIC int utime(const char *name, const struct utimbuf *timp)
_CONST char *name;
_CONST struct utimbuf *timp;
{ {
message m; message m;
@ -21,6 +19,6 @@ _CONST struct utimbuf *timp;
m.m2_l2 = timp->modtime; m.m2_l2 = timp->modtime;
m.m2_i1 = strlen(name) + 1; m.m2_i1 = strlen(name) + 1;
} }
m.m2_p1 = (char *) name; m.m2_p1 = (char *) __UNCONST(name);
return(_syscall(VFS_PROC_NR, UTIME, &m)); return(_syscall(VFS_PROC_NR, UTIME, &m));
} }

View file

@ -422,8 +422,10 @@ vsyslogp_r(int pri, struct syslog_data *data, const char *msgid,
} }
/* Get connected, output the message to the local logger. */ /* Get connected, output the message to the local logger. */
#ifndef __minix
if (data == &sdata) if (data == &sdata)
mutex_lock(&syslog_mutex); mutex_lock(&syslog_mutex);
#endif
opened = !data->opened; opened = !data->opened;
if (opened) if (opened)
openlog_unlocked_r(data->log_tag, data->log_stat, 0, data); openlog_unlocked_r(data->log_tag, data->log_stat, 0, data);
@ -460,8 +462,10 @@ vsyslogp_r(int pri, struct syslog_data *data, const char *msgid,
(void)close(fd); (void)close(fd);
} }
#ifndef __minix
if (data == &sdata) if (data == &sdata)
mutex_unlock(&syslog_mutex); mutex_unlock(&syslog_mutex);
#endif
if (data != &sdata && opened) { if (data != &sdata && opened) {
/* preserve log tag */ /* preserve log tag */
@ -541,24 +545,32 @@ openlog_unlocked_r(const char *ident, int logstat, int logfac,
void void
openlog_r(const char *ident, int logstat, int logfac, struct syslog_data *data) openlog_r(const char *ident, int logstat, int logfac, struct syslog_data *data)
{ {
#ifndef __minix
if (data == &sdata) if (data == &sdata)
mutex_lock(&syslog_mutex); mutex_lock(&syslog_mutex);
#endif
openlog_unlocked_r(ident, logstat, logfac, data); openlog_unlocked_r(ident, logstat, logfac, data);
#ifndef __minix
if (data == &sdata) if (data == &sdata)
mutex_unlock(&syslog_mutex); mutex_unlock(&syslog_mutex);
#endif
} }
void void
closelog_r(struct syslog_data *data) closelog_r(struct syslog_data *data)
{ {
#ifndef __minix
if (data == &sdata) if (data == &sdata)
mutex_lock(&syslog_mutex); mutex_lock(&syslog_mutex);
#endif
(void)close(data->log_file); (void)close(data->log_file);
data->log_file = -1; data->log_file = -1;
data->connected = 0; data->connected = 0;
data->log_tag = NULL; data->log_tag = NULL;
#ifndef __minix
if (data == &sdata) if (data == &sdata)
mutex_unlock(&syslog_mutex); mutex_unlock(&syslog_mutex);
#endif
} }
int int

View file

@ -12,7 +12,7 @@ PUBLIC int setmcontext(const mcontext_t *mcp)
{ {
message m; message m;
m.m1_p1 = (char *) mcp; m.m1_p1 = (char *) __UNCONST(mcp);
return(_syscall(PM_PROC_NR, SETMCONTEXT, &m)); return(_syscall(PM_PROC_NR, SETMCONTEXT, &m));
} }

View file

@ -92,7 +92,7 @@ static int _tcp_bind(int sock, const struct sockaddr *address,
nwio_tcpconf_t tcpconf; nwio_tcpconf_t tcpconf;
struct sockaddr_in *sinp; struct sockaddr_in *sinp;
sinp= (struct sockaddr_in *)address; sinp= (struct sockaddr_in *) __UNCONST(address);
if (sinp->sin_family != AF_INET || address_len < sizeof(*sinp)) if (sinp->sin_family != AF_INET || address_len < sizeof(*sinp))
{ {
#if DEBUG #if DEBUG
@ -132,7 +132,7 @@ static int _udp_bind(int sock, const struct sockaddr *address,
nwio_udpopt_t udpopt; nwio_udpopt_t udpopt;
struct sockaddr_in *sinp; struct sockaddr_in *sinp;
sinp= (struct sockaddr_in *)address; sinp= (struct sockaddr_in *) __UNCONST(address);
if (sinp->sin_family != AF_INET || address_len < sizeof(*sinp)) if (sinp->sin_family != AF_INET || address_len < sizeof(*sinp))
{ {
#if DEBUG #if DEBUG
@ -193,7 +193,7 @@ static int _uds_bind(int sock, const struct sockaddr *address,
did_mknod = 0; did_mknod = 0;
r = mknod(((struct sockaddr_un *) address)->sun_path, r = mknod(((struct sockaddr_un *) __UNCONST(address))->sun_path,
S_IFSOCK|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH, 0); S_IFSOCK|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH, 0);
if (r == -1 && errno != EEXIST) { if (r == -1 && errno != EEXIST) {
@ -203,14 +203,14 @@ static int _uds_bind(int sock, const struct sockaddr *address,
} }
/* perform the bind */ /* perform the bind */
r= ioctl(sock, NWIOSUDSADDR, (void *) address); r= ioctl(sock, NWIOSUDSADDR, (void *) __UNCONST(address));
if (r == -1 && did_mknod) { if (r == -1 && did_mknod) {
/* bind() failed in pfs, so we roll back the /* bind() failed in pfs, so we roll back the
* file system change * file system change
*/ */
unlink(((struct sockaddr_un *) address)->sun_path); unlink(((struct sockaddr_un *) __UNCONST(address))->sun_path);
} }
return r; return r;

View file

@ -16,6 +16,6 @@ PUBLIC int chown(const char *name, uid_t owner, gid_t grp)
m.m1_i1 = strlen(name) + 1; m.m1_i1 = strlen(name) + 1;
m.m1_i2 = owner; m.m1_i2 = owner;
m.m1_i3 = grp; m.m1_i3 = grp;
m.m1_p1 = (char *) name; m.m1_p1 = (char *) __UNCONST(name);
return(_syscall(VFS_PROC_NR, CHOWN, &m)); return(_syscall(VFS_PROC_NR, CHOWN, &m));
} }

View file

@ -94,7 +94,7 @@ static int _tcp_connect(int sock, const struct sockaddr *address,
errno= EINVAL; errno= EINVAL;
return -1; return -1;
} }
sinp= (struct sockaddr_in *)address; sinp= (struct sockaddr_in *) __UNCONST(address);
if (sinp->sin_family != AF_INET) if (sinp->sin_family != AF_INET)
{ {
errno= EINVAL; errno= EINVAL;
@ -148,7 +148,7 @@ static int _udp_connect(int sock, const struct sockaddr *address,
errno= EINVAL; errno= EINVAL;
return -1; return -1;
} }
sinp= (struct sockaddr_in *)address; sinp= (struct sockaddr_in *) __UNCONST(address);
if (sinp->sin_family != AF_INET) if (sinp->sin_family != AF_INET)
{ {
errno= EINVAL; errno= EINVAL;
@ -174,5 +174,5 @@ static int _uds_connect(int sock, const struct sockaddr *address,
} }
/* perform the connect */ /* perform the connect */
return ioctl(sock, NWIOSUDSCONN, (void *) address); return ioctl(sock, NWIOSUDSCONN, (void *) __UNCONST(address));
} }

View file

@ -103,7 +103,7 @@ int execve(const char *path, char * const *argv, char * const *envp)
/* We can finally make the system call. */ /* We can finally make the system call. */
m.m1_i1 = strlen(path) + 1; m.m1_i1 = strlen(path) + 1;
m.m1_i2 = frame_size; m.m1_i2 = frame_size;
m.m1_p1 = (char *) path; m.m1_p1 = (char *) __UNCONST(path);
m.m1_p2 = frame; m.m1_p2 = frame;
/* Clear unused fields */ /* Clear unused fields */

View file

@ -9,14 +9,13 @@
__weak_alias(link, _link) __weak_alias(link, _link)
#endif #endif
PUBLIC int link(name, name2) PUBLIC int link(const char *name, const char *name2)
_CONST char *name, *name2;
{ {
message m; message m;
m.m1_i1 = strlen(name) + 1; m.m1_i1 = strlen(name) + 1;
m.m1_i2 = strlen(name2) + 1; m.m1_i2 = strlen(name2) + 1;
m.m1_p1 = (char *) name; m.m1_p1 = (char *) __UNCONST(name);
m.m1_p2 = (char *) name2; m.m1_p2 = (char *) __UNCONST(name2);
return(_syscall(VFS_PROC_NR, LINK, &m)); return(_syscall(VFS_PROC_NR, LINK, &m));
} }

View file

@ -4,9 +4,7 @@
#include <string.h> #include <string.h>
void _loadname(name, msgptr) void _loadname(const char *name, message *msgptr)
const char *name;
message *msgptr;
{ {
/* This function is used to load a string into a type m3 message. If the /* This function is used to load a string into a type m3 message. If the
* string fits in the message, it is copied there. If not, a pointer to * string fits in the message, it is copied there. If not, a pointer to
@ -17,6 +15,6 @@ message *msgptr;
k = strlen(name) + 1; k = strlen(name) + 1;
msgptr->m3_i1 = k; msgptr->m3_i1 = k;
msgptr->m3_p1 = (char *) name; msgptr->m3_p1 = (char *) __UNCONST(name);
if (k <= M3_STRING) strcpy(msgptr->m3_ca1, name); if (k <= M3_STRING) strcpy(msgptr->m3_ca1, name);
} }

View file

@ -6,7 +6,7 @@
PUBLIC int closefrom(int fd) PUBLIC int closefrom(int fd)
{ {
int f, ok = 0, e; int f, ok = 0, e = 0;
for(f = fd; f < __MINIX_OPEN_MAX; f++) { for(f = fd; f < __MINIX_OPEN_MAX; f++) {
if(close(f) >= 0) if(close(f) >= 0)
ok = 1; ok = 1;

View file

@ -28,7 +28,7 @@ int minix_rs_lookup(const char *name, endpoint_t *value)
len_key = strlen(name)+1; len_key = strlen(name)+1;
m.RS_NAME = (char *) name; m.RS_NAME = (char *) __UNCONST(name);
m.RS_NAME_LEN = len_key; m.RS_NAME_LEN = len_key;
if (_syscall(RS_PROC_NR, RS_LOOKUP, &m) != -1) { if (_syscall(RS_PROC_NR, RS_LOOKUP, &m) != -1) {

View file

@ -15,6 +15,6 @@ PUBLIC int mkdir(const char *name, mode_t mode)
m.m1_i1 = strlen(name) + 1; m.m1_i1 = strlen(name) + 1;
m.m1_i2 = mode; m.m1_i2 = mode;
m.m1_p1 = (char *) name; m.m1_p1 = (char *) __UNCONST(name);
return(_syscall(VFS_PROC_NR, MKDIR, &m)); return(_syscall(VFS_PROC_NR, MKDIR, &m));
} }

View file

@ -14,7 +14,7 @@ PUBLIC int mknod(const char *name, mode_t mode, dev_t dev)
m.m1_i1 = strlen(name) + 1; m.m1_i1 = strlen(name) + 1;
m.m1_i2 = mode; m.m1_i2 = mode;
m.m1_i3 = dev; m.m1_i3 = dev;
m.m1_p1 = (char *) name; m.m1_p1 = (char *) __UNCONST(name);
m.m1_p2 = (char *) ((int) 0); /* obsolete size field */ m.m1_p2 = (char *) ((int) 0); /* obsolete size field */
return(_syscall(VFS_PROC_NR, MKNOD, &m)); return(_syscall(VFS_PROC_NR, MKNOD, &m));
} }

View file

@ -27,7 +27,7 @@ PUBLIC int open(const char *name, int flags)
* an int, the mode was passed as an int. * an int, the mode was passed as an int.
*/ */
m.m1_i3 = va_arg(argp, int); m.m1_i3 = va_arg(argp, int);
m.m1_p1 = (char *) name; m.m1_p1 = (char *) __UNCONST(name);
} else { } else {
_loadname(name, &m); _loadname(name, &m);
m.m3_i2 = flags; m.m3_i2 = flags;

View file

@ -9,16 +9,13 @@
__weak_alias(readlink, _readlink) __weak_alias(readlink, _readlink)
#endif #endif
int readlink(name, buffer, bufsiz) int readlink(const char *name, char *buffer, size_t bufsiz)
const char *name;
char *buffer;
size_t bufsiz;
{ {
message m; message m;
m.m1_i1 = strlen(name) + 1; m.m1_i1 = strlen(name) + 1;
m.m1_i2 = bufsiz; m.m1_i2 = bufsiz;
m.m1_p1 = (char *) name; m.m1_p1 = (char *) __UNCONST(name);
m.m1_p2 = (char *) buffer; m.m1_p2 = (char *) buffer;
return(_syscall(VFS_PROC_NR, RDLNK, &m)); return(_syscall(VFS_PROC_NR, RDLNK, &m));

View file

@ -5,14 +5,13 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
int rename(name, name2) int rename(const char *name, const char *name2)
const char *name, *name2;
{ {
message m; message m;
m.m1_i1 = strlen(name) + 1; m.m1_i1 = strlen(name) + 1;
m.m1_i2 = strlen(name2) + 1; m.m1_i2 = strlen(name2) + 1;
m.m1_p1 = (char *) name; m.m1_p1 = (char *) __UNCONST(name);
m.m1_p2 = (char *) name2; m.m1_p2 = (char *) __UNCONST(name2);
return(_syscall(VFS_PROC_NR, RENAME, &m)); return(_syscall(VFS_PROC_NR, RENAME, &m));
} }

View file

@ -137,7 +137,7 @@ static ssize_t _udp_sendto(int sock, const void *message, size_t length,
errno= EINVAL; errno= EINVAL;
return -1; return -1;
} }
sinp= (struct sockaddr_in *)dest_addr; sinp= (struct sockaddr_in *) __UNCONST(dest_addr);
if (sinp->sin_family != AF_INET) if (sinp->sin_family != AF_INET)
{ {
errno= EAFNOSUPPORT; errno= EAFNOSUPPORT;
@ -226,7 +226,7 @@ static ssize_t _uds_sendto_dgram(int sock, const void *message, size_t length,
} }
/* set the target address */ /* set the target address */
r= ioctl(sock, NWIOSUDSTADDR, (void *) dest_addr); r= ioctl(sock, NWIOSUDSTADDR, (void *) __UNCONST(dest_addr));
if (r == -1) { if (r == -1) {
return r; return r;
} }

View file

@ -12,7 +12,7 @@ int setgroups(int ngroups, const gid_t *gidset)
{ {
message m; message m;
m.m1_p1 = (char *) gidset; m.m1_p1 = (char *) __UNCONST(gidset);
m.m1_i1 = ngroups; m.m1_i1 = ngroups;
return(_syscall(PM_PROC_NR, SETGROUPS, &m)); return(_syscall(PM_PROC_NR, SETGROUPS, &m));

View file

@ -19,7 +19,7 @@ int setitimer(int which, const struct itimerval *_RESTRICT value,
if (value == NULL) return(EINVAL); if (value == NULL) return(EINVAL);
m.m1_i1 = which; m.m1_i1 = which;
m.m1_p1 = (char *) value; m.m1_p1 = (char *) __UNCONST(value);
m.m1_p2 = (char *) ovalue; m.m1_p2 = (char *) ovalue;
return _syscall(PM_PROC_NR, ITIMER, &m); return _syscall(PM_PROC_NR, ITIMER, &m);

View file

@ -90,7 +90,7 @@ static int _tcp_setsockopt(int sock, int level, int option_name,
errno= EINVAL; errno= EINVAL;
return -1; return -1;
} }
i= *(int *)option_value; i= *(const int *)option_value;
if (!i) if (!i)
{ {
/* At the moment there is no way to turn off /* At the moment there is no way to turn off
@ -108,7 +108,7 @@ static int _tcp_setsockopt(int sock, int level, int option_name,
errno= EINVAL; errno= EINVAL;
return -1; return -1;
} }
i= *(int *)option_value; i= *(const int *)option_value;
if (!i) if (!i)
{ {
/* At the moment there is no way to turn off /* At the moment there is no way to turn off
@ -126,7 +126,7 @@ static int _tcp_setsockopt(int sock, int level, int option_name,
errno= EINVAL; errno= EINVAL;
return -1; return -1;
} }
i= *(int *)option_value; i= *(const int *)option_value;
if (i > 32*1024) if (i > 32*1024)
{ {
/* The receive buffer is limited to 32K at the moment. /* The receive buffer is limited to 32K at the moment.
@ -146,7 +146,7 @@ static int _tcp_setsockopt(int sock, int level, int option_name,
errno= EINVAL; errno= EINVAL;
return -1; return -1;
} }
i= *(int *)option_value; i= *(const int *)option_value;
if (i > 32*1024) if (i > 32*1024)
{ {
/* The send buffer is limited to 32K at the moment. /* The send buffer is limited to 32K at the moment.
@ -166,7 +166,7 @@ static int _tcp_setsockopt(int sock, int level, int option_name,
errno= EINVAL; errno= EINVAL;
return -1; return -1;
} }
i= *(int *)option_value; i= *(const int *)option_value;
if (i) if (i)
{ {
/* At the moment there is no way to turn on /* At the moment there is no way to turn on
@ -212,7 +212,7 @@ static int _uds_setsockopt(int sock, int level, int option_name,
errno= EINVAL; errno= EINVAL;
return -1; return -1;
} }
size= *(size_t *)option_value; size= *(const size_t *)option_value;
return ioctl(sock, NWIOSUDSRCVBUF, &size); return ioctl(sock, NWIOSUDSRCVBUF, &size);
} }
@ -223,7 +223,7 @@ static int _uds_setsockopt(int sock, int level, int option_name,
errno= EINVAL; errno= EINVAL;
return -1; return -1;
} }
size= *(size_t *)option_value; size= *(const size_t *)option_value;
return ioctl(sock, NWIOSUDSSNDBUF, &size); return ioctl(sock, NWIOSUDSSNDBUF, &size);
} }
@ -234,7 +234,7 @@ static int _uds_setsockopt(int sock, int level, int option_name,
errno= EINVAL; errno= EINVAL;
return -1; return -1;
} }
i= *(int *)option_value; i= *(const int *)option_value;
if (!i) if (!i)
{ {
/* At the moment there is no way to turn off /* At the moment there is no way to turn off
@ -253,7 +253,7 @@ static int _uds_setsockopt(int sock, int level, int option_name,
errno= EINVAL; errno= EINVAL;
return -1; return -1;
} }
i= *(int *)option_value; i= *(const int *)option_value;
if (!i) if (!i)
{ {
/* credentials can always be received. */ /* credentials can always be received. */

View file

@ -6,17 +6,13 @@
int __sigreturn(void); int __sigreturn(void);
int sigaction(sig, act, oact) int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
int sig;
const struct sigaction *act;
struct sigaction *oact;
{ {
message m; message m;
m.m1_i2 = sig; m.m1_i2 = sig;
/* XXX - yet more type puns because message struct is short of types. */ m.m1_p1 = (char *) __UNCONST(act);
m.m1_p1 = (char *) act;
m.m1_p2 = (char *) oact; m.m1_p2 = (char *) oact;
m.m1_p3 = (char *) __sigreturn; m.m1_p3 = (char *) __sigreturn;

View file

@ -40,7 +40,7 @@ int _stat(const char *name, struct stat *buffer)
struct minix_prev_stat old_sb; struct minix_prev_stat old_sb;
m.m1_i1 = strlen(name) + 1; m.m1_i1 = strlen(name) + 1;
m.m1_p1 = (char *) name; m.m1_p1 = (char *) __UNCONST(name);
m.m1_p2 = (char *) buffer; m.m1_p2 = (char *) buffer;
if((r = _syscall(VFS_PROC_NR, STAT, &m)) >= 0 || errno != ENOSYS) if((r = _syscall(VFS_PROC_NR, STAT, &m)) >= 0 || errno != ENOSYS)
@ -52,7 +52,7 @@ int _stat(const char *name, struct stat *buffer)
* User has struct stat (buffer), VFS still fills minix_prev_stat. * User has struct stat (buffer), VFS still fills minix_prev_stat.
*/ */
m.m1_i1 = strlen(name) + 1; m.m1_i1 = strlen(name) + 1;
m.m1_p1 = (char *) name; m.m1_p1 = (char *) __UNCONST(name);
m.m1_p2 = (char *) &old_sb; m.m1_p2 = (char *) &old_sb;
if((r = _syscall(VFS_PROC_NR, PREV_STAT, &m)) < 0) if((r = _syscall(VFS_PROC_NR, PREV_STAT, &m)) < 0)
@ -104,7 +104,7 @@ int _lstat(const char *name, struct stat *buffer)
struct minix_prev_stat old_sb; struct minix_prev_stat old_sb;
m.m1_i1 = strlen(name) + 1; m.m1_i1 = strlen(name) + 1;
m.m1_p1 = (char *) name; m.m1_p1 = (char *) __UNCONST(name);
m.m1_p2 = (char *) buffer; m.m1_p2 = (char *) buffer;
if((r = _syscall(VFS_PROC_NR, LSTAT, &m)) >= 0 || errno != ENOSYS) if((r = _syscall(VFS_PROC_NR, LSTAT, &m)) >= 0 || errno != ENOSYS)
@ -116,7 +116,7 @@ int _lstat(const char *name, struct stat *buffer)
* User has struct stat (buffer), VFS still fills minix_prev_stat. * User has struct stat (buffer), VFS still fills minix_prev_stat.
*/ */
m.m1_i1 = strlen(name) + 1; m.m1_i1 = strlen(name) + 1;
m.m1_p1 = (char *) name; m.m1_p1 = (char *) __UNCONST(name);
m.m1_p2 = (char *) &old_sb; m.m1_p2 = (char *) &old_sb;
if((r = _syscall(VFS_PROC_NR, PREV_LSTAT, &m)) < 0) if((r = _syscall(VFS_PROC_NR, PREV_LSTAT, &m)) < 0)

View file

@ -9,14 +9,12 @@
__weak_alias(statvfs, _statvfs) __weak_alias(statvfs, _statvfs)
#endif #endif
int statvfs(name, buffer) int statvfs(const char *name, struct statvfs *buffer)
const char *name;
struct statvfs *buffer;
{ {
message m; message m;
m.STATVFS_LEN = strlen(name) + 1; m.STATVFS_LEN = strlen(name) + 1;
m.STATVFS_NAME = (char *) name; m.STATVFS_NAME = (char *) __UNCONST(name);
m.STATVFS_BUF = (char *) buffer; m.STATVFS_BUF = (char *) buffer;
return(_syscall(VFS_PROC_NR, STATVFS, &m)); return(_syscall(VFS_PROC_NR, STATVFS, &m));
} }

View file

@ -9,14 +9,13 @@ __weak_alias(symlink, _symlink)
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
int symlink(name, name2) int symlink(const char *name, const char *name2)
const char *name, *name2;
{ {
message m; message m;
m.m1_i1 = strlen(name) + 1; m.m1_i1 = strlen(name) + 1;
m.m1_i2 = strlen(name2) + 1; m.m1_i2 = strlen(name2) + 1;
m.m1_p1 = (char *) name; m.m1_p1 = (char *) __UNCONST(name);
m.m1_p2 = (char *) name2; m.m1_p2 = (char *) __UNCONST(name2);
return(_syscall(VFS_PROC_NR, SYMLINK, &m)); return(_syscall(VFS_PROC_NR, SYMLINK, &m));
} }

View file

@ -13,7 +13,7 @@ __weak_alias(truncate, _truncate)
int truncate(const char *_path, off_t _length) int truncate(const char *_path, off_t _length)
{ {
message m; message m;
m.m2_p1 = (char *) _path; m.m2_p1 = (char *) __UNCONST(_path);
m.m2_i1 = strlen(_path)+1; m.m2_i1 = strlen(_path)+1;
m.m2_l1 = _length; m.m2_l1 = _length;

View file

@ -8,16 +8,13 @@
__weak_alias(write, _write) __weak_alias(write, _write)
#endif #endif
ssize_t write(fd, buffer, nbytes) ssize_t write(int fd, const void *buffer, size_t nbytes)
int fd;
const void *buffer;
size_t nbytes;
{ {
message m; message m;
m.m1_i1 = fd; m.m1_i1 = fd;
m.m1_i2 = nbytes; m.m1_i2 = nbytes;
m.m1_p1 = (char *) buffer; m.m1_p1 = (char *) __UNCONST(buffer);
return(_syscall(VFS_PROC_NR, WRITE, &m)); return(_syscall(VFS_PROC_NR, WRITE, &m));
} }

View file

@ -3,7 +3,7 @@
GCC?=gcc GCC?=gcc
CFLAGS= -O0 -D_MINIX -D_POSIX_SOURCE -g -Wall -Werror CFLAGS= -O0 -D_MINIX -D_POSIX_SOURCE -g -Wall -Werror
.if ${COMPILER_TYPE} == "gnu" .if ${COMPILER_TYPE} == "gnu"
CFLAGS+= -D_NETBSD_SOURCE CFLAGS+= -D_NETBSD_SOURCE -fno-builtin
LIBS+= -lm -lcompat_minix LIBS+= -lm -lcompat_minix
.endif .endif
CFLAGS-GCC= $(CFLAGS) -Wall -D_NETBSD_SOURCE CFLAGS-GCC= $(CFLAGS) -Wall -D_NETBSD_SOURCE

View file

@ -38,22 +38,22 @@ int main()
if (getpid() == pid) if (getpid() == pid)
if (fork() == 0) { if (fork() == 0) {
execl("t10a", (char *) 0); execl("t10a", "t10a", (char *) 0);
exit(0); exit(0);
} }
if (getpid() == pid) if (getpid() == pid)
if (fork() == 0) { if (fork() == 0) {
execl("t10b", (char *) 0); execl("t10b", "t10b", (char *) 0);
exit(0); exit(0);
} }
if (getpid() == pid) if (getpid() == pid)
if (fork() == 0) { if (fork() == 0) {
execl("t10c", (char *) 0); execl("t10c", "t10c", (char *) 0);
exit(0); exit(0);
} }
if (getpid() == pid) if (getpid() == pid)
if (fork() == 0) { if (fork() == 0) {
execl("t10d", (char *) 0); execl("t10d", "t10d", (char *) 0);
exit(0); exit(0);
} }
@ -77,7 +77,7 @@ int n;
if ((pid = fork()) != 0) { if ((pid = fork()) != 0) {
wait(&n); /* wait for some child (any one) */ wait(&n); /* wait for some child (any one) */
} else { } else {
k = execl(name[n], (char *) 0); k = execl(name[n], name[n], (char *) 0);
errct++; errct++;
printf("Child execl didn't take. file=%s errno=%d\n", name[n], errno); printf("Child execl didn't take. file=%s errno=%d\n", name[n], errno);
rmfiles(); rmfiles();

View file

@ -88,7 +88,7 @@ void test11a()
* bits on. If a bug lets it unexpectedly succeed, the child * bits on. If a bug lets it unexpectedly succeed, the child
* will print an error message since the arguments are wrong. * will print an error message since the arguments are wrong.
*/ */
execl("t11a", (char *) 0, envp); /* should fail -- no X bits */ execl("t11a", "t11a", (char *) 0); /* should fail -- no X bits */
/* Control should come here after the failed execl(). */ /* Control should come here after the failed execl(). */
chmod("t11a", 06555); chmod("t11a", 06555);

View file

@ -63,6 +63,8 @@ int main(int argc, char *argv[])
test20d(); test20d();
} }
quit(); quit();
return(-1); /* Unreachable */
} }
void test20a() void test20a()

View file

@ -65,6 +65,8 @@ char *argv[];
if (m & 020000) test21o(); if (m & 020000) test21o();
} }
quit(); quit();
return(-1); /* Unreachable */
} }
void test21a() void test21a()

View file

@ -37,6 +37,8 @@ int main(int argc, char *argv[])
} }
quit(); quit();
return (-1); /* Unreachable */
} }
void test22a() void test22a()

View file

@ -52,6 +52,8 @@ int main(int argc, char *argv[])
if (m & 0004) test24c(); if (m & 0004) test24c();
} }
quit(); quit();
return(-1); /* Unreachable */
} }
void test24a() void test24a()

View file

@ -63,6 +63,8 @@ int main(int argc, char *argv[])
if (m & 020) test25e(); if (m & 020) test25e();
} }
quit(); quit();
return(-1); /* Unreachable */
} }
void test25a() void test25a()

View file

@ -41,6 +41,8 @@ int main(int argc, char *argv[])
if (m & 0004) test26c(); if (m & 0004) test26c();
} }
quit(); quit();
return(-1); /* Unreachable */
} }
void test26a() void test26a()

View file

@ -47,6 +47,8 @@ int main(int argc, char *argv[])
if (m & 0004) test27c(); if (m & 0004) test27c();
} }
quit(); quit();
return(-1); /* Unreachable */
} }
void test27a() void test27a()

View file

@ -59,6 +59,8 @@ int main(int argc, char *argv[])
if (m & 0004) test28c(); if (m & 0004) test28c();
} }
quit(); quit();
return(-1); /* Unreachable */
} }
void test28a() void test28a()

View file

@ -58,6 +58,8 @@ int main(int argc, char *argv[])
if (m & 0004) test29c(); if (m & 0004) test29c();
} }
quit(); quit();
return(-1); /* Unreachable */
} }
void test29a() void test29a()

View file

@ -57,6 +57,8 @@ int main(int argc, char *argv[])
if (m & 0004) test30c(); if (m & 0004) test30c();
} }
quit(); quit();
return(-1); /* Unreachable */
} }
void test30a() void test30a()

View file

@ -49,6 +49,8 @@ int main(int argc, char *argv[])
if (m & 0004) test32c(); if (m & 0004) test32c();
} }
quit(); quit();
return(-1); /* Unreachable */
} }
#define BUF_SIZE 1024 #define BUF_SIZE 1024

View file

@ -77,6 +77,8 @@ int main(int argc, char *argv[])
if (m & 0004) test34c(); if (m & 0004) test34c();
} }
quit(); quit();
return(-1); /* Unreachable */
} }
void test34a() void test34a()

View file

@ -102,6 +102,8 @@ char *argv[];
} }
quit(); quit();
return(-1); /* Unreachable */
} }
void test37a() void test37a()

View file

@ -53,6 +53,8 @@ int main(int argc, char *argv[])
if (m & 0004) test38c(); if (m & 0004) test38c();
} }
quit(); quit();
return(-1); /* Unreachable */
} }
void test38a() void test38a()

View file

@ -10,7 +10,9 @@ _PROTOTYPE( void test39a, (void) );
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
start(39); start(39);
test39a();
quit(); quit();
return(-1); /* Unreachable */
} }
void test39a() void test39a()

View file

@ -60,6 +60,8 @@ int main(int argc, char *argv[])
group_test(); /* Perform some tests that mimic actual use */ group_test(); /* Perform some tests that mimic actual use */
quit(); quit();
return(-1); /* Unreachable */
} }
void limit_test() { void limit_test() {

View file

@ -276,4 +276,6 @@ int main(void)
/* this was all */ /* this was all */
quit(); quit();
return(-1); /* Unreachable */
} }

View file

@ -51,4 +51,5 @@ int main(void)
start(54); start(54);
do_test(); do_test();
quit(); quit();
return(-1); /* Unreachable */
} }

View file

@ -175,6 +175,7 @@ int main(int argc, char* argv[])
start(58); start(58);
do_test(); do_test();
quit(); quit();
return(-1); /* Unreachable */
} }

View file

@ -18,7 +18,7 @@
#include <setjmp.h> #include <setjmp.h>
#define ITERATIONS 4 #define ITERATIONS 4
#define MAX_ERROR 4 #define MAX_ERROR 3
#define ITEMS 32 #define ITEMS 32
#define READ 10 #define READ 10
#define WRITE 20 #define WRITE 20
@ -28,7 +28,9 @@
char buf[ITEMS] = {0,1,2,3,4,5,6,7,8,9,8,7,6,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9}; char buf[ITEMS] = {0,1,2,3,4,5,6,7,8,9,8,7,6,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9};
int subtest, errct, xfd; #include "common.c"
int subtes, xfd;
int whence = SEEK_SET, func_code = F_SETLK; int whence = SEEK_SET, func_code = F_SETLK;
extern char **environ; extern char **environ;
@ -50,9 +52,7 @@ _PROTOTYPE(void test7j, (void));
_PROTOTYPE(void cloexec_test, (void)); _PROTOTYPE(void cloexec_test, (void));
_PROTOTYPE(int set, (int how, int first, int last)); _PROTOTYPE(int set, (int how, int first, int last));
_PROTOTYPE(int locked, (int b)); _PROTOTYPE(int locked, (int b));
_PROTOTYPE(void e, (int n));
_PROTOTYPE(void sigfunc, (int s)); _PROTOTYPE(void sigfunc, (int s));
_PROTOTYPE(void quit, (void));
int main(argc, argv) int main(argc, argv)
int argc; int argc;
@ -61,15 +61,10 @@ char *argv[];
int i, m = 0xFFFF; int i, m = 0xFFFF;
sync();
if (argc == 2) m = atoi(argv[1]); if (argc == 2) m = atoi(argv[1]);
if (m == 0) cloexec_test(); /* important; do not remove this! */ if (m == 0) cloexec_test(); /* important; do not remove this! */
printf("Test 7 ");
fflush(stdout);
system("rm -rf DIR_07; mkdir DIR_07"); start(7);
chdir("DIR_07");
for (i = 0; i < ITERATIONS; i++) { for (i = 0; i < ITERATIONS; i++) {
if (m & 00001) timed_test(test7a); if (m & 00001) timed_test(test7a);
@ -690,39 +685,8 @@ int b;
return(WEXITSTATUS(status)); return(WEXITSTATUS(status));
} }
void e(n)
int n;
{
int err_num = errno; /* save errno in case printf clobbers it */
printf("Subtest %d, error %d errno=%d ", subtest, n, errno);
fflush(stdout);
errno = err_num; /* restore errno, just in case */
perror("");
if (errct++ > MAX_ERROR) {
printf("Too many errors; test aborted\n");
chdir("..");
system("rm -rf DIR*");
exit(1);
}
}
void sigfunc(s) void sigfunc(s)
int s; /* for ANSI */ int s; /* for ANSI */
{ {
} }
void quit()
{
chdir("..");
system("rm -rf DIR*");
if (errct == 0) {
printf("ok\n");
exit(0);
} else {
printf("%d errors\n", errct);
exit(1);
}
}