Fix a ton of compiler warnings

This patch fixes most of current reasons to generate compiler warnings.
The changes consist of:
 - adding missing casts
 - hiding or unhiding function declarations
 - including headers where missing
 - add __UNCONST when assigning a const char * to a char *
 - adding missing return statements
 - changing some types from unsigned to signed, as the code seems to want
   signed ints
 - converting old-style function definitions to current style (i.e.,
   void func(param1, param2) short param1, param2; {...} to
   void func (short param1, short param2) {...})
 - making the compiler silent about signed vs unsigned comparisons. We
   have too many of those in the new libc to fix.

A number of bugs in the test set were fixed. These bugs were never
triggered with our old libc. Consequently, these tests are now forced to
link with the new libc or they will generate errors (in particular tests 43
and 55).

Most changes in NetBSD libc are limited to moving aroudn "#ifndef __minix"
or stuff related to Minix-specific things (code in sys-minix or gen/minix).
This commit is contained in:
Thomas Veerman 2011-11-14 10:07:49 +00:00
parent 85b8fbe72b
commit a209c3ae12
87 changed files with 389 additions and 751 deletions

View file

@ -64,8 +64,8 @@ _PROTOTYPE( int devman_usb_device_add, (struct devman_usb_dev *dev));
_PROTOTYPE( int devman_usb_device_remove, (struct devman_usb_dev *dev));
_PROTOTYPE( void devman_usb_device_delete, (struct devman_usb_dev *udev));
_PROTOTYPE( int devman_handle_msg, (message *m));
_PROTOTYPE( int devman_usb_init,(devman_usb_bind_cb_t bind_cb,
devman_usb_bind_cb_t unbind_cb));
_PROTOTYPE( void devman_usb_init, (devman_usb_bind_cb_t bind_cb,
devman_usb_bind_cb_t unbind_cb) );
#endif

View file

@ -7,9 +7,7 @@
#ifndef _CTYPE_H
#define _CTYPE_H
#ifndef _MINIX_ANSI_H
#include <minix/ansi.h>
#endif
extern char __ctype[]; /* property array defined in chartab.c */
@ -39,13 +37,13 @@ _PROTOTYPE( int toupper, (int _c) ); /* convert to upper-case */
_PROTOTYPE( int toascii, (int _c) ); /* convert to 7-bit ASCII */
/* Macros for identifying character classes. */
#define isalnum(c) ((__ctype+1)[c]&(_U|_L|_N))
#define isalpha(c) ((__ctype+1)[c]&(_U|_L))
#define iscntrl(c) ((__ctype+1)[c]&_C)
#define isgraph(c) ((__ctype+1)[c]&(_P|_U|_L|_N))
#define ispunct(c) ((__ctype+1)[c]&_P)
#define isspace(c) ((__ctype+1)[c]&_S)
#define isxdigit(c) ((__ctype+1)[c]&(_N|_X))
#define isalnum(c) ((__ctype+1)[(unsigned char)(c)]&(_U|_L|_N))
#define isalpha(c) ((__ctype+1)[(unsigned char)(c)]&(_U|_L))
#define iscntrl(c) ((__ctype+1)[(unsigned char)(c)]&_C)
#define isgraph(c) ((__ctype+1)[(unsigned char)(c)]&(_P|_U|_L|_N))
#define ispunct(c) ((__ctype+1)[(unsigned char)(c)]&_P)
#define isspace(c) ((__ctype+1)[(unsigned char)(c)]&_S)
#define isxdigit(c) ((__ctype+1)[(unsigned char)(c)]&(_N|_X))
#define isdigit(c) ((unsigned) ((c)-'0') < 10)
#define islower(c) ((unsigned) ((c)-'a') < 26)

View file

@ -169,7 +169,9 @@ archive_entry_linkify(struct archive_entry_linkresolver *res,
struct archive_entry **e, struct archive_entry **f)
{
struct links_entry *le;
#ifndef __minix
struct archive_entry *t;
#endif
*f = NULL; /* Default: Don't return a second entry. */

View file

@ -168,10 +168,10 @@ struct tar {
int64_t entry_padding;
int64_t realsize;
#else
size_t entry_bytes_remaining;
int32_t entry_bytes_remaining;
off_t entry_offset;
off_t entry_padding;
size_t realsize;
int32_t realsize;
#endif
struct sparse_block *sparse_list;
struct sparse_block *sparse_last;
@ -538,7 +538,7 @@ archive_read_format_tar_skip(struct archive_read *a)
#ifndef __minix
int64_t bytes_skipped;
#else
size_t bytes_skipped;
int32_t bytes_skipped;
#endif
struct tar* tar;

View file

@ -9,6 +9,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <unistd.h>
#define mmap minix_mmap
#define munmap minix_munmap

View file

@ -8,7 +8,6 @@ ssize_t asyn_write(asynchio_t *asyn, int fd, const void *buf, size_t len)
/* Nonblocking write(). (See asyn_read()). */
{
asynfd_t *afd;
ssize_t result;
asyn->asyn_more++;

View file

@ -173,37 +173,6 @@ static int _udp_bind(int socket, const struct sockaddr *address,
return r;
}
static int in_group(uid_t uid, gid_t gid)
{
int r, i;
int size;
gid_t *list;
size = sysconf(_SC_NGROUPS_MAX);
list = malloc(size * sizeof(gid_t));
if (list == NULL) {
return 0;
}
r= getgroups(size, list);
if (r == -1) {
free(list);
return 0;
}
for (i = 0; i < r; i++) {
if (gid == list[i]) {
free(list);
return 1;
}
}
free(list);
return 0;
}
static int _uds_bind(int socket, const struct sockaddr *address,
socklen_t address_len, struct sockaddr_un *uds_addr)
{

View file

@ -7,6 +7,8 @@
#include <minix/const.h>
#include <minix/devman.h>
#include <minix/safecopies.h>
#include <minix/sysutil.h>
#include <minix/ds.h>
#include "local.h"
@ -192,7 +194,6 @@ PUBLIC endpoint_t devman_get_ep()
PUBLIC int devman_init()
{
int res;
message msg;
/* get the endpoint of the HCD */
res = ds_retrieve_label_endpt("devman", &devman_ep);

View file

@ -6,6 +6,7 @@
#include <minix/const.h>
#include <minix/devman.h>
#include <minix/usb.h>
#include <minix/sysutil.h>
#include "local.h"
@ -291,7 +292,7 @@ PUBLIC int devman_usb_device_remove(struct devman_usb_dev *dev)
/****************************************************************************
* devman_usb_init *
***************************************************************************/
PUBLIC int devman_usb_init
PUBLIC void devman_usb_init
(int (*_bind_cb) (struct devman_usb_bind_cb_data *data, endpoint_t ep),
int (*_unbind_cb) (struct devman_usb_bind_cb_data *data, endpoint_t ep))
{

View file

@ -903,8 +903,8 @@ retry_mode:
int arg;
#endif
int d;
char *ap;
#ifdef INET6
char *ap;
char hname[INET6_ADDRSTRLEN];
#endif

View file

@ -11,5 +11,5 @@ int fputs(const char *s, FILE *fp)
{
assert(fp == stdout || fp == stderr);
puts(s);
return puts(s);
}

View file

@ -14,7 +14,6 @@
#include <errno.h>
#include <assert.h>
static int no_debug = -1;
#define CHECK_DBG(statement)
#if _EM_WSIZE == _EM_PSIZE

View file

@ -4,6 +4,7 @@
#include <minix/libminixfs.h>
#include <minix/dmap.h>
#include <minix/u64.h>
#include <minix/sysutil.h>
#include <sys/param.h>
#include <errno.h>

View file

@ -1,7 +1,9 @@
#include <minix/vfsif.h>
#include <minix/type.h>
#include <minix/syslib.h>
#include <assert.h>
#include <string.h>
#include "minixfs.h"

View file

@ -23,7 +23,7 @@ int source;
source %= RANDOM_SOURCES;
r_next= rand->bin[source].r_next;
read_tsc(&tsc_high, &tsc_low);
read_tsc((u32_t *) &tsc_high, (u32_t *) &tsc_low);
rand->bin[source].r_buf[r_next] = tsc_low;
if (rand->bin[source].r_size < RANDOM_ELEMENTS) {
rand->bin[source].r_size ++;

View file

@ -13,6 +13,7 @@
#include "syslib.h"
#include <timers.h>
#include <minix/sysutil.h>
PRIVATE timer_t *timers = NULL;
PRIVATE int expiring = 0;

View file

@ -26,8 +26,8 @@ void util_timer_start(util_timingdata_t *timingdata, char *name)
return;
}
read_tsc(&timingdata->starttimes[HIGHCOUNT],
&timingdata->starttimes[LOWCOUNT]);
read_tsc((u32_t *) &timingdata->starttimes[HIGHCOUNT],
(u32_t *) &timingdata->starttimes[LOWCOUNT]);
}
void util_timer_end(util_timingdata_t *timingdata)
@ -35,7 +35,7 @@ void util_timer_end(util_timingdata_t *timingdata)
unsigned long h, l, d = 0;
int bin;
read_tsc(&h, &l);
read_tsc((u32_t *) &h, (u32_t *) &l);
if (!timingdata->starttimes[HIGHCOUNT]) {
panic("timer stopped but not started");
return;

View file

@ -3,6 +3,7 @@
#include <stddef.h>
#include <ctype.h>
#include <limits.h>
#include <string.h>
/* vprintf() uses kputc() to print characters. */
void kputc(int c);
@ -210,12 +211,12 @@ __xfputc(int c, void *arg)
int _vprintf(const char *fmt, va_list argp)
{
__fvprintf(__xfputc, fmt, argp, stdout);
return __fvprintf(__xfputc, fmt, argp, stdout);
}
int _vfprintf(FILE *fp, const char *fmt, va_list argp)
{
__fvprintf(__xfputc, fmt, argp, fp);
return __fvprintf(__xfputc, fmt, argp, fp);
}
#endif

View file

@ -187,7 +187,7 @@ PRIVATE void _usb_urb_complete(struct usb_driver *ud, long urb_id)
#endif
ud->urb_completion(urb);
} else {
printf("WARN: _usb_urb_complete: did not find URB with ID %d", urb_id);
printf("WARN: _usb_urb_complete: did not find URB with ID %ld", urb_id);
}
}

View file

@ -209,9 +209,9 @@ pw_cont(int sig)
void
pw_init(void)
{
#ifndef __minix
struct rlimit rlim;
#ifndef __minix
/* Unlimited resource limits. */
rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY;
(void)setrlimit(RLIMIT_CPU, &rlim);

View file

@ -117,9 +117,13 @@ openpty(int *amaster, int *aslave, char *name, struct termios *term,
linep = line;
if (chown(line, getuid(), ttygid) == 0 &&
chmod(line, mode) == 0 &&
#ifndef __minix
revoke(line) == 0 &&
#endif
(slave = open(line, O_RDWR, 0)) != -1) {
#ifndef __minix
gotit:
#endif
*amaster = master;
*aslave = slave;
if (name)

View file

@ -6,6 +6,7 @@
#include <minix/const.h>
#include <minix/ipc.h>
#include <minix/com.h>
#include <minix/syslib.h>
#include "vassert.h"
VAssert_StateWrapper vassert_state ALIGNED(VASSERT_PAGE_SIZE);
@ -39,6 +40,9 @@ typedef uint32 VA;
static sigjmp_buf segv_jmp;
void libvassert_process_backdoor(uint32, uint32, uint32, reg_t *, reg_t *,
reg_t *, reg_t *);
/*
*---------------------------------------------------------------------
*
@ -143,7 +147,7 @@ VAssert_Init(void)
* to adjust the given address for segments)
*/
if(sys_umap(SELF, D, page_address, 1, &ph)) {
if(sys_umap(SELF, D, page_address, 1, (phys_bytes *) &ph)) {
printf("VAssert_Init: sys_umap failed\n");
return -1;
}

View file

@ -98,7 +98,7 @@ getttyent(void)
line = fparseln(tf, &len, &lineno, NULL, FPARSELN_UNESCALL);
if (line == NULL) {
if (errno != 0)
warn(__func__);
warn("%s", __func__);
return NULL;
}
for (p = line; *p && isspace((unsigned char)*p); p++)

View file

@ -11,17 +11,19 @@
__weak_alias(getdomainname, _getdomainname)
#endif
int getdomainname(char *domain, size_t size)
int getdomainname(char *result, size_t size)
{
char nodename[256];
char *dot;
char *domain;
if (gethostname(nodename, sizeof(nodename)) < 0)
return -1;
nodename[sizeof(nodename)-1]= 0;
if ((dot= strchr(nodename, '.')) == nil) dot= ".";
if ((domain = strchr(nodename, '.')) != NULL)
strncpy(result, domain+1, size);
else
result[0] = '\0';
strncpy(domain, dot+1, size);
if (size > 0) domain[size-1]= 0;
if (size > 0) result[size-1]= 0;
return 0;
}

View file

@ -4,7 +4,6 @@
#include <sys/cdefs.h>
#include "namespace.h"
#define _MINIX
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>

View file

@ -90,9 +90,7 @@ static void dumpmode __P((BITCMD *));
* bits) followed by a '+' (set bits).
*/
mode_t
getmode(bbox, omode)
const void *bbox;
mode_t omode;
getmode(const void *bbox, mode_t omode)
{
const BITCMD *set;
mode_t clrval, newmode, value;
@ -178,8 +176,7 @@ common: if (set->cmd2 & CMD2_CLR) {
#define STANDARD_BITS (S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO)
void *
setmode(p)
const char *p;
setmode(const char *p)
{
int serrno;
char op, *ep;
@ -367,9 +364,7 @@ out:
}
static BITCMD *
addcmd(set, op, who, oparg, mask)
BITCMD *set;
mode_t oparg, who, op, mask;
addcmd(BITCMD *set, mode_t op, mode_t who, mode_t oparg, mode_t mask)
{
_DIAGASSERT(set != NULL);

View file

@ -44,7 +44,10 @@ ulimit(int cmd, ...)
{
va_list ap;
struct rlimit rlimit;
long int new_limit, result;
long int result;
#ifndef __minix
long int new_limit;
#endif
va_start(ap, cmd);

View file

@ -72,20 +72,20 @@ struct {
} __link_set_all_categories = {
.__ls_length = 7,
.__ls_items = {
[0] = &_generic_LC_ALL_desc,
[1] = &_dummy_LC_COLLATE_desc,
[0] = __UNCONST(&_generic_LC_ALL_desc),
[1] = __UNCONST(&_dummy_LC_COLLATE_desc),
#ifdef WITH_RUNE
[2] = &_citrus_LC_CTYPE_desc,
[3] = &_citrus_LC_MONETARY_desc,
[4] = &_citrus_LC_NUMERIC_desc,
[5] = &_citrus_LC_TIME_desc,
[6] = &_citrus_LC_MESSAGES_desc,
[2] = __UNCONST(&_citrus_LC_CTYPE_desc),
[3] = __UNCONST(&_citrus_LC_MONETARY_desc),
[4] = __UNCONST(&_citrus_LC_NUMERIC_desc),
[5] = __UNCONST(&_citrus_LC_TIME_desc),
[6] = __UNCONST(&_citrus_LC_MESSAGES_desc),
#else
[2] = &_localeio_LC_CTYPE_desc,
[3] = &_localeio_LC_MONETARY_desc,
[4] = &_localeio_LC_NUMERIC_desc,
[5] = &_localeio_LC_TIME_desc,
[6] = &_localeio_LC_MESSAGES_desc,
[2] = __UNCONST(&_localeio_LC_CTYPE_desc),
[3] = __UNCONST(&_localeio_LC_MONETARY_desc),
[4] = __UNCONST(&_localeio_LC_NUMERIC_desc),
[5] = __UNCONST(&_localeio_LC_TIME_desc),
[6] = __UNCONST(&_localeio_LC_MESSAGES_desc),
#endif
},
};

View file

@ -58,8 +58,8 @@ __guard_setup(void)
{
#ifndef __minix
int mib[2];
#endif
size_t len;
#endif
if (__stack_chk_guard[0] != 0)
return;

View file

@ -111,8 +111,8 @@ static int getnameinfo_atalk __P((const struct sockaddr *, socklen_t, char *,
static int getnameinfo_link __P((const struct sockaddr *, socklen_t, char *,
socklen_t, char *, socklen_t, int));
#endif /* __minix */
static int hexname __P((const u_int8_t *, size_t, char *, socklen_t));
#endif /* __minix */
/*
* Top-level getnameinfo() code. Look at the address family, and pick an
@ -579,7 +579,6 @@ getnameinfo_link(const struct sockaddr *sa, socklen_t salen,
(size_t)sdl->sdl_alen, host, hostlen);
}
}
#endif /* !__minix */
static int
hexname(cp, len, host, hostlen)
@ -605,3 +604,4 @@ hexname(cp, len, host, hostlen)
}
return 0;
}
#endif /* !__minix */

View file

@ -27,7 +27,7 @@ getifaddrs(struct ifaddrs **ifap)
memset(&addr, 0, sizeof(addr));
memset(&netmask, 0, sizeof(netmask));
ifa.ifa_next = NULL;
ifa.ifa_name = "ip";
ifa.ifa_name = __UNCONST("ip");
addr.sin_family = netmask.sin_family = AF_INET;
ifa.ifa_addr = (struct sockaddr *) &addr;
ifa.ifa_netmask = (struct sockaddr *) &netmask;
@ -36,8 +36,9 @@ getifaddrs(struct ifaddrs **ifap)
if(fd < 0) {
char *ipd;
if(!(ipd=getenv("IP_DEVICE")))
ipd="/dev/ip";
if(!(ipd = getenv("IP_DEVICE")))
ipd = __UNCONST("/dev/ip");
if((fd = open(ipd, O_RDWR)) < 0)
return -1;
}

View file

@ -1068,8 +1068,6 @@ Aerror(const res_state statp, FILE *file, const char *string, int error,
char hbuf[NI_MAXHOST];
char sbuf[NI_MAXSERV];
alen = alen;
if ((statp->options & RES_DEBUG) != 0U) {
if (getnameinfo(address, (socklen_t)alen, hbuf, sizeof(hbuf),
sbuf, sizeof(sbuf), niflags)) {

View file

@ -35,9 +35,12 @@ __RCSID("$NetBSD: memcpy_chk.c,v 1.4 2008/04/28 20:23:00 martin Exp $");
#include <ssp/ssp.h>
#include <string.h>
#include <ssp/string.h>
#undef memcpy
#if __SSP_FORTIFY_LEVEL > 0
void *
__memcpy_chk(void * __restrict dst, const void * __restrict src, size_t len,
size_t slen)
@ -46,3 +49,5 @@ __memcpy_chk(void * __restrict dst, const void * __restrict src, size_t len,
__chk_fail();
return memcpy(dst, src, len);
}
#endif

View file

@ -38,6 +38,8 @@ __RCSID("$NetBSD: memmove_chk.c,v 1.4 2008/04/28 20:23:00 martin Exp $");
#undef memmove
#if __SSP_FORTIFY_LEVEL > 0
void *
__memmove_chk(void *dst, void *src, size_t len,
size_t slen)
@ -46,3 +48,5 @@ __memmove_chk(void *dst, void *src, size_t len,
__chk_fail();
return memmove(dst, src, len);
}
#endif

View file

@ -38,6 +38,8 @@ __RCSID("$NetBSD: memset_chk.c,v 1.4 2008/04/28 20:23:00 martin Exp $");
#undef memset
#if __SSP_FORTIFY_LEVEL > 0
void *
__memset_chk(void * __restrict dst, int val, size_t len, size_t slen)
{
@ -45,3 +47,5 @@ __memset_chk(void * __restrict dst, int val, size_t len, size_t slen)
__chk_fail();
return memset(dst, val, len);
}
#endif

View file

@ -36,6 +36,8 @@ __RCSID("$NetBSD: strcat_chk.c,v 1.4 2009/11/17 20:44:26 drochner Exp $");
#include <ssp/ssp.h>
#include <string.h>
#if __SSP_FORTIFY_LEVEL > 0
char *
__strcat_chk(char * __restrict dst, const char * __restrict src, size_t slen)
{
@ -58,3 +60,5 @@ __strcat_chk(char * __restrict dst, const char * __restrict src, size_t slen)
*d = '\0';
return dst;
}
#endif

View file

@ -38,6 +38,8 @@ __RCSID("$NetBSD: strcpy_chk.c,v 1.5 2010/12/28 16:19:25 christos Exp $");
#undef memcpy
#if __SSP_FORTIFY_LEVEL > 0
char *
__strcpy_chk(char * __restrict dst, const char * __restrict src, size_t slen)
{
@ -48,3 +50,5 @@ __strcpy_chk(char * __restrict dst, const char * __restrict src, size_t slen)
return memcpy(dst, src, len + 1);
}
#endif

View file

@ -37,6 +37,8 @@ __RCSID("$NetBSD: strncat_chk.c,v 1.4 2009/11/17 20:44:26 drochner Exp $");
#include <string.h>
#include <stdio.h>
#if __SSP_FORTIFY_LEVEL > 0
char *
__strncat_chk(char * __restrict dst, const char * __restrict src, size_t len,
size_t slen)
@ -68,3 +70,5 @@ __strncat_chk(char * __restrict dst, const char * __restrict src, size_t len,
*d = '\0';
return dst;
}
#endif

View file

@ -38,6 +38,8 @@ __RCSID("$NetBSD: strncpy_chk.c,v 1.4 2008/04/28 20:23:00 martin Exp $");
#undef strncpy
#if __SSP_FORTIFY_LEVEL > 0
char *
__strncpy_chk(char * __restrict dst, const char * __restrict src, size_t len,
size_t slen)
@ -47,3 +49,5 @@ __strncpy_chk(char * __restrict dst, const char * __restrict src, size_t len,
return strncpy(dst, src, len);
}
#endif

View file

@ -36,7 +36,7 @@ __RCSID("$NetBSD: strfmon.c,v 1.7 2009/01/30 23:46:03 lukem Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#if defined(__NetBSD__)
#if defined(__NetBSD__) || defined(__minix)
#include "namespace.h"
#include <monetary.h>
#endif

View file

@ -51,9 +51,7 @@ __RCSID("$NetBSD: strmode.c,v 1.18 2006/10/07 22:04:18 apb Exp $");
#if !HAVE_STRMODE
void
strmode(mode, p)
mode_t mode;
char *p;
strmode(mode_t mode, char *p)
{
_DIAGASSERT(p != NULL);

View file

@ -15,6 +15,9 @@
#include <limits.h>
#include <string.h>
/* libc-private interface */
int __getcwd(char *, size_t);
static int addpath(const char *path, char **ap, const char *entry)
/* Add the name of a directory entry at the front of the path being built.
* Note that the result always starts with a slash.
@ -59,7 +62,8 @@ int __getcwd(char *path, size_t size)
struct stat above, current, tmp;
struct dirent *entry;
DIR *d;
char *p, *up, *dotdot;
char *p, *up;
const char *dotdot = "..";
int cycle;
if (path == NULL || size <= 1) { errno= EINVAL; return -1; }
@ -70,7 +74,6 @@ int __getcwd(char *path, size_t size)
if (stat(".", &current) < 0) return -1;
while (1) {
dotdot= "..";
if (stat(dotdot, &above) < 0) { recover(p); return -1; }
if (above.st_dev == current.st_dev

View file

@ -180,37 +180,6 @@ static int _udp_bind(int sock, const struct sockaddr *address,
return r;
}
static int in_group(uid_t uid, gid_t gid)
{
int r, i;
int size;
gid_t *list;
size = sysconf(_SC_NGROUPS_MAX);
list = malloc(size * sizeof(gid_t));
if (list == NULL) {
return 0;
}
r= getgroups(size, list);
if (r == -1) {
free(list);
return 0;
}
for (i = 0; i < r; i++) {
if (gid == list[i]) {
free(list);
return 1;
}
}
free(list);
return 0;
}
static int _uds_bind(int sock, const struct sockaddr *address,
socklen_t address_len, struct sockaddr_un *uds_addr)
{

View file

@ -17,7 +17,7 @@ PUBLIC int getgroups(int ngroups, gid_t *arr)
{
message m;
m.m1_i1 = ngroups;
m.m1_p1 = arr;
m.m1_p1 = (char *) arr;
return(_syscall(PM_PROC_NR, GETGROUPS, &m));
}

View file

@ -1,8 +1,9 @@
#include <sys/cdefs.h>
#include <lib.h>
#include "namespace.h"
#include <lib.h>
#include <unistd.h>
#include <string.h>
pid_t getsid(pid_t p)
{

View file

@ -46,8 +46,8 @@ int mountflags;
int use_existing = 0;
/* Default values. */
if (type == NULL) type = FSDEFAULT;
if (args == NULL) args = "";
if (type == NULL) type = __UNCONST(FSDEFAULT);
if (args == NULL) args = __UNCONST("");
reuse = 0;
/* Check mount flags */
@ -79,7 +79,7 @@ int mountflags;
sprintf(label, "fs_%.12s", p);
} else {
if (stat(name, &statbuf) < 0) return -1;
sprintf(label, "fs_%04x%x", statbuf.st_dev, statbuf.st_ino);
sprintf(label, "fs_%04x%llx", statbuf.st_dev, statbuf.st_ino);
}
} else {
/* label to long? */

View file

@ -92,7 +92,7 @@ static ssize_t _uds_sendmsg_dgram(int sock, const struct msghdr *msg,
{
struct msg_control msg_ctrl;
struct sockaddr_un *dest_addr;
int i, r;
int r;
if (flags != 0) {
#if DEBUG

View file

@ -38,7 +38,6 @@ ssize_t sendto(int sock, const void *message, size_t length, int flags,
int r;
nwio_tcpopt_t tcpopt;
nwio_udpopt_t udpopt;
struct sockaddr_un uds_addr;
int uds_sotype = -1;
r= ioctl(sock, NWIOGTCPOPT, &tcpopt);

View file

@ -31,10 +31,9 @@ static void prev_stat2new_stat(struct stat *new, struct minix_prev_stat *prev)
new->st_ctimespec.tv_sec = prev->st_ctime;
}
int _stat(const char *name, struct stat *buffer);
int _stat(name, buffer)
const char *name;
struct stat *buffer;
int _stat(const char *name, struct stat *buffer)
{
message m;
int r;
@ -65,9 +64,9 @@ struct stat *buffer;
return r;
}
int _fstat(fd, buffer)
int fd;
struct stat *buffer;
int _fstat(int fd, struct stat *buffer);
int _fstat(int fd, struct stat *buffer)
{
message m;
int r;
@ -96,9 +95,9 @@ struct stat *buffer;
return r;
}
int _lstat(name, buffer)
const char *name;
struct stat *buffer;
int _lstat(const char *name, struct stat *buffer);
int _lstat(const char *name, struct stat *buffer)
{
message m;
int r;

View file

@ -5,6 +5,7 @@
#include <sys/cdefs.h>
#include "namespace.h"
#include <lib.h>
#include <sys/utsname.h>
int sysuname(int req, int field, char *value, size_t len)
{

View file

@ -55,7 +55,9 @@ tcsetattr(fd, opt, t)
int fd, opt;
const struct termios *t;
{
#ifndef __minix
struct termios localterm;
#endif
_DIAGASSERT(fd != -1);
_DIAGASSERT(t != NULL);
@ -71,11 +73,11 @@ tcsetattr(fd, opt, t)
#endif /* __minix */
switch (opt & ~TCSASOFT) {
case TCSANOW:
return (ioctl(fd, TIOCSETA, t));
return (ioctl(fd, TIOCSETA, __UNCONST(t)));
case TCSADRAIN:
return (ioctl(fd, TIOCSETAW, t));
return (ioctl(fd, TIOCSETAW, __UNCONST(t)));
case TCSAFLUSH:
return (ioctl(fd, TIOCSETAF, t));
return (ioctl(fd, TIOCSETAF, __UNCONST(t)));
default:
errno = EINVAL;
return (-1);

View file

@ -10,6 +10,7 @@
#include <fcntl.h>
#include <pwd.h>
#include <grp.h>
#include <stdio.h>
/*
* group_from_gid()

View file

@ -119,10 +119,10 @@ static void __test_sse(void) __attribute__ ((constructor));
static void __test_sse(void)
{
#ifndef __minix
size_t oldlen = sizeof(__HAS_SSE);
int rv;
#ifndef __minix
rv = sysctlbyname("machdep.sse", &__HAS_SSE, &oldlen, NULL, 0);
if (rv == -1)
#endif

View file

@ -1,6 +1,7 @@
#define _SYSTEM 1
#include <lib.h>
#include <unistd.h>
#include <string.h>
/* return -1, when the query itself or the processing of query has errors.
* return 1, when there are more processes waiting to be queried.
@ -25,7 +26,6 @@ PUBLIC int vm_query_exit(int *endpt)
PUBLIC int vm_watch_exit(endpoint_t ep)
{
message m;
int r;
memset(&m, 0, sizeof(m));
m.VM_WE_EP = ep;

View file

@ -45,19 +45,19 @@
#include <sys/ctype_bits.h>
#define isdigit(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_N))
#define islower(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_L))
#define isspace(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_S))
#define ispunct(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_P))
#define isupper(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_U))
#define isalpha(c) ((int)((_ctype_ + 1)[(c)] & (_CTYPE_U|_CTYPE_L)))
#define isxdigit(c) ((int)((_ctype_ + 1)[(c)] & (_CTYPE_N|_CTYPE_X)))
#define isalnum(c) ((int)((_ctype_ + 1)[(c)] & (_CTYPE_U|_CTYPE_L|_CTYPE_N)))
#define isprint(c) ((int)((_ctype_ + 1)[(c)] & (_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N|_CTYPE_B)))
#define isgraph(c) ((int)((_ctype_ + 1)[(c)] & (_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N)))
#define iscntrl(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_C))
#define tolower(c) ((int)((_tolower_tab_ + 1)[(c)]))
#define toupper(c) ((int)((_toupper_tab_ + 1)[(c)]))
#define isdigit(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & _CTYPE_N))
#define islower(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & _CTYPE_L))
#define isspace(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & _CTYPE_S))
#define ispunct(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & _CTYPE_P))
#define isupper(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & _CTYPE_U))
#define isalpha(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & (_CTYPE_U|_CTYPE_L)))
#define isxdigit(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & (_CTYPE_N|_CTYPE_X)))
#define isalnum(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & (_CTYPE_U|_CTYPE_L|_CTYPE_N)))
#define isprint(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & (_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N|_CTYPE_B)))
#define isgraph(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & (_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N)))
#define iscntrl(c) ((int)((_ctype_ + 1)[(unsigned char)(c)] & _CTYPE_C))
#define tolower(c) ((int)((_tolower_tab_ + 1)[(unsigned char)(c)]))
#define toupper(c) ((int)((_toupper_tab_ + 1)[(unsigned char)(c)]))
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
#define isascii(c) ((unsigned)(c) <= 0177)

View file

@ -274,6 +274,9 @@ struct cmsghdr {
#include <sys/cdefs.h>
__BEGIN_DECLS
int __cmsg_alignbytes(void);
__END_DECLS
__BEGIN_DECLS
int accept(int, struct sockaddr * __restrict, socklen_t * __restrict);

View file

@ -33,7 +33,7 @@
#define OPEN_MAX __MINIX_OPEN_MAX /* max open files per process */
#endif
#define PATH_MAX __MINIX_PATH_MAX /* # chars in a path name */
#define PIPE_BUF 7168 /* # bytes in atomic write to a pipe */
#define PIPE_BUF 32768 /* # bytes in atomic write to a pipe */
#define BC_BASE_MAX INT_MAX /* max ibase/obase values in bc(1) */
#define BC_DIM_MAX 65535 /* max array elements in bc(1) */

View file

@ -226,9 +226,7 @@ int nice(int);
__aconst char *crypt(const char *, const char *);
int encrypt(char *, int);
char *getpass(const char *);
#ifndef __minix
pid_t getsid(pid_t);
#endif /* !__minix */
#endif
@ -356,12 +354,12 @@ int issetugid(void);
int nfssvc(int, void *);
#ifndef __minix
int profil(char *, size_t, u_long, u_int);
#endif /* !__minix */
#ifndef __PSIGNAL_DECLARED
#define __PSIGNAL_DECLARED
/* also in signal.h */
void psignal(int, const char *);
#endif /* __PSIGNAL_DECLARED */
#endif /* !__minix */
int rcmd(char **, int, const char *, const char *, const char *, int *);
#ifdef __minix
int reboot(int, ...);

View file

@ -1,2 +1,2 @@
AFLAGS+=-D__ASSEMBLY__ -D_EM_WSIZE=4
CFLAGS+= -fno-builtin -Wall -march=i586
CFLAGS+= -fno-builtin -Wall -march=i586 -Wno-sign-compare

View file

@ -1,7 +1,7 @@
# Makefile for the tests.
GCC?=gcc
CFLAGS= -O0 -D_MINIX -D_POSIX_SOURCE -g
CFLAGS= -O0 -D_MINIX -D_POSIX_SOURCE -g -Wall -Werror
.if ${COMPILER_TYPE} == "gnu"
CFLAGS+= -D_NETBSD_SOURCE
LIBS+= -lm -lcompat_minix
@ -15,12 +15,12 @@ OBJ= test1 test2 test3 test4 test5 test6 test7 test8 test9 \
test21 test22 test23 test25 test26 test27 test28 test29 \
test30 test31 test32 test34 test35 test36 test37 test38 \
test39 t10a t11a t11b test40 t40a t40b t40c t40d t40e t40f test41 \
test42 test45 test47 test48 test49 test50 test51 test52 test53 \
test54 test55 test56 test58
test42 test45 test47 test49 test50 test51 test52 test53 \
test54 test56 test58
BIGOBJ= test20 test24
ROOTOBJ= test11 test33 test43 test44 test46
GCCOBJ= test45-gcc test49-gcc
GCCOBJ= test45-gcc test48 test49-gcc test55
GCCFPUOBJ= test51-gcc test52-gcc
OTHEROBJ= test57 test59

View file

@ -219,7 +219,10 @@ void do_child(int childno) {
}
void do_parent(void) {
int fd_sock, fd_new, yes = 1, exitstatus;
#ifndef _MINIX
int yes = 1;
#endif
int fd_sock, fd_new, exitstatus;
int sockets[NUMCHILDREN], i;
fd_set fds_read, fds_write, fds_error;
fd_set fds_compare_read, fds_compare_write;
@ -239,7 +242,7 @@ void do_parent(void) {
my_addr.sin_port = htons(MYPORT); /* Short, network byte order */
my_addr.sin_addr.s_addr = INADDR_ANY;
/* Normally we'd zerofill sin_zero, but there is no such thing on Minix */
#ifndef _MINIX
#ifndef _MINIX
memset(my_addr.sin_zero, '\0', sizeof my_addr.sin_zero);
#endif

View file

@ -74,7 +74,7 @@ int n;
{
int pid, k;
if (pid = fork()) {
if ((pid = fork()) != 0) {
wait(&n); /* wait for some child (any one) */
} else {
k = execl(name[n], (char *) 0);

View file

@ -147,7 +147,8 @@ void test11c()
int n, etc_uid;
uid_t ruid, euid;
char *lnamep, *cnamep, *p;
char array[L_cuserid], save[L_cuserid], save2[L_cuserid];
#define MAXLINELEN 200
char array[MAXLINELEN], save[L_cuserid], save2[L_cuserid];
FILE *stream;
subtest = 3;
@ -176,7 +177,7 @@ void test11c()
/* Check login against passwd file. First lookup login in /etc/passwd. */
if (n == 0) return; /* if login not found, don't look it up */
if ( (stream = fopen(passwd_file, "r")) == NULL) e(8);
while (fgets(array, L_cuserid, stream) != NULL) {
while (fgets(array, sizeof(array), stream) != NULL) {
if (strncmp(array, save, n) == 0) {
p = &array[0]; /* hunt for uid */
while (*p != ':') p++;

View file

@ -117,7 +117,6 @@ int main(argc, argv)
int argc;
char *argv[];
{
char buffer[PATH_MAX + 1];
int n, mask, i;
/* Create filenames for MAXOPEN files, the *filenames[] array. */

View file

@ -124,7 +124,6 @@ _PROTOTYPE(void quit, (void));
****************************************************************************/
int main(int argc, char **argv)
{
char buffer[PATH_MAX + 1];
int n, i;
/* Create filenames for MAXOPEN files, the *file[] array. */

View file

@ -8,11 +8,11 @@
#include <unistd.h>
#include <stdio.h>
#define MAX_ERROR 4
#define MAX_ERROR 3
#define NB 30L
#define NBOUNDS 6
int errct, subtest, passes, pipesigs;
int subtest, passes, pipesigs;
long t1;
char aa[100];
@ -20,6 +20,8 @@ char b[4] = {0, 1, 2, 3}, c[4] = {10, 20, 30, 40}, d[4] = {6, 7, 8, 9};
long bounds[NBOUNDS] = {7, 9, 50, 519, 520, 40000L};
char buff[30000];
#include "common.c"
_PROTOTYPE(int main, (int argc, char *argv[]));
_PROTOTYPE(void test19a, (void));
_PROTOTYPE(void test19b, (void));
@ -30,23 +32,17 @@ _PROTOTYPE(void test19f, (void));
_PROTOTYPE(void test19g, (void));
_PROTOTYPE(void clraa, (void));
_PROTOTYPE(void pipecatcher, (int s));
_PROTOTYPE(void e, (int n));
_PROTOTYPE(void quit, (void));
int main(argc, argv)
int argc;
char *argv[];
{
char buffer[PATH_MAX + 1];
int i, m;
start(19);
m = (argc == 2 ? atoi(argv[1]) : 0xFFFF);
system("rm -rf DIR_19; mkdir DIR_19");
chdir("DIR_19");
printf("Test 19 ");
fflush(stdout);
for (i = 0; i < 4; i++) {
if (m & 0001) test19a();
if (m & 0002) test19b();
@ -480,39 +476,3 @@ int s; /* it is supposed to have an arg */
pipesigs++;
}
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); /* aargh! Most results go to stdout and are
* messed up by perror going to stderr.
* Should replace perror by printf and strerror
* in all the tests.
*/
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 quit()
{
chdir("..");
system("rm -rf DIR*");
if (errct == 0) {
printf("ok\n");
exit(0);
} else {
printf("%d errors\n", errct);
exit(1);
}
}

View file

@ -16,7 +16,7 @@
#include <stdio.h>
#define ITERATIONS 1
#define MAX_ERROR 4
#define MAX_ERROR 3
#include "common.c"
@ -42,14 +42,12 @@ int argc;
char *argv[];
{
char buffer[PATH_MAX + 1];
int i, m = 0xFFFF;
sync();
start(21);
if (argc == 2) m = atoi(argv[1]);
start(21);
for (i = 0; i < ITERATIONS; i++) {
if (m & 00001) test21a();
if (m & 00002) test21b();

View file

@ -43,7 +43,6 @@ _PROTOTYPE(void makelongnames, (void));
int main(int argc, char *argv[])
{
char buffer[PATH_MAX + 1];
int i, m = 0xFFFF;
sync();

View file

@ -252,14 +252,6 @@ void test27c()
Chdir("DIR_27"); /* back to test dir */
/* Check on ToLongName etc. */
#ifdef _POSIX_NO_TRUNC
# if _POSIX_NO_TRUNC - 0 != -1
if (stat(ToLongName, &st) != -1) e(4); /* name is too long */
if (errno != ENAMETOOLONG) e(5);
# endif
#else
# include "error, this case requires dynamic checks and is not handled"
#endif
if (stat(ToLongPath, &st) != -1) e(6); /* path is too long */
if (errno != ENAMETOOLONG) e(7);

View file

@ -164,8 +164,6 @@ void test28b()
int other = 0, dot = 0, dotdot = 0; /* dirent counters */
int r; /* Intermediate result */
int rmdir_result; /* tmp var */
nlink_t nlink;
static char bar[20];
int stat_loc, does_truncate;
subtest = 2;
@ -210,19 +208,6 @@ void test28b()
if (mkdir("foo", 0777) != 0) e(21);
System("touch foo/xyzzy");
#if 0
/* Test what happens if the parent link count > LINK_MAX. */
/* This takes too long. */
for (nlink = 1; nlink < LINK_MAX; nlink++) { /* make all */
sprintf(bar, "foo/bar.%d", nlink);
if (link("foo/xyzzy", bar) != 0) e(24);
}
if (stat("foo/xyzzy", &st) != 0) e(25); /* foo now */
if (st.st_nlink != LINK_MAX) e(26); /* is full */
if (link("foo/xyzzy", "nono") != -1) e(27); /* no more */
if (errno != EMLINK) e(28); /* entrys. */
System("rm -rf foo/nono"); /* Just in case. */
#endif
/* Test if rmdir removes only empty dirs */
if (rmdir("foo") != -1) e(29);/* not empty */

View file

@ -12,42 +12,32 @@
#include <stdio.h>
#define ITERATIONS 10
#define MAX_ERROR 4
#define MAX_ERROR 3
#define SIZE 64
int errct, subtest;
int subtest;
char el_weirdo[] = "\n\t\\\e@@!!##\e\e\n\n";
#include "common.c"
_PROTOTYPE(int main, (int argc, char *argv []));
_PROTOTYPE(void test3a, (void));
_PROTOTYPE(void test3b, (void));
_PROTOTYPE(void test3c, (void));
_PROTOTYPE(void test3d, (void));
_PROTOTYPE(void test3e, (void));
_PROTOTYPE(void quit, (void));
_PROTOTYPE(void e, (int n));
int main(argc, argv)
int argc;
char *argv[];
{
char buffer[PATH_MAX + 1];
int i, m = 0xFFFF;
sync();
start(3);
if (argc == 2) m = atoi(argv[1]);
printf("Test 3 ");
fflush(stdout); /* have to flush for child's benefit */
system("rm -rf DIR_03; mkdir DIR_03");
chdir("DIR_03");
for (i = 0; i < ITERATIONS; i++) {
if (m & 0001) test3a();
if (m & 0002) test3b();
if (m & 0004) test3c();
if (m & 0010) test3d();
if (m & 0020) test3e();
@ -139,21 +129,6 @@ void test3a()
}
void test3b()
{
/* Test uname. */
struct utsname u; /* contains all kinds of system ids */
subtest = 2;
#if 0
errno = -2000; /* None of these calls set errno. */
if (uname(&u) != 0) e(1);
if (strcmp(u.sysname, "MINIX") != 0
&& strcmp(u.sysname, "Minix") != 0) e(2); /* only one defined */
#endif
}
void test3c()
{
/* Test getenv. Asume HOME, PATH, and LOGNAME exist (not strictly required).*/
@ -221,32 +196,3 @@ void test3e()
if (sysconf(_SC_JOB_CONTROL) >= 0) e(5); /* no job control! */
}
void quit()
{
chdir("..");
system("rm -rf DIR*");
if (errct == 0) {
printf("ok\n");
exit(0);
} else {
printf("%d errors\n", errct);
exit(4);
}
}
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);
errno = err_num; /* restore errno, just in case */
perror("");
if (errct++ > MAX_ERROR) {
printf("Test aborted. Too many errors: ");
chdir("..");
system("rm -rf DIR*");
exit(1);
}
}

View file

@ -883,7 +883,6 @@ void test_attach_child()
void test_attach()
{
pid_t pid;
int r, status;
subtest = 9;

View file

@ -11,39 +11,15 @@
#include <sys/stat.h>
#include <unistd.h>
#define MAX_ERROR 4
#define MAX_ERROR 3
static int errct = 0;
static const char *executable, *subtest;
int subtest;
static const char *executable;
#include "common.c"
#define ERR (e(__LINE__))
static void e(int n)
{
printf("File %s, error line %d, errno %d: %s\n",
subtest, n, errno, strerror(errno));
if (errct++ > MAX_ERROR)
{
printf("Too many errors; test aborted\n");
exit(1);
}
}
static void quit(void)
{
if (errct == 0)
{
printf("ok\n");
exit(0);
}
else
{
printf("%d errors\n", errct);
exit(1);
}
}
static char *remove_last_path_component(char *path)
{
char *current, *last;
@ -113,7 +89,6 @@ static void check_realpath(const char *path, int expected_errno)
expected_errno2 = check_path_components(path);
/* run realpath */
subtest = path;
errno = 0;
resolved_path = realpath(path, buffer);
@ -122,7 +97,6 @@ static void check_realpath(const char *path, int expected_errno)
{
if (resolved_path) ERR;
if (errno != expected_errno && errno != expected_errno2) ERR;
subtest = NULL;
return;
}
@ -130,7 +104,6 @@ static void check_realpath(const char *path, int expected_errno)
if (!resolved_path)
{
ERR;
subtest = NULL;
return;
}
errno = 0;
@ -157,7 +130,6 @@ static void check_realpath(const char *path, int expected_errno)
if (lstat(resolved_path, &statbuf[1]) < 0) { ERR; return; }
if ((statbuf[1].st_mode & S_IFMT) != S_IFDIR) ERR;
}
subtest = NULL;
}
static void check_realpath_step_by_step(const char *path, int expected_errno)
@ -227,11 +199,17 @@ static void check_realpath_recurse(const char *path, int depth)
/* loop through subdirectories (including . and ..) */
if (!(dir = opendir(path)))
{
if (errno != ENOENT && errno != ENOTDIR)
/* Opening some special files might result in errors when the
* corresponding hardware is not present, or simply when access
* rights prohibit access (e.g., /dev/log).
*/
if (errno != ENOTDIR
&& errno != ENXIO && errno != EIO && errno != EACCES) {
ERR;
}
return;
}
while (dirent = readdir(dir))
while ((dirent = readdir(dir)) != NULL)
{
/* build path */
if (!pathncat(pathsub, sizeof(pathsub), path, dirent->d_name))
@ -247,7 +225,7 @@ static void check_realpath_recurse(const char *path, int depth)
}
#define PATH_DEPTH 4
#define PATH_BASE "/t43"
#define PATH_BASE "/."
#define L(x) PATH_BASE "/link_" #x ".tmp"
static char basepath[PATH_MAX + 1];
@ -255,7 +233,6 @@ static char basepath[PATH_MAX + 1];
static char *addbasepath(char *buffer, const char *path)
{
size_t basepathlen, pathlen;
int slashlen;
/* assumption: both start with slash and neither end with it */
assert(basepath[0] == '/');
@ -279,56 +256,6 @@ static char *addbasepath(char *buffer, const char *path)
return buffer;
}
static void cleanup(const char *path)
{
DIR *dir;
struct dirent *dirent;
char pathsub[PATH_MAX + 1];
struct stat statbuf;
/* determine file type, avoid following links */
if (lstat(path, &statbuf) < 0)
{
if (errno != ENOENT) ERR;
return;
}
/* only recursively process directories (NOT symlinks!) */
if ((statbuf.st_mode & S_IFMT) != S_IFDIR)
{
if (unlink(path) < 0) ERR;
return;
}
/* loop through subdirectories (excluding . and ..) */
if (!(dir = opendir(path)))
{
ERR;
return;
}
while (dirent = readdir(dir))
{
/* ignore current and parent directories */
if (strcmp(dirent->d_name, ".") == 0 ||
strcmp(dirent->d_name, "..") == 0)
continue;
/* build path */
if (!pathncat(pathsub, sizeof(pathsub), path, dirent->d_name))
{
ERR;
continue;
}
/* delete path */
cleanup(pathsub);
}
if (closedir(dir) < 0) ERR;
/* remove the (now empty) directory itself */
if (rmdir(path) < 0) ERR;
}
static void test_dirname(const char *path, const char *exp)
{
char buffer[PATH_MAX];
@ -362,16 +289,14 @@ static void test_dirname(const char *path, const char *exp)
int main(int argc, char **argv)
{
char buffer1[PATH_MAX + 1], buffer2[PATH_MAX + 1];
subtest = 1;
/* initialize */
printf("Test 43 ");
fflush(stdout);
start(43);
executable = argv[0];
getcwd(basepath, sizeof(basepath));
cleanup(addbasepath(buffer1, PATH_BASE));
/* prepare some symlinks to make it more difficult */
if (mkdir(addbasepath(buffer1, PATH_BASE), S_IRWXU) < 0) ERR;
if (symlink("/", addbasepath(buffer1, L(1))) < 0) ERR;
if (symlink(basepath, addbasepath(buffer1, L(2))) < 0) ERR;
@ -387,7 +312,7 @@ int main(int argc, char **argv)
check_realpath_step_by_step(addbasepath(buffer1, L(5)), ELOOP);
/* delete the symlinks */
cleanup(addbasepath(buffer1, PATH_BASE));
cleanup();
/* also test dirname */
test_dirname("", ".");

View file

@ -4,6 +4,10 @@
#include <stdlib.h>
#include <unistd.h>
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wtautological-compare"
#endif
#define MAX_ERROR 4
static int errct;

View file

@ -97,7 +97,7 @@ void api_test() {
* must have super user privileges.
*/
int r, i, nogroups;
int i;
gid_t *grouplist, *grouplist2;
long ngroups_max;
@ -197,7 +197,7 @@ void group_test() {
* the imaginary group, and readable, writable, and both by everyone else (2).
*/
int r, i, round, test_result;
int i, round;
gid_t *grouplist;
long ngroups_max;
#define ROUNDS 8

View file

@ -204,7 +204,7 @@ static void test_round_values(void)
static void test_remainder_value(double x, double y)
{
int mode_old;
double r1, r2, z;
double r1, r2;
assert(y != 0);

View file

@ -6,7 +6,7 @@
#include <string.h>
#include <unistd.h>
#define MAX_ERRORS 8
#define MAX_ERRORS 3
static int errct;
@ -139,7 +139,9 @@ static void test_getnameinfo_err_nr(
static void test_getaddrinfo(
const char *nodename,
int nodename_numerical,
const char *servname,
int servname_numerical,
int passhints,
int flags,
int family,
@ -153,18 +155,22 @@ static void test_getaddrinfo(
struct addrinfo hints;
struct sockaddr_in *sockaddr_in;
int ai_count_dgram, ai_count_stream, r;
/* some parameters are only meaningful with hints */
assert(passhints || !flags);
assert(passhints || family == AF_UNSPEC);
assert(passhints || !socktype);
/* a combination of parameters don't make sense to test */
if (nodename == NULL && servname == NULL) return;
if (nodename == NULL && (flags & AI_NUMERICHOST)) return;
if (servname == NULL && (flags & AI_NUMERICSERV)) return;
/* initialize hints */
memset(&hints, 0, sizeof(hints));
hints.ai_flags = flags;
hints.ai_family = family;
hints.ai_socktype = socktype;
hints.ai_family = family;
/* perform query and test result */
ai = (struct addrinfo *) 0xDEADBEEF;
@ -217,30 +223,45 @@ static void test_getaddrinfo(
ntohs(sockaddr_in->sin_port));
}
/* is canonical supplied? */
if (exp_canonname &&
(!ai_cur->ai_canonname || !*ai_cur->ai_canonname))
test_getaddrinfo_err(7,
TEST_GETADDRINFO_ERR_PARAMS,
"(anything)", ai_cur->ai_canonname);
/* If a hostname is numeric, there can't be a canonical name.
* Instead, the returned canonname (if requested) will be
* identical to the supplied hostname */
if (nodename != NULL && nodename_numerical &&
(flags & AI_CANONNAME)) {
if (strncmp(ai_cur->ai_canonname, nodename,
strlen(nodename)))
test_getaddrinfo_err(11,
TEST_GETADDRINFO_ERR_PARAMS,
nodename, ai_cur->ai_canonname);
} else {
/* is canonical supplied? */
if (exp_canonname && nodename &&
(!ai_cur->ai_canonname || !*ai_cur->ai_canonname))
test_getaddrinfo_err(7,
TEST_GETADDRINFO_ERR_PARAMS,
"(anything)", ai_cur->ai_canonname);
if (!exp_canonname && ai_cur->ai_canonname)
test_getaddrinfo_err(8,
TEST_GETADDRINFO_ERR_PARAMS,
NULL, ai_cur->ai_canonname);
if (!exp_canonname && ai_cur->ai_canonname)
test_getaddrinfo_err(8,
TEST_GETADDRINFO_ERR_PARAMS,
NULL, ai_cur->ai_canonname);
}
/* move to next result */
ai_cur = ai_cur->ai_next;
}
/* check number of results */
if (ai_count_dgram != ((socktype == SOCK_STREAM) ? 0 : 1))
test_getaddrinfo_err_nr(9, TEST_GETADDRINFO_ERR_PARAMS,
/* If socket type is non-zero, make sure we got what we wanted. Else
* any result is okay. */
if (socktype) {
if (ai_count_dgram != ((socktype == SOCK_STREAM) ? 0 : 1))
test_getaddrinfo_err_nr(9, TEST_GETADDRINFO_ERR_PARAMS,
(socktype == SOCK_STREAM) ? 0 : 1, ai_count_dgram);
if (ai_count_stream != ((socktype == SOCK_DGRAM) ? 0 : 1))
test_getaddrinfo_err_nr(10, TEST_GETADDRINFO_ERR_PARAMS,
if (ai_count_stream != ((socktype == SOCK_DGRAM) ? 0 : 1))
test_getaddrinfo_err_nr(10, TEST_GETADDRINFO_ERR_PARAMS,
(socktype == SOCK_DGRAM) ? 0 : 1, ai_count_stream);
}
/* clean up */
freeaddrinfo(ai);
@ -308,18 +329,18 @@ static struct
int need_network;
int exp_result;
} hosts[] = {
{ NULL, 0x7f000001, 1, 1, 0, 0 },
{ "0.0.0.0", 0x00000000, 1, 0, 0, 0, },
{ "0.0.0.255", 0x000000ff, 1, 0, 0, 0, },
{ "0.0.255.0", 0x0000ff00, 1, 0, 0, 0, },
{ "0.255.0.0", 0x00ff0000, 1, 0, 0, 0, },
{ "255.0.0.0", 0xff000000, 1, 0, 0, 0, },
{ "127.0.0.1", 0x7f000001, 1, 0, 0, 0, },
{ "localhost", 0x7f000001, 0, 1, 0, 0, },
{ "minix3.org", 0x82251414, 0, 1, 1, 0, },
{ "", 0x00000000, 1, 0, 0, (1 << EAI_NONAME) },
{ "256.256.256.256", 0x00000000, 1, 0, 0, (1 << EAI_NONAME) },
{ "minix3.xxx", 0x00000000, 0, 0, 1, (1 << EAI_NONAME) }};
{ NULL, 0x7f000001, 1, 1, 0, 0 },
{ "0.0.0.0", 0x00000000, 1, 0, 0, 0 },
{ "0.0.0.255", 0x000000ff, 1, 0, 0, 0 },
{ "0.0.255.0", 0x0000ff00, 1, 0, 0, 0 },
{ "0.255.0.0", 0x00ff0000, 1, 0, 0, 0 },
{ "255.0.0.0", 0xff000000, 1, 0, 0, 0 },
{ "127.0.0.1", 0x7f000001, 1, 0, 0, 0 },
{ "localhost", 0x7f000001, 0, 1, 0, 0, },
{ "minix3.org", 0x82251414, 0, 1, 1, 0, },
{ "", 0x00000000, 1, 0, 0, (1<<EAI_NONAME)|(1<<EAI_FAIL)|(1<<EAI_NODATA)},
{ "256.256.256.256",0x00000000, 1, 0, 0, (1<<EAI_NONAME)|(1<<EAI_FAIL)|(1<<EAI_NODATA)},
{ "minix3.xxx", 0x00000000, 0, 0, 1, (1<<EAI_NONAME)|(1<<EAI_FAIL)|(1<<EAI_NODATA)}};
static struct
{
@ -338,8 +359,8 @@ static struct
{ "echo", 7, 0, 0, 0 },
{ "ftp", 21, 0, SOCK_STREAM, 0 },
{ "tftp", 69, 0, SOCK_DGRAM , 0 },
{ "-1", 0, 1, 0, (1 << EAI_SERVICE) },
{ "", 0, 1, 0, (1 << EAI_SERVICE) },
{ "-1", 0, 1, 0, (1<<EAI_NONAME) | (1<<EAI_SERVICE) },
{ "", 0, 1, 0, (1<<EAI_NONAME) | (1<<EAI_SERVICE) },
{ "65537", 0, 1, 0, (1 << EAI_SERVICE) },
{ "XXX", 0, 0, 0, (1 << EAI_SERVICE) }};
@ -350,7 +371,7 @@ static struct
} families[] = {
{ AF_UNSPEC, 0 },
{ AF_INET, 0 },
{ AF_UNSPEC + AF_INET + 1, (1 << EAI_FAMILY) }};
{ AF_UNSPEC + AF_INET + 1, (1 << EAI_FAMILY) }};
static struct
{
@ -360,14 +381,15 @@ static struct
{ 0, 0 },
{ SOCK_STREAM, 0 },
{ SOCK_DGRAM, 0 },
{ SOCK_STREAM + SOCK_DGRAM + 1, (1 << EAI_SOCKTYPE) }};
{ SOCK_STREAM + SOCK_DGRAM + 1,
(1 << EAI_SOCKTYPE) | (1 << EAI_FAIL) | (1 << EAI_NONAME) }};
#define LENGTH(a) (sizeof((a)) / sizeof((a)[0]))
static void test_getaddrinfo_all(int use_network)
{
int flag_PASSIVE, flag_CANONNAME, flag_NUMERICHOST, flag_NUMERICSERV;
int exp_results, flags, i, j, k, l, needhints, passhints;
int exp_results, flags, i, j, k, l, passhints;
unsigned long ipaddr;
/* loop through various parameter values */
@ -379,6 +401,7 @@ static void test_getaddrinfo_all(int use_network)
for (flag_CANONNAME = 0; flag_CANONNAME < 2; flag_CANONNAME++)
for (flag_NUMERICHOST = 0; flag_NUMERICHOST < 2; flag_NUMERICHOST++)
for (flag_NUMERICSERV = 0; flag_NUMERICSERV < 2; flag_NUMERICSERV++)
for (passhints = 0; passhints < 2; passhints++)
{
/* skip tests that need but cannot use network */
if (!use_network && hosts[i].need_network)
@ -390,6 +413,12 @@ static void test_getaddrinfo_all(int use_network)
(flag_NUMERICHOST ? AI_NUMERICHOST : 0) |
(flag_NUMERICSERV ? AI_NUMERICSERV : 0);
/* some options require hints */
if (families[k].value != AF_UNSPEC ||
socktypes[l].value != 0 || flags) {
passhints = 1;
}
/* flags may influence IP address */
ipaddr = hosts[i].ipaddr;
if (!hosts[i].nodename && flag_PASSIVE)
@ -408,33 +437,39 @@ static void test_getaddrinfo_all(int use_network)
exp_results |= (1 << EAI_NONAME);
if (flag_NUMERICSERV && !services[j].numeric)
exp_results |= (1 << EAI_SERVICE);
exp_results |= (1 << EAI_NONAME);
if (services[j].socktype && socktypes[l].value != services[j].socktype)
exp_results |= (1 << EAI_SERVICE);
/* When we don't pass hints, getaddrinfo will find suitable
* settings for us. If we do pass hints, there might be
* conflicts.
*/
if (passhints) {
/* Can't have conflicting socket types */
if (services[j].socktype &&
socktypes[l].value &&
socktypes[l].value != services[j].socktype) {
exp_results |= (1 << EAI_SERVICE);
}
}
/* with no reason for failure, we demand success */
if (!exp_results)
exp_results |= (1 << 0);
/* some options require hints */
needhints = (families[k].value != AF_UNSPEC ||
socktypes[l].value != 0 || flags) ? 1 : 0;
for (passhints = needhints; passhints < 2; passhints++)
{
/* test getaddrinfo function */
test_getaddrinfo(
hosts[i].nodename,
services[j].servname,
passhints,
flags,
families[k].value,
socktypes[l].value,
exp_results,
htonl(ipaddr),
flag_CANONNAME && hosts[i].canonname,
htons(services[j].port));
}
/* test getaddrinfo function */
test_getaddrinfo(
hosts[i].nodename,
hosts[i].numeric,
services[j].servname,
services[j].numeric,
passhints,
flags,
families[k].value,
socktypes[l].value,
exp_results,
htonl(ipaddr),
flag_CANONNAME && hosts[i].canonname,
htons(services[j].port));
}
}
@ -496,12 +531,10 @@ static void test_getnameinfo_all(void)
/* determine expected result */
exp_results = 0;
if (!buflens[k] && !buflens[l])
exp_results |= (1 << EAI_NONAME);
nodename = flag_NUMERICHOST ? ipaddrs[i].nodenum : ipaddrs[i].nodename;
if (buflens[k] > 0 && buflens[k] <= strlen(nodename))
exp_results |= (1 << EAI_OVERFLOW);
exp_results |= (1 << EAI_OVERFLOW) | (1 << EAI_MEMORY);
socktypemismatch =
(flag_DGRAM && ports[j].socktype == SOCK_STREAM) ||
@ -509,9 +542,9 @@ static void test_getnameinfo_all(void)
servname = (flag_NUMERICSERV || socktypemismatch) ?
ports[j].servnum : ports[j].servname;
if (buflens[l] > 0 && buflens[l] <= strlen(servname))
exp_results |= (1 << EAI_OVERFLOW);
exp_results |= (1 << EAI_OVERFLOW) | (1 << EAI_MEMORY);
if (flag_NAMEREQD && (!ipaddrs[i].havename | flag_NUMERICHOST) && buflens[k])
if (flag_NAMEREQD && (!ipaddrs[i].havename || flag_NUMERICHOST) && buflens[k])
exp_results |= (1 << EAI_NONAME);
/* with no reason for failure, we demand success */
@ -533,7 +566,6 @@ static void test_getnameinfo_all(void)
static int can_use_network(void)
{
pid_t pid;
int status;
/* try to ping minix3.org */
@ -557,7 +589,6 @@ int main(void)
use_network = can_use_network();
if (!use_network)
printf("Warning: no network\n");
test_getaddrinfo_all(use_network);
test_getnameinfo_all();

View file

@ -11,14 +11,14 @@
#include <string.h>
#define ITERATIONS 2
#define MAX_ERROR 4
#define MAX_ERROR 3
int errct;
int subtest;
int zero[1024];
int sigmap[5] = {9, 10, 11};
#include "common.c"
_PROTOTYPE(int main, (int argc, char *argv[]));
_PROTOTYPE(void test5a, (void));
_PROTOTYPE(void parent, (int childpid));
@ -37,17 +37,6 @@ _PROTOTYPE(void funcalrm, (int s));
_PROTOTYPE(void test5h, (void));
_PROTOTYPE(void test5i, (void));
_PROTOTYPE(void ex, (void));
_PROTOTYPE(void e, (int n));
_PROTOTYPE(void quit, (void));
#ifdef _ANSI
void (*Signal(int _sig, void (*_func)(int)))(int);
#define SIG_ZERO ((void (*)(int))0) /* default signal handling */
#else
sighandler_t Signal();
/* void (*Signal()) (); */
#define SIG_ZERO ((void (*)())0) /* default signal handling */
#endif
_VOLATILE int childsigs, parsigs, alarms;
@ -57,11 +46,7 @@ char *argv[];
{
int i, m = 0x7777;
printf("Test 5 ");
fflush(stdout); /* have to flush for child's benefit */
system("rm -rf DIR_05; mkdir DIR_05");
chdir("DIR_05");
start(5);
for (i = 0; i < ITERATIONS; i++) {
if (m & 0001) test5a();
@ -87,17 +72,17 @@ void test5a()
for (zp = &zero[0]; zp < &zero[1024]; zp++)
if (*zp != 0) flag = 1;
if (flag) e(0); /* check if bss is cleared to 0 */
if (Signal(1, func1) == SIG_ERR) e(1);
if (Signal(10, func10) < SIG_ZERO) e(2);
if (signal(1, func1) == SIG_ERR) e(1);
if (signal(10, func10) == SIG_ERR) e(2);
parpid = getpid();
if (childpid = fork()) {
if ((childpid = fork()) != 0) {
if (childpid < 0) ex();
parent(childpid);
} else {
child(parpid);
}
if (Signal(1, SIG_DFL) < SIG_ZERO) e(4);
if (Signal(10, SIG_DFL) < SIG_ZERO) e(5);
if (signal(1, SIG_DFL) == SIG_ERR) e(4);
if (signal(10, SIG_DFL) == SIG_ERR) e(5);
}
void parent(childpid)
@ -131,7 +116,7 @@ int parpid;
void func1(s)
int s; /* for ANSI */
{
if (Signal(1, func1) < SIG_ZERO) e(10);
if (signal(1, func1) == SIG_ERR) e(10);
childsigs++;
}
@ -143,7 +128,7 @@ int s;
void func10(s)
int s; /* for ANSI */
{
if (Signal(10, func10) < SIG_ZERO) e(11);
if (signal(10, func10) == SIG_ERR) e(11);
parsigs++;
}
@ -158,11 +143,11 @@ void test5b()
int cpid, n, pid;
subtest = 1;
if ((pid = fork())) {
if ((pid = fork()) != 0) {
if (pid < 0) ex();
if ((pid = fork())) {
if ((pid = fork()) != 0) {
if (pid < 0) ex();
if (cpid = fork()) {
if ((cpid = fork()) != 0) {
if (cpid < 0) ex();
if (kill(cpid, 9) < 0) e(12);
if (wait(&n) < 0) e(13);
@ -187,7 +172,7 @@ void test5c()
/* Test exit status codes for processes killed by signals. */
subtest = 3;
for (i = 0; i < 2; i++) {
if (pid = fork()) {
if ((pid = fork()) != 0) {
if (pid < 0) ex();
sleep(2); /* wait for child to pause */
if (kill(pid, sigmap[i]) < 0) {
@ -213,7 +198,7 @@ void test5d()
subtest = 4;
alarms = 0;
for (i = 0; i < 8; i++) {
Signal(SIGALRM, funcalrm);
signal(SIGALRM, funcalrm);
alarm(1);
pause();
if (alarms != i + 1) e(24);
@ -228,14 +213,14 @@ void test5e()
int n, j;
subtest = 5;
if (Signal(8, func8) < SIG_ZERO) e(25);
if (n = fork()) {
if (signal(8, func8) == SIG_ERR) e(25);
if ((n = fork()) != 0) {
/* Parent must delay to give child a chance to pause. */
if (n < 0) ex();
sleep(1);
if (kill(n, 8) < 0) e(26);
if (wait(&n) < 0) e(27);
if (Signal(8, SIG_DFL) < SIG_ZERO) e(28);
if (signal(8, SIG_DFL) == SIG_ERR) e(28);
} else {
j = pause();
if (errno != EINTR && -errno != EINTR) e(29);
@ -279,11 +264,11 @@ void test5g()
int n;
subtest = 7;
Signal(11, func11);
Signal(11, SIG_IGN);
signal(11, func11);
signal(11, SIG_IGN);
n = getpid();
if (kill(n, 11) != 0) e(1);
Signal(11, SIG_DFL);
signal(11, SIG_DFL);
}
void funcalrm(s)
@ -301,9 +286,9 @@ void test5h()
subtest = 8;
unlink("XXX.test5");
if (Signal(8, func8) < SIG_ZERO) e(1);
if (signal(8, func8) == SIG_ERR) e(1);
pipe(fd);
if (n = fork()) {
if ((n = fork()) != 0) {
/* Parent must delay to give child a chance to pause. */
if (n < 0) ex();
while (access("XXX.test5", 0) != 0) /* just wait */ ;
@ -311,7 +296,7 @@ void test5h()
unlink("XXX.test5");
if (kill(n, 8) < 0) e(2);
if (wait(&n) < 0) e(3);
if (Signal(8, SIG_DFL) < SIG_ZERO) e(4);
if (signal(8, SIG_DFL) == SIG_ERR) e(4);
if (close(fd[0]) != 0) e(5);
if (close(fd[1]) != 0) e(6);
} else {
@ -330,7 +315,7 @@ void test5i()
pipe(fd);
unlink("XXXxxxXXX");
if ( (pid = fork())) {
if ((pid = fork()) != 0) {
/* Parent */
/* Wait until child has started and has created the XXXxxxXXX file. */
while (access("XXXxxxXXX", 0) != 0) /* loop */ ;
@ -354,47 +339,3 @@ void ex()
exit(1);
}
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);
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);
}
}
#ifdef _ANSI
void (*Signal(int a, void (*b)(int)))(int)
#else
sighandler_t Signal(a, b)
int a;
void (*b)();
#endif
{
if (signal(a, (void (*) ()) b) == (void (*)()) -1)
return(SIG_ERR);
else
return(SIG_ZERO);
}
void quit()
{
chdir("..");
system("rm -rf DIR*");
if (errct == 0) {
printf("ok\n");
exit(0);
} else {
printf("%d errors\n", errct);
exit(1);
}
}

View file

@ -53,7 +53,7 @@ int main(argc, argv)
int argc;
char *argv[];
{
int i, j, m = 0xFFFF;
int j, m = 0xFFFF;
start(50);
prepare();
@ -109,7 +109,7 @@ int make_file(size)
off_t size;
{
off_t off;
int i, fd, r;
int fd, r;
if ((fd = open(TESTFILE, O_RDWR|O_CREAT|O_EXCL, 0600)) < 0) e(1001);
@ -476,7 +476,7 @@ void sub50g(osize, nsize)
off_t osize;
off_t nsize;
{
int fd, r;
int fd;
fd = make_file(osize);

View file

@ -89,7 +89,8 @@ void dead_child(int n)
{
int status;
subtest = 4;
n = n;
(void) n; /* Avoid warning about unused parameter */
if (wait(&status) == -1) err(1);

View file

@ -20,7 +20,7 @@ static jmp_buf jmpbuf_SIGFPE, jmpbuf_main;
static void err(int line)
{
/* print error information */
printf("error line %d; i=0x%.8x%.8x; j=0x%.8x%.8x; k=0x%.8x%.8x\n",
printf("error line %d; i=0x%.8lx%.8lx; j=0x%.8lx%.8lx; k=0x%.8lx%.8lx\n",
line,
ex64hi(i), ex64lo(i),
ex64hi(j), ex64lo(j),

View file

@ -19,27 +19,26 @@ void do_test(void)
size_t size;
ssize_t nwritten;
ssize_t nread;
char *filename;
char *filename = "pwrite_test_XXXXXXX";
int i;
subtest = 1;
if((filename = mktemp("pwrite_test_XXXXXXX")) == NULL) e(1);
if((fd = open(filename, O_CREAT|O_RDWR)) < 0) e(2);
if ((fd = mkstemp(filename)) < 0) e(1);
size = 1 + rand() % 4096;
off = rand();
if((wbuf = malloc(sizeof(char)*size)) == NULL) e(3);
if((wbuf = malloc(sizeof(char)*size)) == NULL) e(2);
for(i = 0; i < size; i++) {
wbuf[i] = 1 + rand()%127;
}
if((nwritten = pwrite(fd, wbuf, size, off)) < 0) e(4);
if((rbuf = malloc(sizeof(char)*nwritten)) == NULL) e(5);
if((nread = pread(fd, rbuf, nwritten, off)) < 0) e(6);
if(strncmp(rbuf, wbuf, nread) != 0) e(7);
if ((nwritten = pwrite(fd, wbuf, size, off)) < 0) e(3);
if ((rbuf = malloc(sizeof(char)*nwritten)) == NULL) e(4);
if ((nread = pread(fd, rbuf, nwritten, off)) < 0) e(5);
if (strncmp(rbuf, wbuf, nread) != 0) e(6);
close(fd);
free(wbuf);

View file

@ -8,37 +8,31 @@
#define TRIALS 10
#define SIZE 65536
#define TMPPATH "/usr/tmp/"
#define MAX_ERROR 3
char *create_file(void)
int subtest;
char *filename = "statvfs_test_XXXXXX";
#include "common.c"
void create_file(void)
{
char buf[SIZE]={0};
char *p;
ssize_t ntowrite, nwritten;
int fd;
char *filename;
if((filename = mktemp(TMPPATH "statvfs_test_XXXXXXX")) == NULL) {
err(1, "mktemp failed");
}
if((fd = open(filename, O_CREAT|O_WRONLY)) < 0) {
err(1, "open failed");
}
subtest = 2;
if ((fd = mkstemp(filename)) < 0) e(1);
ntowrite = SIZE;
p = &buf[0];
while(ntowrite > 0) {
if((nwritten = write(fd, p, ntowrite)) < 0) {
err(1, "write failed");
}
while (ntowrite > 0) {
if ((nwritten = write(fd, p, ntowrite)) < 0) e(2);
p += nwritten;
ntowrite -= nwritten;
}
close(fd);
return filename;
if (close(fd) < 0) e(3);
}
int main(int argc, char *argv[])
@ -57,16 +51,11 @@ int main(int argc, char *argv[])
unsigned long f_namemax, f_namemax_new;
int i;
printf("Test 55 ");
for(i = 0; i < TRIALS; i++) {
int r;
char *filename;
start(55);
if(statvfs(TMPPATH, &stats) < 0) {
perror("statvfs failed");
return 1;
}
subtest = 1;
for(i = 0; i < TRIALS; i++) {
if (statvfs(".", &stats) < 0) e(1);
f_bsize = stats.f_bsize ;
f_frsize = stats.f_frsize ;
@ -80,44 +69,38 @@ int main(int argc, char *argv[])
f_flag = stats.f_flag ;
f_namemax = stats.f_namemax;
filename = create_file();
create_file();
r = statvfs(TMPPATH, &stats);
unlink(filename);
if(r < 0) {
perror("statvfs failed");
return 1;
}
if (statvfs(".", &stats) < 0) e(2);
if (unlink(filename) < 0) e(3);
f_bsize_new = stats.f_bsize ;
f_frsize_new = stats.f_frsize ;
f_blocks_new = stats.f_blocks ;
f_bfree_new = stats.f_bfree ;
f_bavail_new = stats.f_bavail ;
f_files_new = stats.f_files ;
f_ffree_new = stats.f_ffree ;
f_favail_new = stats.f_favail ;
f_fsid_new = stats.f_fsid ;
f_flag_new = stats.f_flag ;
f_namemax_new = stats.f_namemax;
f_frsize_new = stats.f_frsize ;
f_blocks_new = stats.f_blocks ;
f_bfree_new = stats.f_bfree ;
f_bavail_new = stats.f_bavail ;
f_files_new = stats.f_files ;
f_ffree_new = stats.f_ffree ;
f_favail_new = stats.f_favail ;
f_fsid_new = stats.f_fsid ;
f_flag_new = stats.f_flag ;
f_namemax_new = stats.f_namemax;
if ((f_bsize == f_bsize_new) &&
(f_frsize == f_frsize_new) &&
(f_blocks == f_blocks_new) &&
(f_bfree > f_bfree_new) &&
(f_bavail > f_bavail_new) &&
(f_files == f_files_new) &&
(f_ffree == f_ffree_new + 1) &&
(f_favail == f_favail_new + 1) &&
(f_fsid == f_fsid_new) &&
(f_flag == f_flag_new) &&
(f_namemax == f_namemax_new) ) {
printf("ok\n");
return 0;
if (!((f_bsize == f_bsize_new) &&
(f_frsize == f_frsize_new) &&
(f_blocks == f_blocks_new) &&
(f_bfree > f_bfree_new) &&
(f_bavail > f_bavail_new) &&
(f_files == f_files_new) &&
(f_ffree == f_ffree_new + 1) &&
(f_favail == f_favail_new + 1) &&
(f_fsid == f_fsid_new) &&
(f_flag == f_flag_new) &&
(f_namemax == f_namemax_new))) {
e(4);
}
}
return 1;
quit();
return(-1);
}

View file

@ -572,7 +572,6 @@ void test_bind(void)
void test_listen(void)
{
int sd;
int rc;
debug("entering test_listen()");
@ -718,7 +717,6 @@ void test_sockopts(void)
int rc;
int sd;
int option_value;
int option_value_orig;
socklen_t option_len;
debug("entering test_sockopts()");
@ -984,7 +982,6 @@ void test_dup2(void)
*/
void test_xfer_server(pid_t pid)
{
struct ucred credentials;
socklen_t ucred_length;
int i;
int on;
@ -998,8 +995,6 @@ void test_xfer_server(pid_t pid)
int client_sd;
struct sockaddr_un addr;
struct sockaddr_un client_addr;
uid_t euid;
gid_t egid;
on = 1;
status = 0;
@ -1203,8 +1198,6 @@ void test_xfer_client(void)
int sd;
int rc;
char buf[BUFSIZE];
uid_t uid;
gid_t gid;
debug("[client] entering test_xfer_client()");
errct = 0; /* reset error count */

View file

@ -10,42 +10,30 @@
#include <unistd.h>
#include <stdio.h>
#define MAX_ERROR 4
#define MAX_ERROR 3
int errct;
int subtest = 1;
int zilch[5000];
char curdir[PATH_MAX];
#include "common.c"
_PROTOTYPE(int main, (int argc, char *argv []));
_PROTOTYPE(void test6a, (void));
_PROTOTYPE(void test6b, (void));
_PROTOTYPE(void test6c, (void));
_PROTOTYPE(void e, (int n));
_PROTOTYPE(void quit, (void));
int main(argc, argv)
int argc;
char *argv[];
{
char buffer[PATH_MAX + 1];
int i, m = 0xFFFF;
sync();
if (argc == 2) m = atoi(argv[1]);
printf("Test 6 ");
fflush(stdout);
getcwd(curdir, PATH_MAX);
system("rm -rf DIR_06; mkdir DIR_06");
chdir("DIR_06");
start(6);
for (i = 0; i < 70; i++) {
if (m & 00001) test6a();
if (m & 00002) test6b();
if (m & 00004) test6c();
}
quit();
@ -115,96 +103,3 @@ void test6b()
kill(getpid(), SIGQUIT);
}
void test6c()
{
/* Test mknod, chdir, chmod, chown, access. */
int i, j;
struct stat s;
subtest = 3;
if (getuid() != 0) return;
for (j = 0; j < 2; j++) {
umask(0);
if (chdir("/") < 0) e(1);
if (mknod("dir", 040700, 0) < 0) e(2);
if (link("/", "/dir/..") < 0) e(3);
if (mknod("T3a", 0777, 0) < 0) e(4);
if (mknod("/dir/T3b", 0777, 0) < 0) e(5);
if (mknod("dir/T3c", 0777, 0) < 0) e(6);
if ((i = open("/dir/T3b", 0)) < 0) e(7);
if (close(i) < 0) e(8);
if ((i = open("dir/T3c", O_RDONLY)) < 0) e(9);
if (close(i) < 0) e(10);
if (chdir("dir") < 0) e(11);
if ((i = open("T3b", 0)) < 0) e(12);
if (close(i) < 0) e(13);
if ((i = open("../T3a", O_RDONLY)) < 0) e(14);
if (close(i) < 0) e(15);
if ((i = open("../dir/../dir/../dir/../dir/../dir/T3c", O_RDONLY)) < 0)
e(16);
if (close(i) < 0) e(17);
if (chmod("../dir/../dir/../dir/../dir/../T3a", 0123) < 0) e(18);
if (stat("../dir/../dir/../dir/../T3a", &s) < 0) e(19);
if ((s.st_mode & 077777) != 0123) e(20);
if (chmod("../dir/../dir/../T3a", 0456) < 0) e(21);
if (stat("../T3a", &s) < 0) e(22);
if ((s.st_mode & 077777) != 0456) e(23);
if (chown("../dir/../dir/../T3a", 20, 30) < 0) e(24);
if (stat("../T3a", &s) < 0) e(25);
if (s.st_uid != 20) e(26);
if (s.st_gid != 30) e(27);
if ((i = open("/T3c", O_RDONLY)) >= 0) e(28);
if ((i = open("/T3a", O_RDONLY)) < 0) e(29);
if (close(i) < 0) e(30);
if (access("/T3a", 4) < 0) e(31);
if (access("/dir/T3b", 4) < 0) e(32);
if (access("/dir/T3d", 4) >= 0) e(33);
if (unlink("T3b") < 0) e(34);
if (unlink("T3c") < 0) e(35);
if (unlink("..") < 0) e(36);
if (chdir("/") < 0) e(37);
if (unlink("dir") < 0) e(38);
if (unlink("/T3a") < 0) e(39);
}
}
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);
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 quit()
{
chdir("..");
system("rm -rf DIR*");
chdir(curdir);
system("rm -rf DIR*");
if (errct == 0) {
printf("ok\n");
exit(0);
} else {
printf("%d errors\n", errct);
exit(1);
}
}

View file

@ -144,9 +144,10 @@ jmp_buf env;
char *
addr()
{
char a;
char a, *ret;
return &a;
ret = &a;
return(ret);
}
void garbage()

View file

@ -80,7 +80,7 @@ int
main(int argc, char **argv)
{
int i, ch;
GElf_Addr startaddr, endaddr;
GElf_Addr startaddr;
startaddr = BOOTPROG_LOAD_START;