From a209c3ae1296f9263ca6488a85fe5b405cfc4f7c Mon Sep 17 00:00:00 2001 From: Thomas Veerman Date: Mon, 14 Nov 2011 10:07:49 +0000 Subject: [PATCH] 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). --- common/include/minix/devman.h | 4 +- include/ctype.h | 16 +- lib/libarchive/archive_entry_link_resolver.c | 2 + .../archive_read_support_format_tar.c | 6 +- lib/libc/ansi/malloc-debug.c | 1 + lib/libc/asyn/asyn_write.c | 1 - lib/libc/ip/bind.c | 31 ---- lib/libdevman/generic.c | 3 +- lib/libdevman/usb.c | 3 +- lib/libfetch/ftp.c | 2 +- lib/libminc/fputs.c | 2 +- lib/libminc/malloc.c | 1 - lib/libminixfs/cache.c | 1 + lib/libminixfs/fetch_credentials.c | 2 + lib/libsys/get_randomness.c | 2 +- lib/libsys/timers.c | 1 + lib/libsys/timing.c | 6 +- lib/libsys/vprintf.c | 5 +- lib/libusb/usb.c | 2 +- lib/libutil/passwd.c | 2 +- lib/libutil/pty.c | 4 + lib/libvassert/vassert.c | 6 +- lib/nbsd_libc/gen/getttyent.c | 2 +- lib/nbsd_libc/gen/minix/getdomainname.c | 12 +- lib/nbsd_libc/gen/minix/getpass.c | 1 - lib/nbsd_libc/gen/setmode.c | 11 +- lib/nbsd_libc/gen/ulimit.c | 5 +- lib/nbsd_libc/locale/setlocale.c | 24 +-- lib/nbsd_libc/misc/stack_protector.c | 2 +- lib/nbsd_libc/net/getnameinfo.c | 4 +- lib/nbsd_libc/net/minix/getifaddrs.c | 7 +- lib/nbsd_libc/resolv/res_send.c | 2 - lib/nbsd_libc/ssp/memcpy_chk.c | 5 + lib/nbsd_libc/ssp/memmove_chk.c | 4 + lib/nbsd_libc/ssp/memset_chk.c | 4 + lib/nbsd_libc/ssp/strcat_chk.c | 4 + lib/nbsd_libc/ssp/strcpy_chk.c | 4 + lib/nbsd_libc/ssp/strncat_chk.c | 4 + lib/nbsd_libc/ssp/strncpy_chk.c | 4 + lib/nbsd_libc/stdlib/strfmon.c | 2 +- lib/nbsd_libc/string/strmode.c | 4 +- lib/nbsd_libc/sys-minix/__getcwd.c | 7 +- lib/nbsd_libc/sys-minix/bind.c | 31 ---- lib/nbsd_libc/sys-minix/getgroups.c | 2 +- lib/nbsd_libc/sys-minix/getsid.c | 3 +- lib/nbsd_libc/sys-minix/mount.c | 6 +- lib/nbsd_libc/sys-minix/sendmsg.c | 2 +- lib/nbsd_libc/sys-minix/sendto.c | 1 - lib/nbsd_libc/sys-minix/stat.c | 17 +- lib/nbsd_libc/sys-minix/sysuname.c | 1 + lib/nbsd_libc/termios/tcsetattr.c | 8 +- lib/nbsd_libcompat_minix/passwd.c | 1 + lib/nbsd_libm/arch/i387/fenv.c | 2 +- lib/nbsd_libminlib/vm_query_exit.c | 2 +- nbsd_include/sys/ctype_inline.h | 26 +-- nbsd_include/sys/socket.h | 3 + nbsd_include/sys/syslimits.h | 2 +- nbsd_include/unistd.h | 4 +- share/mk/minix.gcc.mk | 2 +- test/Makefile | 8 +- test/t40e.c | 7 +- test/test10.c | 2 +- test/test11.c | 5 +- test/test17.c | 1 - test/test18.c | 1 - test/test19.c | 52 +----- test/test21.c | 6 +- test/test25.c | 1 - test/test27.c | 8 - test/test28.c | 15 -- test/test3.c | 64 +------ test/test42.c | 1 - test/test43.c | 109 ++---------- test/test45.c | 4 + test/test46.c | 4 +- test/test47.c | 2 +- test/test48.c | 159 +++++++++++------- test/test5.c | 111 +++--------- test/test50.c | 6 +- test/test52.c | 3 +- test/test53.c | 2 +- test/test54.c | 15 +- test/test55.c | 103 +++++------- test/test56.c | 7 - test/test6.c | 113 +------------ test/test9.c | 5 +- usr.bin/mkimage/mkimage.c | 2 +- 87 files changed, 391 insertions(+), 753 deletions(-) diff --git a/common/include/minix/devman.h b/common/include/minix/devman.h index 48ccb7f59..9bf1a8c94 100644 --- a/common/include/minix/devman.h +++ b/common/include/minix/devman.h @@ -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 diff --git a/include/ctype.h b/include/ctype.h index 1b40173c1..7ec581ca7 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -7,9 +7,7 @@ #ifndef _CTYPE_H #define _CTYPE_H -#ifndef _MINIX_ANSI_H #include -#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) diff --git a/lib/libarchive/archive_entry_link_resolver.c b/lib/libarchive/archive_entry_link_resolver.c index 5ab348c6c..808d0a6bf 100644 --- a/lib/libarchive/archive_entry_link_resolver.c +++ b/lib/libarchive/archive_entry_link_resolver.c @@ -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. */ diff --git a/lib/libarchive/archive_read_support_format_tar.c b/lib/libarchive/archive_read_support_format_tar.c index 0469b75ea..f93c164f4 100644 --- a/lib/libarchive/archive_read_support_format_tar.c +++ b/lib/libarchive/archive_read_support_format_tar.c @@ -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; diff --git a/lib/libc/ansi/malloc-debug.c b/lib/libc/ansi/malloc-debug.c index c14717809..2f2b918ea 100644 --- a/lib/libc/ansi/malloc-debug.c +++ b/lib/libc/ansi/malloc-debug.c @@ -9,6 +9,7 @@ #include #include #include +#include #define mmap minix_mmap #define munmap minix_munmap diff --git a/lib/libc/asyn/asyn_write.c b/lib/libc/asyn/asyn_write.c index 1c3afdd78..7e9878aff 100644 --- a/lib/libc/asyn/asyn_write.c +++ b/lib/libc/asyn/asyn_write.c @@ -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++; diff --git a/lib/libc/ip/bind.c b/lib/libc/ip/bind.c index 72393526f..b73828e1d 100644 --- a/lib/libc/ip/bind.c +++ b/lib/libc/ip/bind.c @@ -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) { diff --git a/lib/libdevman/generic.c b/lib/libdevman/generic.c index 481ef9fba..93b5a2ed0 100644 --- a/lib/libdevman/generic.c +++ b/lib/libdevman/generic.c @@ -7,6 +7,8 @@ #include #include #include +#include +#include #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); diff --git a/lib/libdevman/usb.c b/lib/libdevman/usb.c index c0f9a888c..001f91393 100644 --- a/lib/libdevman/usb.c +++ b/lib/libdevman/usb.c @@ -6,6 +6,7 @@ #include #include #include +#include #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)) { diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c index 3f181d627..d3903b4fa 100644 --- a/lib/libfetch/ftp.c +++ b/lib/libfetch/ftp.c @@ -903,8 +903,8 @@ retry_mode: int arg; #endif int d; - char *ap; #ifdef INET6 + char *ap; char hname[INET6_ADDRSTRLEN]; #endif diff --git a/lib/libminc/fputs.c b/lib/libminc/fputs.c index b9a66bce2..868bbe1d0 100644 --- a/lib/libminc/fputs.c +++ b/lib/libminc/fputs.c @@ -11,5 +11,5 @@ int fputs(const char *s, FILE *fp) { assert(fp == stdout || fp == stderr); - puts(s); + return puts(s); } diff --git a/lib/libminc/malloc.c b/lib/libminc/malloc.c index fc8028299..2ea43adec 100644 --- a/lib/libminc/malloc.c +++ b/lib/libminc/malloc.c @@ -14,7 +14,6 @@ #include #include -static int no_debug = -1; #define CHECK_DBG(statement) #if _EM_WSIZE == _EM_PSIZE diff --git a/lib/libminixfs/cache.c b/lib/libminixfs/cache.c index bf43750c0..4df1de7bb 100644 --- a/lib/libminixfs/cache.c +++ b/lib/libminixfs/cache.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include diff --git a/lib/libminixfs/fetch_credentials.c b/lib/libminixfs/fetch_credentials.c index 26f62d2f9..a1247c78c 100644 --- a/lib/libminixfs/fetch_credentials.c +++ b/lib/libminixfs/fetch_credentials.c @@ -1,7 +1,9 @@ #include #include +#include #include +#include #include "minixfs.h" diff --git a/lib/libsys/get_randomness.c b/lib/libsys/get_randomness.c index 5313c4e7b..421618570 100644 --- a/lib/libsys/get_randomness.c +++ b/lib/libsys/get_randomness.c @@ -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 ++; diff --git a/lib/libsys/timers.c b/lib/libsys/timers.c index 726583c28..06cfffdf3 100644 --- a/lib/libsys/timers.c +++ b/lib/libsys/timers.c @@ -13,6 +13,7 @@ #include "syslib.h" #include +#include PRIVATE timer_t *timers = NULL; PRIVATE int expiring = 0; diff --git a/lib/libsys/timing.c b/lib/libsys/timing.c index 12b39ba57..51acc7b08 100644 --- a/lib/libsys/timing.c +++ b/lib/libsys/timing.c @@ -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; diff --git a/lib/libsys/vprintf.c b/lib/libsys/vprintf.c index 2da039229..b6120d052 100644 --- a/lib/libsys/vprintf.c +++ b/lib/libsys/vprintf.c @@ -3,6 +3,7 @@ #include #include #include +#include /* 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 diff --git a/lib/libusb/usb.c b/lib/libusb/usb.c index 43ea2c4b5..011c4ae61 100644 --- a/lib/libusb/usb.c +++ b/lib/libusb/usb.c @@ -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); } } diff --git a/lib/libutil/passwd.c b/lib/libutil/passwd.c index 972ea03fc..ad25d72ce 100644 --- a/lib/libutil/passwd.c +++ b/lib/libutil/passwd.c @@ -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); diff --git a/lib/libutil/pty.c b/lib/libutil/pty.c index cd03b4b47..6a0e0c304 100644 --- a/lib/libutil/pty.c +++ b/lib/libutil/pty.c @@ -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) diff --git a/lib/libvassert/vassert.c b/lib/libvassert/vassert.c index 3720551bd..b3a2893fd 100644 --- a/lib/libvassert/vassert.c +++ b/lib/libvassert/vassert.c @@ -6,6 +6,7 @@ #include #include #include +#include #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; } diff --git a/lib/nbsd_libc/gen/getttyent.c b/lib/nbsd_libc/gen/getttyent.c index f3f3e2af2..aa6f5df2f 100644 --- a/lib/nbsd_libc/gen/getttyent.c +++ b/lib/nbsd_libc/gen/getttyent.c @@ -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++) diff --git a/lib/nbsd_libc/gen/minix/getdomainname.c b/lib/nbsd_libc/gen/minix/getdomainname.c index 5d70f41f0..c913cee6c 100644 --- a/lib/nbsd_libc/gen/minix/getdomainname.c +++ b/lib/nbsd_libc/gen/minix/getdomainname.c @@ -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; } diff --git a/lib/nbsd_libc/gen/minix/getpass.c b/lib/nbsd_libc/gen/minix/getpass.c index 2f2451bb4..623439629 100644 --- a/lib/nbsd_libc/gen/minix/getpass.c +++ b/lib/nbsd_libc/gen/minix/getpass.c @@ -4,7 +4,6 @@ #include #include "namespace.h" -#define _MINIX #include #include #include diff --git a/lib/nbsd_libc/gen/setmode.c b/lib/nbsd_libc/gen/setmode.c index 83dd752b9..4fed4b9cd 100644 --- a/lib/nbsd_libc/gen/setmode.c +++ b/lib/nbsd_libc/gen/setmode.c @@ -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); diff --git a/lib/nbsd_libc/gen/ulimit.c b/lib/nbsd_libc/gen/ulimit.c index 30a7ca498..03aa540d2 100644 --- a/lib/nbsd_libc/gen/ulimit.c +++ b/lib/nbsd_libc/gen/ulimit.c @@ -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); diff --git a/lib/nbsd_libc/locale/setlocale.c b/lib/nbsd_libc/locale/setlocale.c index 35c12d6e1..b8d4129f2 100644 --- a/lib/nbsd_libc/locale/setlocale.c +++ b/lib/nbsd_libc/locale/setlocale.c @@ -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 }, }; diff --git a/lib/nbsd_libc/misc/stack_protector.c b/lib/nbsd_libc/misc/stack_protector.c index d247e11a5..0f20cb9ea 100644 --- a/lib/nbsd_libc/misc/stack_protector.c +++ b/lib/nbsd_libc/misc/stack_protector.c @@ -58,8 +58,8 @@ __guard_setup(void) { #ifndef __minix int mib[2]; -#endif size_t len; +#endif if (__stack_chk_guard[0] != 0) return; diff --git a/lib/nbsd_libc/net/getnameinfo.c b/lib/nbsd_libc/net/getnameinfo.c index ce64bc2d9..7e1e8aeb7 100644 --- a/lib/nbsd_libc/net/getnameinfo.c +++ b/lib/nbsd_libc/net/getnameinfo.c @@ -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 */ diff --git a/lib/nbsd_libc/net/minix/getifaddrs.c b/lib/nbsd_libc/net/minix/getifaddrs.c index e7726edb9..87ddc26ba 100644 --- a/lib/nbsd_libc/net/minix/getifaddrs.c +++ b/lib/nbsd_libc/net/minix/getifaddrs.c @@ -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; } diff --git a/lib/nbsd_libc/resolv/res_send.c b/lib/nbsd_libc/resolv/res_send.c index 702329759..8e8bbb193 100644 --- a/lib/nbsd_libc/resolv/res_send.c +++ b/lib/nbsd_libc/resolv/res_send.c @@ -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)) { diff --git a/lib/nbsd_libc/ssp/memcpy_chk.c b/lib/nbsd_libc/ssp/memcpy_chk.c index 7c7a88824..ac2b1ca3a 100644 --- a/lib/nbsd_libc/ssp/memcpy_chk.c +++ b/lib/nbsd_libc/ssp/memcpy_chk.c @@ -35,9 +35,12 @@ __RCSID("$NetBSD: memcpy_chk.c,v 1.4 2008/04/28 20:23:00 martin Exp $"); #include #include +#include #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 diff --git a/lib/nbsd_libc/ssp/memmove_chk.c b/lib/nbsd_libc/ssp/memmove_chk.c index 029205781..a90243d9d 100644 --- a/lib/nbsd_libc/ssp/memmove_chk.c +++ b/lib/nbsd_libc/ssp/memmove_chk.c @@ -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 diff --git a/lib/nbsd_libc/ssp/memset_chk.c b/lib/nbsd_libc/ssp/memset_chk.c index 6911e77a9..37c1a53f7 100644 --- a/lib/nbsd_libc/ssp/memset_chk.c +++ b/lib/nbsd_libc/ssp/memset_chk.c @@ -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 diff --git a/lib/nbsd_libc/ssp/strcat_chk.c b/lib/nbsd_libc/ssp/strcat_chk.c index 212cdd92e..770bb13d2 100644 --- a/lib/nbsd_libc/ssp/strcat_chk.c +++ b/lib/nbsd_libc/ssp/strcat_chk.c @@ -36,6 +36,8 @@ __RCSID("$NetBSD: strcat_chk.c,v 1.4 2009/11/17 20:44:26 drochner Exp $"); #include #include +#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 diff --git a/lib/nbsd_libc/ssp/strcpy_chk.c b/lib/nbsd_libc/ssp/strcpy_chk.c index 74f9af323..21987f4f9 100644 --- a/lib/nbsd_libc/ssp/strcpy_chk.c +++ b/lib/nbsd_libc/ssp/strcpy_chk.c @@ -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 diff --git a/lib/nbsd_libc/ssp/strncat_chk.c b/lib/nbsd_libc/ssp/strncat_chk.c index ae6679238..864683d00 100644 --- a/lib/nbsd_libc/ssp/strncat_chk.c +++ b/lib/nbsd_libc/ssp/strncat_chk.c @@ -37,6 +37,8 @@ __RCSID("$NetBSD: strncat_chk.c,v 1.4 2009/11/17 20:44:26 drochner Exp $"); #include #include +#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 diff --git a/lib/nbsd_libc/ssp/strncpy_chk.c b/lib/nbsd_libc/ssp/strncpy_chk.c index 2fe5211bf..af876feda 100644 --- a/lib/nbsd_libc/ssp/strncpy_chk.c +++ b/lib/nbsd_libc/ssp/strncpy_chk.c @@ -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 diff --git a/lib/nbsd_libc/stdlib/strfmon.c b/lib/nbsd_libc/stdlib/strfmon.c index d53ed7f13..8ce598bcd 100644 --- a/lib/nbsd_libc/stdlib/strfmon.c +++ b/lib/nbsd_libc/stdlib/strfmon.c @@ -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 #endif diff --git a/lib/nbsd_libc/string/strmode.c b/lib/nbsd_libc/string/strmode.c index 6d7bd1f52..40b81a1f3 100644 --- a/lib/nbsd_libc/string/strmode.c +++ b/lib/nbsd_libc/string/strmode.c @@ -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); diff --git a/lib/nbsd_libc/sys-minix/__getcwd.c b/lib/nbsd_libc/sys-minix/__getcwd.c index 7fec1faad..af4a60037 100644 --- a/lib/nbsd_libc/sys-minix/__getcwd.c +++ b/lib/nbsd_libc/sys-minix/__getcwd.c @@ -15,6 +15,9 @@ #include #include +/* 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(".", ¤t) < 0) return -1; while (1) { - dotdot= ".."; if (stat(dotdot, &above) < 0) { recover(p); return -1; } if (above.st_dev == current.st_dev diff --git a/lib/nbsd_libc/sys-minix/bind.c b/lib/nbsd_libc/sys-minix/bind.c index 666164af1..dfad3b0f8 100644 --- a/lib/nbsd_libc/sys-minix/bind.c +++ b/lib/nbsd_libc/sys-minix/bind.c @@ -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) { diff --git a/lib/nbsd_libc/sys-minix/getgroups.c b/lib/nbsd_libc/sys-minix/getgroups.c index ded3dc122..30ad4b1cf 100644 --- a/lib/nbsd_libc/sys-minix/getgroups.c +++ b/lib/nbsd_libc/sys-minix/getgroups.c @@ -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)); } diff --git a/lib/nbsd_libc/sys-minix/getsid.c b/lib/nbsd_libc/sys-minix/getsid.c index c4505fcc1..7b8170e69 100644 --- a/lib/nbsd_libc/sys-minix/getsid.c +++ b/lib/nbsd_libc/sys-minix/getsid.c @@ -1,8 +1,9 @@ #include -#include #include "namespace.h" +#include #include +#include pid_t getsid(pid_t p) { diff --git a/lib/nbsd_libc/sys-minix/mount.c b/lib/nbsd_libc/sys-minix/mount.c index dc543a839..8a24160af 100644 --- a/lib/nbsd_libc/sys-minix/mount.c +++ b/lib/nbsd_libc/sys-minix/mount.c @@ -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? */ diff --git a/lib/nbsd_libc/sys-minix/sendmsg.c b/lib/nbsd_libc/sys-minix/sendmsg.c index 52727cd6e..6ffa7ab0f 100644 --- a/lib/nbsd_libc/sys-minix/sendmsg.c +++ b/lib/nbsd_libc/sys-minix/sendmsg.c @@ -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 diff --git a/lib/nbsd_libc/sys-minix/sendto.c b/lib/nbsd_libc/sys-minix/sendto.c index 367c9be11..d746e0556 100644 --- a/lib/nbsd_libc/sys-minix/sendto.c +++ b/lib/nbsd_libc/sys-minix/sendto.c @@ -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); diff --git a/lib/nbsd_libc/sys-minix/stat.c b/lib/nbsd_libc/sys-minix/stat.c index ee39727eb..3357acf53 100644 --- a/lib/nbsd_libc/sys-minix/stat.c +++ b/lib/nbsd_libc/sys-minix/stat.c @@ -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; diff --git a/lib/nbsd_libc/sys-minix/sysuname.c b/lib/nbsd_libc/sys-minix/sysuname.c index 2ce733272..142d3bea4 100644 --- a/lib/nbsd_libc/sys-minix/sysuname.c +++ b/lib/nbsd_libc/sys-minix/sysuname.c @@ -5,6 +5,7 @@ #include #include "namespace.h" #include +#include int sysuname(int req, int field, char *value, size_t len) { diff --git a/lib/nbsd_libc/termios/tcsetattr.c b/lib/nbsd_libc/termios/tcsetattr.c index 43f11645b..b72e197cf 100644 --- a/lib/nbsd_libc/termios/tcsetattr.c +++ b/lib/nbsd_libc/termios/tcsetattr.c @@ -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); diff --git a/lib/nbsd_libcompat_minix/passwd.c b/lib/nbsd_libcompat_minix/passwd.c index 119faf160..86890ed12 100644 --- a/lib/nbsd_libcompat_minix/passwd.c +++ b/lib/nbsd_libcompat_minix/passwd.c @@ -10,6 +10,7 @@ #include #include #include +#include /* * group_from_gid() diff --git a/lib/nbsd_libm/arch/i387/fenv.c b/lib/nbsd_libm/arch/i387/fenv.c index 085e030ab..cf94c5618 100644 --- a/lib/nbsd_libm/arch/i387/fenv.c +++ b/lib/nbsd_libm/arch/i387/fenv.c @@ -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 diff --git a/lib/nbsd_libminlib/vm_query_exit.c b/lib/nbsd_libminlib/vm_query_exit.c index f65218728..9f5596387 100644 --- a/lib/nbsd_libminlib/vm_query_exit.c +++ b/lib/nbsd_libminlib/vm_query_exit.c @@ -1,6 +1,7 @@ #define _SYSTEM 1 #include #include +#include /* 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; diff --git a/nbsd_include/sys/ctype_inline.h b/nbsd_include/sys/ctype_inline.h index 105cdcb2c..9cdc6e045 100644 --- a/nbsd_include/sys/ctype_inline.h +++ b/nbsd_include/sys/ctype_inline.h @@ -45,19 +45,19 @@ #include -#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) diff --git a/nbsd_include/sys/socket.h b/nbsd_include/sys/socket.h index 24b9d4525..a738ce842 100644 --- a/nbsd_include/sys/socket.h +++ b/nbsd_include/sys/socket.h @@ -274,6 +274,9 @@ struct cmsghdr { #include +__BEGIN_DECLS +int __cmsg_alignbytes(void); +__END_DECLS __BEGIN_DECLS int accept(int, struct sockaddr * __restrict, socklen_t * __restrict); diff --git a/nbsd_include/sys/syslimits.h b/nbsd_include/sys/syslimits.h index 4fb0039dc..a795e03b7 100644 --- a/nbsd_include/sys/syslimits.h +++ b/nbsd_include/sys/syslimits.h @@ -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) */ diff --git a/nbsd_include/unistd.h b/nbsd_include/unistd.h index c7621e8ec..445775424 100644 --- a/nbsd_include/unistd.h +++ b/nbsd_include/unistd.h @@ -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, ...); diff --git a/share/mk/minix.gcc.mk b/share/mk/minix.gcc.mk index 5366519ad..658489531 100644 --- a/share/mk/minix.gcc.mk +++ b/share/mk/minix.gcc.mk @@ -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 diff --git a/test/Makefile b/test/Makefile index cba7e3fec..1721030b2 100644 --- a/test/Makefile +++ b/test/Makefile @@ -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 diff --git a/test/t40e.c b/test/t40e.c index 5a5ba4c39..1a8f8293a 100644 --- a/test/t40e.c +++ b/test/t40e.c @@ -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 diff --git a/test/test10.c b/test/test10.c index 0d7145382..b5e8c28e3 100644 --- a/test/test10.c +++ b/test/test10.c @@ -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); diff --git a/test/test11.c b/test/test11.c index a1ab97f80..1e279cf19 100644 --- a/test/test11.c +++ b/test/test11.c @@ -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++; diff --git a/test/test17.c b/test/test17.c index 0fbd6898a..faed624c1 100644 --- a/test/test17.c +++ b/test/test17.c @@ -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. */ diff --git a/test/test18.c b/test/test18.c index 8378d81a1..0bdcb0101 100644 --- a/test/test18.c +++ b/test/test18.c @@ -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. */ diff --git a/test/test19.c b/test/test19.c index b0cad2bba..8499b4b81 100644 --- a/test/test19.c +++ b/test/test19.c @@ -8,11 +8,11 @@ #include #include -#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; - m = (argc == 2 ? atoi(argv[1]) : 0xFFFF); + start(19); - system("rm -rf DIR_19; mkdir DIR_19"); - chdir("DIR_19"); + m = (argc == 2 ? atoi(argv[1]) : 0xFFFF); - 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); - } -} - diff --git a/test/test21.c b/test/test21.c index 961fadb9b..0aa5abd78 100644 --- a/test/test21.c +++ b/test/test21.c @@ -16,7 +16,7 @@ #include #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(); diff --git a/test/test25.c b/test/test25.c index 789f0a43d..9c7f539bc 100644 --- a/test/test25.c +++ b/test/test25.c @@ -43,7 +43,6 @@ _PROTOTYPE(void makelongnames, (void)); int main(int argc, char *argv[]) { - char buffer[PATH_MAX + 1]; int i, m = 0xFFFF; sync(); diff --git a/test/test27.c b/test/test27.c index 689486b8d..a81b49caa 100644 --- a/test/test27.c +++ b/test/test27.c @@ -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); diff --git a/test/test28.c b/test/test28.c index 0abee297a..4c81b4608 100644 --- a/test/test28.c +++ b/test/test28.c @@ -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 */ diff --git a/test/test3.c b/test/test3.c index a71ed5f9c..089d8f0ba 100644 --- a/test/test3.c +++ b/test/test3.c @@ -12,42 +12,32 @@ #include #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); - } -} diff --git a/test/test42.c b/test/test42.c index 39787821b..2b5be5fcc 100644 --- a/test/test42.c +++ b/test/test42.c @@ -883,7 +883,6 @@ void test_attach_child() void test_attach() { pid_t pid; - int r, status; subtest = 9; diff --git a/test/test43.c b/test/test43.c index 0e4d509ab..f32a2bc4d 100644 --- a/test/test43.c +++ b/test/test43.c @@ -11,38 +11,14 @@ #include #include -#define MAX_ERROR 4 +#define MAX_ERROR 3 -static int errct = 0; -static const char *executable, *subtest; +int subtest; +static const char *executable; -#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); - } -} +#include "common.c" -static void quit(void) -{ - if (errct == 0) - { - printf("ok\n"); - exit(0); - } - else - { - printf("%d errors\n", errct); - exit(1); - } -} +#define ERR (e(__LINE__)) static char *remove_last_path_component(char *path) { @@ -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("", "."); diff --git a/test/test45.c b/test/test45.c index c7a2f0837..85f546a37 100644 --- a/test/test45.c +++ b/test/test45.c @@ -4,6 +4,10 @@ #include #include +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wtautological-compare" +#endif + #define MAX_ERROR 4 static int errct; diff --git a/test/test46.c b/test/test46.c index 35b962c22..d64d5c849 100644 --- a/test/test46.c +++ b/test/test46.c @@ -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 diff --git a/test/test47.c b/test/test47.c index 3461c818c..77ee58ae6 100644 --- a/test/test47.c +++ b/test/test47.c @@ -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); diff --git a/test/test48.c b/test/test48.c index bbed6685d..8a79ebb16 100755 --- a/test/test48.c +++ b/test/test48.c @@ -6,7 +6,7 @@ #include #include -#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 (!exp_canonname && ai_cur->ai_canonname) - test_getaddrinfo_err(8, - TEST_GETADDRINFO_ERR_PARAMS, - NULL, 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); + } /* 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< 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(); diff --git a/test/test5.c b/test/test5.c index 284820813..1de5c66aa 100644 --- a/test/test5.c +++ b/test/test5.c @@ -11,14 +11,14 @@ #include #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); - } -} diff --git a/test/test50.c b/test/test50.c index d83c2ba2b..8aa0de986 100644 --- a/test/test50.c +++ b/test/test50.c @@ -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); diff --git a/test/test52.c b/test/test52.c index 39090d67e..65986a1a5 100644 --- a/test/test52.c +++ b/test/test52.c @@ -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); diff --git a/test/test53.c b/test/test53.c index 337bacaed..ac2369382 100644 --- a/test/test53.c +++ b/test/test53.c @@ -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), diff --git a/test/test54.c b/test/test54.c index ed9950d21..05094e2e0 100644 --- a/test/test54.c +++ b/test/test54.c @@ -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); diff --git a/test/test55.c b/test/test55.c index 5dbbb0004..d309d390d 100644 --- a/test/test55.c +++ b/test/test55.c @@ -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(); - - r = statvfs(TMPPATH, &stats); + create_file(); - 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; - - 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; + 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))) { + e(4); } } - return 1; + quit(); + return(-1); } diff --git a/test/test56.c b/test/test56.c index 216d4409a..0d350c5e7 100644 --- a/test/test56.c +++ b/test/test56.c @@ -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 */ diff --git a/test/test6.c b/test/test6.c index 9e8ba5f16..f7817cb7c 100644 --- a/test/test6.c +++ b/test/test6.c @@ -10,42 +10,30 @@ #include #include -#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); - } -} diff --git a/test/test9.c b/test/test9.c index 932825590..2709e72ed 100644 --- a/test/test9.c +++ b/test/test9.c @@ -144,9 +144,10 @@ jmp_buf env; char * addr() { - char a; + char a, *ret; - return &a; + ret = &a; + return(ret); } void garbage() diff --git a/usr.bin/mkimage/mkimage.c b/usr.bin/mkimage/mkimage.c index f89d561c8..e20031a3d 100644 --- a/usr.bin/mkimage/mkimage.c +++ b/usr.bin/mkimage/mkimage.c @@ -80,7 +80,7 @@ int main(int argc, char **argv) { int i, ch; - GElf_Addr startaddr, endaddr; + GElf_Addr startaddr; startaddr = BOOTPROG_LOAD_START; -- 2.44.0