From: Thomas Veerman Date: Mon, 28 Nov 2011 10:07:55 +0000 (+0000) Subject: Fix many more comiler warnings X-Git-Tag: v3.2.0~216 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/Bv9ARM.ch10.html?a=commitdiff_plain;h=92b61c816d143bb17882d0b708793f05f72b343c;p=minix.git Fix many more comiler warnings Most warnings were harmless, some real bugs. Test set should now compile cleanly with ack, gcc, and clang. --- diff --git a/lib/libc/ansi/malloc-debug.c b/lib/libc/ansi/malloc-debug.c index 2f2b918ea..b2f466fbc 100644 --- a/lib/libc/ansi/malloc-debug.c +++ b/lib/libc/ansi/malloc-debug.c @@ -177,7 +177,7 @@ static struct block *block_find(const void *ptr) /* locate block based on pointer, then check whether it is valid */ block = (struct block *) page_round_down( - (unsigned long) ((struct block *) ptr - 1)); + (unsigned long) ((struct block *) __UNCONST(ptr) - 1)); block_check(block); LOG(("block_find; block=0x%x\n", block)); return block; diff --git a/lib/libddekit/src/usb_server.c b/lib/libddekit/src/usb_server.c index 2220497c5..faf22665a 100644 --- a/lib/libddekit/src/usb_server.c +++ b/lib/libddekit/src/usb_server.c @@ -546,7 +546,7 @@ device_connect_callback break; } - if (_devices[i].dev!= NULL) { + if (i >= MAX_DEVS) { DEBUG_MSG("Too much devices..."); } else { _devices[i].dev = dev; diff --git a/lib/librefuse/refuse_opt.c b/lib/librefuse/refuse_opt.c index f44bdc236..828dbe2c5 100644 --- a/lib/librefuse/refuse_opt.c +++ b/lib/librefuse/refuse_opt.c @@ -279,6 +279,8 @@ fuse_opt_parse(struct fuse_args *args, void *data, char *buf; int i, rv = 0; + memset(&foo, '\0', sizeof(foo)); + if (!args || !args->argv || !args->argc || !proc) return 0; diff --git a/lib/nbsd_libc/gen/minix/sysconf.c b/lib/nbsd_libc/gen/minix/sysconf.c index df6a9acd4..95aabeb7a 100644 --- a/lib/nbsd_libc/gen/minix/sysconf.c +++ b/lib/nbsd_libc/gen/minix/sysconf.c @@ -27,7 +27,7 @@ PRIVATE u32_t get_hz(void) if ((fp = fopen(_PATH_PROC "hz", "r")) != NULL) { - r = fscanf(fp, "%lu", &hz); + r = fscanf(fp, "%u", &hz); fclose(fp); diff --git a/lib/nbsd_libc/gen/minix/utime.c b/lib/nbsd_libc/gen/minix/utime.c index 1d68c9c3e..35b3f0e66 100644 --- a/lib/nbsd_libc/gen/minix/utime.c +++ b/lib/nbsd_libc/gen/minix/utime.c @@ -7,9 +7,7 @@ #include #include -PUBLIC int utime(name, timp) -_CONST char *name; -_CONST struct utimbuf *timp; +PUBLIC int utime(const char *name, const struct utimbuf *timp) { message m; @@ -21,6 +19,6 @@ _CONST struct utimbuf *timp; m.m2_l2 = timp->modtime; m.m2_i1 = strlen(name) + 1; } - m.m2_p1 = (char *) name; + m.m2_p1 = (char *) __UNCONST(name); return(_syscall(VFS_PROC_NR, UTIME, &m)); } diff --git a/lib/nbsd_libc/gen/syslog.c b/lib/nbsd_libc/gen/syslog.c index 39b4eb64e..225919c99 100644 --- a/lib/nbsd_libc/gen/syslog.c +++ b/lib/nbsd_libc/gen/syslog.c @@ -422,8 +422,10 @@ vsyslogp_r(int pri, struct syslog_data *data, const char *msgid, } /* Get connected, output the message to the local logger. */ +#ifndef __minix if (data == &sdata) mutex_lock(&syslog_mutex); +#endif opened = !data->opened; if (opened) 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); } +#ifndef __minix if (data == &sdata) mutex_unlock(&syslog_mutex); +#endif if (data != &sdata && opened) { /* preserve log tag */ @@ -541,24 +545,32 @@ openlog_unlocked_r(const char *ident, int logstat, int logfac, void openlog_r(const char *ident, int logstat, int logfac, struct syslog_data *data) { +#ifndef __minix if (data == &sdata) mutex_lock(&syslog_mutex); +#endif openlog_unlocked_r(ident, logstat, logfac, data); +#ifndef __minix if (data == &sdata) mutex_unlock(&syslog_mutex); +#endif } void closelog_r(struct syslog_data *data) { +#ifndef __minix if (data == &sdata) mutex_lock(&syslog_mutex); +#endif (void)close(data->log_file); data->log_file = -1; data->connected = 0; data->log_tag = NULL; +#ifndef __minix if (data == &sdata) mutex_unlock(&syslog_mutex); +#endif } int diff --git a/lib/nbsd_libc/sys-minix/_mcontext.c b/lib/nbsd_libc/sys-minix/_mcontext.c index bd70c9cdb..183b8a3ea 100644 --- a/lib/nbsd_libc/sys-minix/_mcontext.c +++ b/lib/nbsd_libc/sys-minix/_mcontext.c @@ -12,7 +12,7 @@ PUBLIC int setmcontext(const mcontext_t *mcp) { message m; - m.m1_p1 = (char *) mcp; + m.m1_p1 = (char *) __UNCONST(mcp); return(_syscall(PM_PROC_NR, SETMCONTEXT, &m)); } diff --git a/lib/nbsd_libc/sys-minix/bind.c b/lib/nbsd_libc/sys-minix/bind.c index dfad3b0f8..47c90d8cd 100644 --- a/lib/nbsd_libc/sys-minix/bind.c +++ b/lib/nbsd_libc/sys-minix/bind.c @@ -92,7 +92,7 @@ static int _tcp_bind(int sock, const struct sockaddr *address, nwio_tcpconf_t tcpconf; 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 DEBUG @@ -132,7 +132,7 @@ static int _udp_bind(int sock, const struct sockaddr *address, nwio_udpopt_t udpopt; 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 DEBUG @@ -193,7 +193,7 @@ static int _uds_bind(int sock, const struct sockaddr *address, 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); if (r == -1 && errno != EEXIST) { @@ -203,14 +203,14 @@ static int _uds_bind(int sock, const struct sockaddr *address, } /* perform the bind */ - r= ioctl(sock, NWIOSUDSADDR, (void *) address); + r= ioctl(sock, NWIOSUDSADDR, (void *) __UNCONST(address)); if (r == -1 && did_mknod) { /* bind() failed in pfs, so we roll back the * file system change */ - unlink(((struct sockaddr_un *) address)->sun_path); + unlink(((struct sockaddr_un *) __UNCONST(address))->sun_path); } return r; diff --git a/lib/nbsd_libc/sys-minix/chown.c b/lib/nbsd_libc/sys-minix/chown.c index 3af36961c..8a15d3211 100644 --- a/lib/nbsd_libc/sys-minix/chown.c +++ b/lib/nbsd_libc/sys-minix/chown.c @@ -16,6 +16,6 @@ PUBLIC int chown(const char *name, uid_t owner, gid_t grp) m.m1_i1 = strlen(name) + 1; m.m1_i2 = owner; m.m1_i3 = grp; - m.m1_p1 = (char *) name; + m.m1_p1 = (char *) __UNCONST(name); return(_syscall(VFS_PROC_NR, CHOWN, &m)); } diff --git a/lib/nbsd_libc/sys-minix/connect.c b/lib/nbsd_libc/sys-minix/connect.c index 66f8cc8a0..3ef50854e 100644 --- a/lib/nbsd_libc/sys-minix/connect.c +++ b/lib/nbsd_libc/sys-minix/connect.c @@ -94,7 +94,7 @@ static int _tcp_connect(int sock, const struct sockaddr *address, errno= EINVAL; return -1; } - sinp= (struct sockaddr_in *)address; + sinp= (struct sockaddr_in *) __UNCONST(address); if (sinp->sin_family != AF_INET) { errno= EINVAL; @@ -148,7 +148,7 @@ static int _udp_connect(int sock, const struct sockaddr *address, errno= EINVAL; return -1; } - sinp= (struct sockaddr_in *)address; + sinp= (struct sockaddr_in *) __UNCONST(address); if (sinp->sin_family != AF_INET) { errno= EINVAL; @@ -174,5 +174,5 @@ static int _uds_connect(int sock, const struct sockaddr *address, } /* perform the connect */ - return ioctl(sock, NWIOSUDSCONN, (void *) address); + return ioctl(sock, NWIOSUDSCONN, (void *) __UNCONST(address)); } diff --git a/lib/nbsd_libc/sys-minix/execve.c b/lib/nbsd_libc/sys-minix/execve.c index f62a278bd..499448afa 100644 --- a/lib/nbsd_libc/sys-minix/execve.c +++ b/lib/nbsd_libc/sys-minix/execve.c @@ -103,7 +103,7 @@ int execve(const char *path, char * const *argv, char * const *envp) /* We can finally make the system call. */ m.m1_i1 = strlen(path) + 1; m.m1_i2 = frame_size; - m.m1_p1 = (char *) path; + m.m1_p1 = (char *) __UNCONST(path); m.m1_p2 = frame; /* Clear unused fields */ diff --git a/lib/nbsd_libc/sys-minix/link.c b/lib/nbsd_libc/sys-minix/link.c index b4f9f71bb..960d3eba4 100644 --- a/lib/nbsd_libc/sys-minix/link.c +++ b/lib/nbsd_libc/sys-minix/link.c @@ -9,14 +9,13 @@ __weak_alias(link, _link) #endif -PUBLIC int link(name, name2) -_CONST char *name, *name2; +PUBLIC int link(const char *name, const char *name2) { message m; m.m1_i1 = strlen(name) + 1; m.m1_i2 = strlen(name2) + 1; - m.m1_p1 = (char *) name; - m.m1_p2 = (char *) name2; + m.m1_p1 = (char *) __UNCONST(name); + m.m1_p2 = (char *) __UNCONST(name2); return(_syscall(VFS_PROC_NR, LINK, &m)); } diff --git a/lib/nbsd_libc/sys-minix/loadname.c b/lib/nbsd_libc/sys-minix/loadname.c index 3ceb62d5c..0b1986776 100644 --- a/lib/nbsd_libc/sys-minix/loadname.c +++ b/lib/nbsd_libc/sys-minix/loadname.c @@ -4,9 +4,7 @@ #include -void _loadname(name, msgptr) -const char *name; -message *msgptr; +void _loadname(const char *name, message *msgptr) { /* 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 @@ -17,6 +15,6 @@ message *msgptr; k = strlen(name) + 1; msgptr->m3_i1 = k; - msgptr->m3_p1 = (char *) name; + msgptr->m3_p1 = (char *) __UNCONST(name); if (k <= M3_STRING) strcpy(msgptr->m3_ca1, name); } diff --git a/lib/nbsd_libc/sys-minix/m_closefrom.c b/lib/nbsd_libc/sys-minix/m_closefrom.c index 962e84a5b..418d439c5 100644 --- a/lib/nbsd_libc/sys-minix/m_closefrom.c +++ b/lib/nbsd_libc/sys-minix/m_closefrom.c @@ -6,7 +6,7 @@ PUBLIC int closefrom(int fd) { - int f, ok = 0, e; + int f, ok = 0, e = 0; for(f = fd; f < __MINIX_OPEN_MAX; f++) { if(close(f) >= 0) ok = 1; diff --git a/lib/nbsd_libc/sys-minix/minix_rs.c b/lib/nbsd_libc/sys-minix/minix_rs.c index f167ca433..236c55d08 100644 --- a/lib/nbsd_libc/sys-minix/minix_rs.c +++ b/lib/nbsd_libc/sys-minix/minix_rs.c @@ -28,7 +28,7 @@ int minix_rs_lookup(const char *name, endpoint_t *value) len_key = strlen(name)+1; - m.RS_NAME = (char *) name; + m.RS_NAME = (char *) __UNCONST(name); m.RS_NAME_LEN = len_key; if (_syscall(RS_PROC_NR, RS_LOOKUP, &m) != -1) { diff --git a/lib/nbsd_libc/sys-minix/mkdir.c b/lib/nbsd_libc/sys-minix/mkdir.c index 91d61b9e2..1b291b0c5 100644 --- a/lib/nbsd_libc/sys-minix/mkdir.c +++ b/lib/nbsd_libc/sys-minix/mkdir.c @@ -15,6 +15,6 @@ PUBLIC int mkdir(const char *name, mode_t mode) m.m1_i1 = strlen(name) + 1; m.m1_i2 = mode; - m.m1_p1 = (char *) name; + m.m1_p1 = (char *) __UNCONST(name); return(_syscall(VFS_PROC_NR, MKDIR, &m)); } diff --git a/lib/nbsd_libc/sys-minix/mknod.c b/lib/nbsd_libc/sys-minix/mknod.c index 19e13c515..a98070b24 100644 --- a/lib/nbsd_libc/sys-minix/mknod.c +++ b/lib/nbsd_libc/sys-minix/mknod.c @@ -14,7 +14,7 @@ PUBLIC int mknod(const char *name, mode_t mode, dev_t dev) m.m1_i1 = strlen(name) + 1; m.m1_i2 = mode; m.m1_i3 = dev; - m.m1_p1 = (char *) name; + m.m1_p1 = (char *) __UNCONST(name); m.m1_p2 = (char *) ((int) 0); /* obsolete size field */ return(_syscall(VFS_PROC_NR, MKNOD, &m)); } diff --git a/lib/nbsd_libc/sys-minix/open.c b/lib/nbsd_libc/sys-minix/open.c index 8a8e71514..b62b2adce 100644 --- a/lib/nbsd_libc/sys-minix/open.c +++ b/lib/nbsd_libc/sys-minix/open.c @@ -27,7 +27,7 @@ PUBLIC int open(const char *name, int flags) * an int, the mode was passed as an int. */ m.m1_i3 = va_arg(argp, int); - m.m1_p1 = (char *) name; + m.m1_p1 = (char *) __UNCONST(name); } else { _loadname(name, &m); m.m3_i2 = flags; diff --git a/lib/nbsd_libc/sys-minix/readlink.c b/lib/nbsd_libc/sys-minix/readlink.c index d510799d9..9d5e7bcb5 100644 --- a/lib/nbsd_libc/sys-minix/readlink.c +++ b/lib/nbsd_libc/sys-minix/readlink.c @@ -9,16 +9,13 @@ __weak_alias(readlink, _readlink) #endif -int readlink(name, buffer, bufsiz) -const char *name; -char *buffer; -size_t bufsiz; +int readlink(const char *name, char *buffer, size_t bufsiz) { message m; m.m1_i1 = strlen(name) + 1; m.m1_i2 = bufsiz; - m.m1_p1 = (char *) name; + m.m1_p1 = (char *) __UNCONST(name); m.m1_p2 = (char *) buffer; return(_syscall(VFS_PROC_NR, RDLNK, &m)); diff --git a/lib/nbsd_libc/sys-minix/rename.c b/lib/nbsd_libc/sys-minix/rename.c index df735a087..50aedbd2f 100644 --- a/lib/nbsd_libc/sys-minix/rename.c +++ b/lib/nbsd_libc/sys-minix/rename.c @@ -5,14 +5,13 @@ #include #include -int rename(name, name2) -const char *name, *name2; +int rename(const char *name, const char *name2) { message m; m.m1_i1 = strlen(name) + 1; m.m1_i2 = strlen(name2) + 1; - m.m1_p1 = (char *) name; - m.m1_p2 = (char *) name2; + m.m1_p1 = (char *) __UNCONST(name); + m.m1_p2 = (char *) __UNCONST(name2); return(_syscall(VFS_PROC_NR, RENAME, &m)); } diff --git a/lib/nbsd_libc/sys-minix/sendto.c b/lib/nbsd_libc/sys-minix/sendto.c index d746e0556..c3c039d1d 100644 --- a/lib/nbsd_libc/sys-minix/sendto.c +++ b/lib/nbsd_libc/sys-minix/sendto.c @@ -137,7 +137,7 @@ static ssize_t _udp_sendto(int sock, const void *message, size_t length, errno= EINVAL; return -1; } - sinp= (struct sockaddr_in *)dest_addr; + sinp= (struct sockaddr_in *) __UNCONST(dest_addr); if (sinp->sin_family != AF_INET) { errno= EAFNOSUPPORT; @@ -226,7 +226,7 @@ static ssize_t _uds_sendto_dgram(int sock, const void *message, size_t length, } /* set the target address */ - r= ioctl(sock, NWIOSUDSTADDR, (void *) dest_addr); + r= ioctl(sock, NWIOSUDSTADDR, (void *) __UNCONST(dest_addr)); if (r == -1) { return r; } diff --git a/lib/nbsd_libc/sys-minix/setgroups.c b/lib/nbsd_libc/sys-minix/setgroups.c index eabf1f0b1..6080596ec 100644 --- a/lib/nbsd_libc/sys-minix/setgroups.c +++ b/lib/nbsd_libc/sys-minix/setgroups.c @@ -12,7 +12,7 @@ int setgroups(int ngroups, const gid_t *gidset) { message m; - m.m1_p1 = (char *) gidset; + m.m1_p1 = (char *) __UNCONST(gidset); m.m1_i1 = ngroups; return(_syscall(PM_PROC_NR, SETGROUPS, &m)); diff --git a/lib/nbsd_libc/sys-minix/setitimer.c b/lib/nbsd_libc/sys-minix/setitimer.c index b9234112a..d69740cab 100644 --- a/lib/nbsd_libc/sys-minix/setitimer.c +++ b/lib/nbsd_libc/sys-minix/setitimer.c @@ -19,7 +19,7 @@ int setitimer(int which, const struct itimerval *_RESTRICT value, if (value == NULL) return(EINVAL); m.m1_i1 = which; - m.m1_p1 = (char *) value; + m.m1_p1 = (char *) __UNCONST(value); m.m1_p2 = (char *) ovalue; return _syscall(PM_PROC_NR, ITIMER, &m); diff --git a/lib/nbsd_libc/sys-minix/setsockopt.c b/lib/nbsd_libc/sys-minix/setsockopt.c index 2014c9051..ff4811177 100644 --- a/lib/nbsd_libc/sys-minix/setsockopt.c +++ b/lib/nbsd_libc/sys-minix/setsockopt.c @@ -90,7 +90,7 @@ static int _tcp_setsockopt(int sock, int level, int option_name, errno= EINVAL; return -1; } - i= *(int *)option_value; + i= *(const int *)option_value; if (!i) { /* 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; return -1; } - i= *(int *)option_value; + i= *(const int *)option_value; if (!i) { /* 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; return -1; } - i= *(int *)option_value; + i= *(const int *)option_value; if (i > 32*1024) { /* 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; return -1; } - i= *(int *)option_value; + i= *(const int *)option_value; if (i > 32*1024) { /* 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; return -1; } - i= *(int *)option_value; + i= *(const int *)option_value; if (i) { /* 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; return -1; } - size= *(size_t *)option_value; + size= *(const size_t *)option_value; return ioctl(sock, NWIOSUDSRCVBUF, &size); } @@ -223,7 +223,7 @@ static int _uds_setsockopt(int sock, int level, int option_name, errno= EINVAL; return -1; } - size= *(size_t *)option_value; + size= *(const size_t *)option_value; return ioctl(sock, NWIOSUDSSNDBUF, &size); } @@ -234,7 +234,7 @@ static int _uds_setsockopt(int sock, int level, int option_name, errno= EINVAL; return -1; } - i= *(int *)option_value; + i= *(const int *)option_value; if (!i) { /* 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; return -1; } - i= *(int *)option_value; + i= *(const int *)option_value; if (!i) { /* credentials can always be received. */ diff --git a/lib/nbsd_libc/sys-minix/sigaction.c b/lib/nbsd_libc/sys-minix/sigaction.c index 724484d14..8999f5911 100644 --- a/lib/nbsd_libc/sys-minix/sigaction.c +++ b/lib/nbsd_libc/sys-minix/sigaction.c @@ -6,17 +6,13 @@ int __sigreturn(void); -int sigaction(sig, act, oact) -int sig; -const struct sigaction *act; -struct sigaction *oact; +int sigaction(int sig, const struct sigaction *act, struct sigaction *oact) { message m; m.m1_i2 = sig; - /* XXX - yet more type puns because message struct is short of types. */ - m.m1_p1 = (char *) act; + m.m1_p1 = (char *) __UNCONST(act); m.m1_p2 = (char *) oact; m.m1_p3 = (char *) __sigreturn; diff --git a/lib/nbsd_libc/sys-minix/stat.c b/lib/nbsd_libc/sys-minix/stat.c index 3357acf53..21f96f7a9 100644 --- a/lib/nbsd_libc/sys-minix/stat.c +++ b/lib/nbsd_libc/sys-minix/stat.c @@ -40,7 +40,7 @@ int _stat(const char *name, struct stat *buffer) struct minix_prev_stat old_sb; m.m1_i1 = strlen(name) + 1; - m.m1_p1 = (char *) name; + m.m1_p1 = (char *) __UNCONST(name); m.m1_p2 = (char *) buffer; 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. */ m.m1_i1 = strlen(name) + 1; - m.m1_p1 = (char *) name; + m.m1_p1 = (char *) __UNCONST(name); m.m1_p2 = (char *) &old_sb; 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; m.m1_i1 = strlen(name) + 1; - m.m1_p1 = (char *) name; + m.m1_p1 = (char *) __UNCONST(name); m.m1_p2 = (char *) buffer; 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. */ m.m1_i1 = strlen(name) + 1; - m.m1_p1 = (char *) name; + m.m1_p1 = (char *) __UNCONST(name); m.m1_p2 = (char *) &old_sb; if((r = _syscall(VFS_PROC_NR, PREV_LSTAT, &m)) < 0) diff --git a/lib/nbsd_libc/sys-minix/statvfs.c b/lib/nbsd_libc/sys-minix/statvfs.c index b886c0b3e..1de8ab77a 100644 --- a/lib/nbsd_libc/sys-minix/statvfs.c +++ b/lib/nbsd_libc/sys-minix/statvfs.c @@ -9,14 +9,12 @@ __weak_alias(statvfs, _statvfs) #endif -int statvfs(name, buffer) -const char *name; -struct statvfs *buffer; +int statvfs(const char *name, struct statvfs *buffer) { message m; m.STATVFS_LEN = strlen(name) + 1; - m.STATVFS_NAME = (char *) name; + m.STATVFS_NAME = (char *) __UNCONST(name); m.STATVFS_BUF = (char *) buffer; return(_syscall(VFS_PROC_NR, STATVFS, &m)); } diff --git a/lib/nbsd_libc/sys-minix/symlink.c b/lib/nbsd_libc/sys-minix/symlink.c index 9231e2f04..6db8ff81b 100644 --- a/lib/nbsd_libc/sys-minix/symlink.c +++ b/lib/nbsd_libc/sys-minix/symlink.c @@ -9,14 +9,13 @@ __weak_alias(symlink, _symlink) #include #include -int symlink(name, name2) -const char *name, *name2; +int symlink(const char *name, const char *name2) { message m; m.m1_i1 = strlen(name) + 1; m.m1_i2 = strlen(name2) + 1; - m.m1_p1 = (char *) name; - m.m1_p2 = (char *) name2; + m.m1_p1 = (char *) __UNCONST(name); + m.m1_p2 = (char *) __UNCONST(name2); return(_syscall(VFS_PROC_NR, SYMLINK, &m)); } diff --git a/lib/nbsd_libc/sys-minix/truncate.c b/lib/nbsd_libc/sys-minix/truncate.c index 9028dd15d..e72ca9da4 100644 --- a/lib/nbsd_libc/sys-minix/truncate.c +++ b/lib/nbsd_libc/sys-minix/truncate.c @@ -13,7 +13,7 @@ __weak_alias(truncate, _truncate) int truncate(const char *_path, off_t _length) { message m; - m.m2_p1 = (char *) _path; + m.m2_p1 = (char *) __UNCONST(_path); m.m2_i1 = strlen(_path)+1; m.m2_l1 = _length; diff --git a/lib/nbsd_libc/sys-minix/write.c b/lib/nbsd_libc/sys-minix/write.c index cc9f193eb..ce5d844dc 100644 --- a/lib/nbsd_libc/sys-minix/write.c +++ b/lib/nbsd_libc/sys-minix/write.c @@ -8,16 +8,13 @@ __weak_alias(write, _write) #endif -ssize_t write(fd, buffer, nbytes) -int fd; -const void *buffer; -size_t nbytes; +ssize_t write(int fd, const void *buffer, size_t nbytes) { message m; m.m1_i1 = fd; m.m1_i2 = nbytes; - m.m1_p1 = (char *) buffer; + m.m1_p1 = (char *) __UNCONST(buffer); return(_syscall(VFS_PROC_NR, WRITE, &m)); } diff --git a/test/Makefile b/test/Makefile index 0e02e9bf0..485c6fb90 100644 --- a/test/Makefile +++ b/test/Makefile @@ -3,7 +3,7 @@ GCC?=gcc CFLAGS= -O0 -D_MINIX -D_POSIX_SOURCE -g -Wall -Werror .if ${COMPILER_TYPE} == "gnu" -CFLAGS+= -D_NETBSD_SOURCE +CFLAGS+= -D_NETBSD_SOURCE -fno-builtin LIBS+= -lm -lcompat_minix .endif CFLAGS-GCC= $(CFLAGS) -Wall -D_NETBSD_SOURCE diff --git a/test/test10.c b/test/test10.c index b5e8c28e3..e38fb1045 100644 --- a/test/test10.c +++ b/test/test10.c @@ -38,22 +38,22 @@ int main() if (getpid() == pid) if (fork() == 0) { - execl("t10a", (char *) 0); + execl("t10a", "t10a", (char *) 0); exit(0); } if (getpid() == pid) if (fork() == 0) { - execl("t10b", (char *) 0); + execl("t10b", "t10b", (char *) 0); exit(0); } if (getpid() == pid) if (fork() == 0) { - execl("t10c", (char *) 0); + execl("t10c", "t10c", (char *) 0); exit(0); } if (getpid() == pid) if (fork() == 0) { - execl("t10d", (char *) 0); + execl("t10d", "t10d", (char *) 0); exit(0); } @@ -77,7 +77,7 @@ int n; if ((pid = fork()) != 0) { wait(&n); /* wait for some child (any one) */ } else { - k = execl(name[n], (char *) 0); + k = execl(name[n], name[n], (char *) 0); errct++; printf("Child execl didn't take. file=%s errno=%d\n", name[n], errno); rmfiles(); diff --git a/test/test11.c b/test/test11.c index 1e279cf19..91ff95d0d 100644 --- a/test/test11.c +++ b/test/test11.c @@ -88,7 +88,7 @@ void test11a() * bits on. If a bug lets it unexpectedly succeed, the child * 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(). */ chmod("t11a", 06555); diff --git a/test/test20.c b/test/test20.c index 06d5370e8..d9d7836ba 100644 --- a/test/test20.c +++ b/test/test20.c @@ -63,6 +63,8 @@ int main(int argc, char *argv[]) test20d(); } quit(); + + return(-1); /* Unreachable */ } void test20a() diff --git a/test/test21.c b/test/test21.c index 0aa5abd78..b9bf8daad 100644 --- a/test/test21.c +++ b/test/test21.c @@ -65,6 +65,8 @@ char *argv[]; if (m & 020000) test21o(); } quit(); + + return(-1); /* Unreachable */ } void test21a() diff --git a/test/test22.c b/test/test22.c index 4be95d05e..e6b32d0ed 100644 --- a/test/test22.c +++ b/test/test22.c @@ -37,6 +37,8 @@ int main(int argc, char *argv[]) } quit(); + + return (-1); /* Unreachable */ } void test22a() diff --git a/test/test24.c b/test/test24.c index b17bba548..415faa004 100644 --- a/test/test24.c +++ b/test/test24.c @@ -52,6 +52,8 @@ int main(int argc, char *argv[]) if (m & 0004) test24c(); } quit(); + + return(-1); /* Unreachable */ } void test24a() diff --git a/test/test25.c b/test/test25.c index 9c7f539bc..61284f943 100644 --- a/test/test25.c +++ b/test/test25.c @@ -63,6 +63,8 @@ int main(int argc, char *argv[]) if (m & 020) test25e(); } quit(); + + return(-1); /* Unreachable */ } void test25a() diff --git a/test/test26.c b/test/test26.c index e4e455a8f..2ce07ed26 100644 --- a/test/test26.c +++ b/test/test26.c @@ -41,6 +41,8 @@ int main(int argc, char *argv[]) if (m & 0004) test26c(); } quit(); + + return(-1); /* Unreachable */ } void test26a() diff --git a/test/test27.c b/test/test27.c index a81b49caa..612e360df 100644 --- a/test/test27.c +++ b/test/test27.c @@ -47,6 +47,8 @@ int main(int argc, char *argv[]) if (m & 0004) test27c(); } quit(); + + return(-1); /* Unreachable */ } void test27a() diff --git a/test/test28.c b/test/test28.c index 4c81b4608..e38ff0476 100644 --- a/test/test28.c +++ b/test/test28.c @@ -59,6 +59,8 @@ int main(int argc, char *argv[]) if (m & 0004) test28c(); } quit(); + + return(-1); /* Unreachable */ } void test28a() diff --git a/test/test29.c b/test/test29.c index c797ca6e4..7948acdea 100644 --- a/test/test29.c +++ b/test/test29.c @@ -58,6 +58,8 @@ int main(int argc, char *argv[]) if (m & 0004) test29c(); } quit(); + + return(-1); /* Unreachable */ } void test29a() diff --git a/test/test30.c b/test/test30.c index 1ef2b4543..374490bca 100644 --- a/test/test30.c +++ b/test/test30.c @@ -57,6 +57,8 @@ int main(int argc, char *argv[]) if (m & 0004) test30c(); } quit(); + + return(-1); /* Unreachable */ } void test30a() diff --git a/test/test32.c b/test/test32.c index 48055abae..bc8a91325 100644 --- a/test/test32.c +++ b/test/test32.c @@ -49,6 +49,8 @@ int main(int argc, char *argv[]) if (m & 0004) test32c(); } quit(); + + return(-1); /* Unreachable */ } #define BUF_SIZE 1024 diff --git a/test/test34.c b/test/test34.c index 7776310c9..20c65a598 100644 --- a/test/test34.c +++ b/test/test34.c @@ -77,6 +77,8 @@ int main(int argc, char *argv[]) if (m & 0004) test34c(); } quit(); + + return(-1); /* Unreachable */ } void test34a() diff --git a/test/test37.c b/test/test37.c index 28876abb8..814b6d29a 100644 --- a/test/test37.c +++ b/test/test37.c @@ -102,6 +102,8 @@ char *argv[]; } quit(); + + return(-1); /* Unreachable */ } void test37a() diff --git a/test/test38.c b/test/test38.c index b3616b9cc..19b75715f 100644 --- a/test/test38.c +++ b/test/test38.c @@ -53,6 +53,8 @@ int main(int argc, char *argv[]) if (m & 0004) test38c(); } quit(); + + return(-1); /* Unreachable */ } void test38a() diff --git a/test/test39.c b/test/test39.c index 31d5ee3e1..724cee21b 100644 --- a/test/test39.c +++ b/test/test39.c @@ -10,7 +10,9 @@ _PROTOTYPE( void test39a, (void) ); int main(int argc, char *argv[]) { start(39); + test39a(); quit(); + return(-1); /* Unreachable */ } void test39a() diff --git a/test/test46.c b/test/test46.c index d64d5c849..5aea904e6 100644 --- a/test/test46.c +++ b/test/test46.c @@ -60,6 +60,8 @@ int main(int argc, char *argv[]) group_test(); /* Perform some tests that mimic actual use */ quit(); + + return(-1); /* Unreachable */ } void limit_test() { diff --git a/test/test53.c b/test/test53.c index ac2369382..67794aed0 100644 --- a/test/test53.c +++ b/test/test53.c @@ -276,4 +276,6 @@ int main(void) /* this was all */ quit(); + + return(-1); /* Unreachable */ } diff --git a/test/test54.c b/test/test54.c index 05094e2e0..4bbeafb47 100644 --- a/test/test54.c +++ b/test/test54.c @@ -51,4 +51,5 @@ int main(void) start(54); do_test(); quit(); + return(-1); /* Unreachable */ } diff --git a/test/test58.c b/test/test58.c index 28d8f2f74..2af60d44a 100644 --- a/test/test58.c +++ b/test/test58.c @@ -175,6 +175,7 @@ int main(int argc, char* argv[]) start(58); do_test(); quit(); + return(-1); /* Unreachable */ } diff --git a/test/test7.c b/test/test7.c index 80b0cc731..a02133b58 100644 --- a/test/test7.c +++ b/test/test7.c @@ -18,7 +18,7 @@ #include #define ITERATIONS 4 -#define MAX_ERROR 4 +#define MAX_ERROR 3 #define ITEMS 32 #define READ 10 #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}; -int subtest, errct, xfd; +#include "common.c" + +int subtes, xfd; int whence = SEEK_SET, func_code = F_SETLK; extern char **environ; @@ -50,9 +52,7 @@ _PROTOTYPE(void test7j, (void)); _PROTOTYPE(void cloexec_test, (void)); _PROTOTYPE(int set, (int how, int first, int last)); _PROTOTYPE(int locked, (int b)); -_PROTOTYPE(void e, (int n)); _PROTOTYPE(void sigfunc, (int s)); -_PROTOTYPE(void quit, (void)); int main(argc, argv) int argc; @@ -61,15 +61,10 @@ char *argv[]; int i, m = 0xFFFF; - sync(); - if (argc == 2) m = atoi(argv[1]); if (m == 0) cloexec_test(); /* important; do not remove this! */ - printf("Test 7 "); - fflush(stdout); - system("rm -rf DIR_07; mkdir DIR_07"); - chdir("DIR_07"); + start(7); for (i = 0; i < ITERATIONS; i++) { if (m & 00001) timed_test(test7a); @@ -690,39 +685,8 @@ int b; 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) 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); - } -}