diff options
author | Kurt Miller <kurt@cvs.openbsd.org> | 2007-05-18 19:28:51 +0000 |
---|---|---|
committer | Kurt Miller <kurt@cvs.openbsd.org> | 2007-05-18 19:28:51 +0000 |
commit | f0cf4bacaaadaebed70dddae959a34afae61012e (patch) | |
tree | 0922d2833eb5f8c154cf558b84d5ca14a78fc1c9 /lib | |
parent | a6be8fe77d4938b29cf75fd12ddfee98e132d71f (diff) |
Eliminate many lint warnings by either: using the appropriate type,
casting when safe or adding ARGSUSED where needed. Reviewed and
improvements from millert@ and marc@. okay marc@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libpthread/uthread/uthread_fd.c | 4 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_file.c | 5 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_info_openbsd.c | 13 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_init.c | 10 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_kern.c | 7 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_priority_queue.c | 6 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_rwlock.c | 3 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_select.c | 14 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_sem.c | 5 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_sig.c | 5 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_stack.c | 6 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_stackseg_np.c | 7 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_write.c | 19 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_writev.c | 17 |
14 files changed, 70 insertions, 51 deletions
diff --git a/lib/libpthread/uthread/uthread_fd.c b/lib/libpthread/uthread/uthread_fd.c index 6b22bafd6ec..c214e20ab9d 100644 --- a/lib/libpthread/uthread/uthread_fd.c +++ b/lib/libpthread/uthread/uthread_fd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_fd.c,v 1.29 2007/04/27 18:04:08 kurt Exp $ */ +/* $OpenBSD: uthread_fd.c,v 1.30 2007/05/18 19:28:50 kurt Exp $ */ /* * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> * All rights reserved. @@ -201,7 +201,7 @@ _thread_fd_init(void) struct fs_flags *status_flags; saved_errno = errno; - flags = calloc(_thread_init_fdtsize, sizeof *flags); + flags = calloc((size_t)_thread_init_fdtsize, sizeof *flags); if (flags == NULL) PANIC("Cannot allocate memory for flags table"); diff --git a/lib/libpthread/uthread/uthread_file.c b/lib/libpthread/uthread/uthread_file.c index 41f62ee7357..40af6f084a5 100644 --- a/lib/libpthread/uthread/uthread_file.c +++ b/lib/libpthread/uthread/uthread_file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_file.c,v 1.12 2005/10/14 06:53:01 otto Exp $ */ +/* $OpenBSD: uthread_file.c,v 1.13 2007/05/18 19:28:50 kurt Exp $ */ /* * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. * All rights reserved. @@ -37,6 +37,7 @@ * level too. * */ +#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -76,7 +77,7 @@ struct file_lock { * structures. If there is a collision, a linear search of the * dynamic list of locks linked to each static lock is perfomed. */ -#define file_idx(_p) ((((u_long) _p) >> sizeof(void *)) % NUM_HEADS) +#define file_idx(_p) ((int)((((uintptr_t) _p) >> sizeof(void *)) % NUM_HEADS)) /* * Global array of file locks. The first lock for each hash bucket is diff --git a/lib/libpthread/uthread/uthread_info_openbsd.c b/lib/libpthread/uthread/uthread_info_openbsd.c index 5353fe4fc05..37acbaa2a1c 100644 --- a/lib/libpthread/uthread/uthread_info_openbsd.c +++ b/lib/libpthread/uthread/uthread_info_openbsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_info_openbsd.c,v 1.13 2007/05/01 18:16:37 kurt Exp $ */ +/* $OpenBSD: uthread_info_openbsd.c,v 1.14 2007/05/18 19:28:50 kurt Exp $ */ /* * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> @@ -88,7 +88,7 @@ truncname(const char *name, int maxlen) if (name == NULL) name = "(null)"; - len = strlen(name); + len = (int)strlen(name); if (len > maxlen) return name + len - maxlen; else @@ -416,6 +416,7 @@ _thread_dump_data(const void *addr, int len) { int fd = -1; unsigned char data[DUMP_BUFLEN]; + const unsigned char hexdigits[] = "0123456789abcdef"; if (getenv("PTHREAD_DEBUG") != NULL) fd = _thread_sys_open(_PATH_TTY, O_WRONLY | O_APPEND); @@ -441,19 +442,19 @@ _thread_dump_data(const void *addr, int len) } addr = (char *)addr + 8; - snprintf(data, DUMP_BUFLEN, "%18p: ", d); + snprintf((char *)data, DUMP_BUFLEN, "%18p: ", d); while (count--) { if (isprint(*d)) *a++ = *d; else *a++ = '.'; - *h++ = "0123456789abcdef"[(*d >> 4) & 0xf]; - *h++ = "0123456789abcdef"[*d++ & 0xf]; + *h++ = hexdigits[(*d >> 4) & 0xf]; + *h++ = hexdigits[*d++ & 0xf]; *h++ = ' '; } *a++ = '\n'; *a = 0; - _thread_sys_write(fd, data, a - data); + _thread_sys_write(fd, data, (size_t)(a - data)); } writestring(fd, "\n"); _thread_sys_close(fd); diff --git a/lib/libpthread/uthread/uthread_init.c b/lib/libpthread/uthread/uthread_init.c index c8c57c0170d..987e6770d4f 100644 --- a/lib/libpthread/uthread/uthread_init.c +++ b/lib/libpthread/uthread/uthread_init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_init.c,v 1.36 2007/04/27 12:59:24 kurt Exp $ */ +/* $OpenBSD: uthread_init.c,v 1.37 2007/05/18 19:28:50 kurt Exp $ */ /* * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> * All rights reserved. @@ -350,11 +350,11 @@ _thread_init(void) if (getrlimit(RLIMIT_NOFILE, &rl) != 0) PANIC("getrlimit failed"); - _thread_init_fdtsize = rl.rlim_cur; - _thread_max_fdtsize = rl.rlim_max; + _thread_init_fdtsize = (int)rl.rlim_cur; + _thread_max_fdtsize = (int)rl.rlim_max; /* Allocate memory for the file descriptor table: */ - _thread_fd_table = calloc(_thread_max_fdtsize, + _thread_fd_table = calloc((size_t)_thread_max_fdtsize, sizeof(struct fd_table_entry *)); if (_thread_fd_table == NULL) { _thread_max_fdtsize = 0; @@ -362,7 +362,7 @@ _thread_init(void) } /* Allocate memory for the pollfd table: */ - _thread_pfd_table = calloc(_thread_max_fdtsize, sizeof(struct pollfd)); + _thread_pfd_table = calloc((size_t)_thread_max_fdtsize, sizeof(struct pollfd)); if (_thread_pfd_table == NULL) PANIC("Cannot allocate memory for pollfd table"); diff --git a/lib/libpthread/uthread/uthread_kern.c b/lib/libpthread/uthread/uthread_kern.c index 02c9a42b418..dd5b767fb06 100644 --- a/lib/libpthread/uthread/uthread_kern.c +++ b/lib/libpthread/uthread/uthread_kern.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_kern.c,v 1.34 2007/04/27 12:59:24 kurt Exp $ */ +/* $OpenBSD: uthread_kern.c,v 1.35 2007/05/18 19:28:50 kurt Exp $ */ /* * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> * All rights reserved. @@ -622,7 +622,7 @@ _thread_kern_poll(int wait_reqd) * timeout: */ timeout_ms = ((pthread->wakeup_time.tv_sec - ts.tv_sec) * - 1000) + ((pthread->wakeup_time.tv_nsec - ts.tv_nsec) / + 1000) + (time_t)((pthread->wakeup_time.tv_nsec - ts.tv_nsec) / 1000000); /* * Don't allow negative timeouts: @@ -1041,7 +1041,8 @@ void _dequeue_signals(void) { char bufr[128]; - int i, num; + int i; + ssize_t num; /* * Enter a loop to read and handle queued signals from the diff --git a/lib/libpthread/uthread/uthread_priority_queue.c b/lib/libpthread/uthread/uthread_priority_queue.c index 918ff694aec..a9fe248f704 100644 --- a/lib/libpthread/uthread/uthread_priority_queue.c +++ b/lib/libpthread/uthread/uthread_priority_queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_priority_queue.c,v 1.4 2001/09/04 23:28:31 fgsch Exp $ */ +/* $OpenBSD: uthread_priority_queue.c,v 1.5 2007/05/18 19:28:50 kurt Exp $ */ /* * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>. * All rights reserved. @@ -89,12 +89,12 @@ _pq_alloc(pq_queue_t *pq, int minprio, int maxprio) int ret = 0; int prioslots = maxprio - minprio + 1; - if (pq == NULL) + if (pq == NULL || prioslots < 1) ret = -1; /* Create the priority queue with (maxprio - minprio + 1) slots: */ else if ((pq->pq_lists = - (pq_list_t *) malloc(sizeof(pq_list_t) * prioslots)) == NULL) + (pq_list_t *) malloc(sizeof(pq_list_t) * (size_t)prioslots)) == NULL) ret = -1; else { diff --git a/lib/libpthread/uthread/uthread_rwlock.c b/lib/libpthread/uthread/uthread_rwlock.c index 66e21f61f76..b5c2d4da339 100644 --- a/lib/libpthread/uthread/uthread_rwlock.c +++ b/lib/libpthread/uthread/uthread_rwlock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_rwlock.c,v 1.5 2004/02/01 06:22:14 brad Exp $ */ +/* $OpenBSD: uthread_rwlock.c,v 1.6 2007/05/18 19:28:50 kurt Exp $ */ /*- * Copyright (c) 1998 Alex Nash * All rights reserved. @@ -83,6 +83,7 @@ pthread_rwlock_destroy (pthread_rwlock_t *rwlock) return (ret); } +/* ARGSUSED */ int pthread_rwlock_init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) { diff --git a/lib/libpthread/uthread/uthread_select.c b/lib/libpthread/uthread/uthread_select.c index 32d6ee7f255..3ee185f7c27 100644 --- a/lib/libpthread/uthread/uthread_select.c +++ b/lib/libpthread/uthread/uthread_select.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_select.c,v 1.14 2007/04/27 12:59:24 kurt Exp $ */ +/* $OpenBSD: uthread_select.c,v 1.15 2007/05/18 19:28:50 kurt Exp $ */ /* * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> * All rights reserved. @@ -57,7 +57,8 @@ select(int numfds, fd_set * readfds, fd_set * writefds, struct pthread *curthread = _get_curthread(); struct timespec ts; int bit, i, j, ret = 0, f_wait = 1; - int events, got_events = 0, fd_count = 0; + short events; + int got_events = 0, fd_count = 0; struct pthread_poll_data data; fd_mask mask, rmask, wmask, emask; @@ -67,6 +68,7 @@ select(int numfds, fd_set * readfds, fd_set * writefds, if (numfds > _thread_max_fdtsize) { numfds = _thread_max_fdtsize; } + /* Check if a timeout was specified: */ if (timeout) { if (timeout->tv_sec < 0 || @@ -90,7 +92,7 @@ select(int numfds, fd_set * readfds, fd_set * writefds, /* Count the number of file descriptors to be polled: */ if (numfds && (readfds || writefds || exceptfds)) { - for (i = (numfds - 1) / NFDBITS; i >= 0; i--) { + for (i = (numfds - 1) / (int)NFDBITS; i >= 0; i--) { rmask = readfds ? readfds->fds_bits[i] : 0; wmask = writefds ? writefds->fds_bits[i] : 0; emask = exceptfds ? exceptfds->fds_bits[i] : 0; @@ -107,7 +109,7 @@ select(int numfds, fd_set * readfds, fd_set * writefds, if ((curthread->poll_data.fds == NULL) || (curthread->poll_data.nfds < fd_count)) { data.fds = (struct pollfd *) realloc(curthread->poll_data.fds, - sizeof(struct pollfd) * MAX(POLLDATA_MIN, fd_count)); + sizeof(struct pollfd) * (size_t)MAX(POLLDATA_MIN, fd_count)); if (data.fds == NULL) { errno = ENOMEM; ret = -1; @@ -132,7 +134,7 @@ select(int numfds, fd_set * readfds, fd_set * writefds, * running the loop in reverse and stopping when * the number of selected file descriptors is reached. */ - for (i = (numfds - 1) / NFDBITS, j = fd_count; + for (i = (numfds - 1) / (int)NFDBITS, j = fd_count; j != 0 && i >= 0; i--) { rmask = readfds ? readfds->fds_bits[i] : 0; wmask = writefds ? writefds->fds_bits[i] : 0; @@ -155,7 +157,7 @@ select(int numfds, fd_set * readfds, fd_set * writefds, * timeout which leaves fds unchanged: */ data.fds[--j].fd = - (i * NFDBITS) + bit - 1; + (i * (int)NFDBITS) + bit - 1; data.fds[j].events = events; data.fds[j].revents = 0; } diff --git a/lib/libpthread/uthread/uthread_sem.c b/lib/libpthread/uthread/uthread_sem.c index 21f7cf86975..7078449aad2 100644 --- a/lib/libpthread/uthread/uthread_sem.c +++ b/lib/libpthread/uthread/uthread_sem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_sem.c,v 1.1 2002/01/18 22:07:27 fgsch Exp $ */ +/* $OpenBSD: uthread_sem.c,v 1.2 2007/05/18 19:28:50 kurt Exp $ */ /* * Copyright (C) 2000 Jason Evans <jasone@freebsd.org>. * All rights reserved. @@ -131,6 +131,7 @@ sem_destroy(sem_t *sem) return retval; } +/* ARGSUSED */ sem_t * sem_open(const char *name, int oflag, ...) { @@ -138,6 +139,7 @@ sem_open(const char *name, int oflag, ...) return SEM_FAILED; } +/* ARGSUSED */ int sem_close(sem_t *sem) { @@ -145,6 +147,7 @@ sem_close(sem_t *sem) return -1; } +/* ARGSUSED */ int sem_unlink(const char *name) { diff --git a/lib/libpthread/uthread/uthread_sig.c b/lib/libpthread/uthread/uthread_sig.c index 5c65781e552..8766470fc95 100644 --- a/lib/libpthread/uthread/uthread_sig.c +++ b/lib/libpthread/uthread/uthread_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_sig.c,v 1.23 2007/04/27 12:59:24 kurt Exp $ */ +/* $OpenBSD: uthread_sig.c,v 1.24 2007/05/18 19:28:50 kurt Exp $ */ /* * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> * All rights reserved. @@ -128,7 +128,7 @@ _thread_sig_handler(int sig, siginfo_t *info, struct sigcontext * scp) * that it will be ready to read when this signal * handler returns. */ - c = sig; + c = (char)sig; _thread_sys_write(_thread_kern_pipe[1], &c, 1); _sigq_check_reqd = 1; } else { @@ -166,6 +166,7 @@ _thread_clear_pending(int sig, pthread_t thread) * Process the given signal. Returns 1 if the signal may be dispatched, * otherwise 0. Signals MUST be defered when this function is called. */ +/* ARGSUSED */ int _thread_sig_handle(int sig, struct sigcontext * scp) { diff --git a/lib/libpthread/uthread/uthread_stack.c b/lib/libpthread/uthread/uthread_stack.c index 039adfa83d3..bf3e3976444 100644 --- a/lib/libpthread/uthread/uthread_stack.c +++ b/lib/libpthread/uthread/uthread_stack.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_stack.c,v 1.9 2006/09/26 14:50:37 kurt Exp $ */ +/* $OpenBSD: uthread_stack.c,v 1.10 2007/05/18 19:28:50 kurt Exp $ */ /* * Copyright 1999, David Leonard. All rights reserved. * <insert BSD-style license&disclaimer> @@ -77,13 +77,13 @@ _thread_stack_alloc(base, size) */ #if defined(MACHINE_STACK_GROWS_UP) /* Red zone is the last page of the storage: */ - stack->redzone = (void *)((caddr_t)stack->storage + (__ptrdiff_t)size); + stack->redzone = (void *)((caddr_t)stack->storage + (ptrdiff_t)size); stack->base = stack->storage; stack->size = size; #else /* Red zone is the first page of the storage: */ stack->redzone = stack->storage; - stack->base = (caddr_t)stack->redzone + (__ptrdiff_t)nbpg; + stack->base = (caddr_t)stack->redzone + (ptrdiff_t)nbpg; stack->size = size; #endif if (mprotect(stack->redzone, nbpg, PROT_NONE) == -1) diff --git a/lib/libpthread/uthread/uthread_stackseg_np.c b/lib/libpthread/uthread/uthread_stackseg_np.c index e2a9bd558d9..cd423aeaf9a 100644 --- a/lib/libpthread/uthread/uthread_stackseg_np.c +++ b/lib/libpthread/uthread/uthread_stackseg_np.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_stackseg_np.c,v 1.4 2004/05/01 22:15:10 marc Exp $ */ +/* $OpenBSD: uthread_stackseg_np.c,v 1.5 2007/05/18 19:28:50 kurt Exp $ */ /* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */ @@ -9,6 +9,7 @@ #include <errno.h> #include <pthread.h> #include <pthread_np.h> +#include <stddef.h> #include <unistd.h> #include <uvm/uvm_extern.h> @@ -30,14 +31,14 @@ pthread_stackseg_np(pthread_t thread, stack_t *sinfo) if (thread->stack) { base = thread->stack->base; #if !defined(MACHINE_STACK_GROWS_UP) - base += thread->stack->size; + base += (ptrdiff_t)thread->stack->size; #endif sinfo->ss_sp = base; sinfo->ss_size = thread->stack->size; sinfo->ss_flags = 0; ret = 0; } else if (thread == _thread_initial) { - pgsz = sysconf(_SC_PAGESIZE); + pgsz = (size_t)sysconf(_SC_PAGESIZE); if (pgsz == (size_t)-1) ret = EAGAIN; else { diff --git a/lib/libpthread/uthread/uthread_write.c b/lib/libpthread/uthread/uthread_write.c index 2c4ed1076ff..ca1a99a7e78 100644 --- a/lib/libpthread/uthread/uthread_write.c +++ b/lib/libpthread/uthread/uthread_write.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_write.c,v 1.12 2006/10/03 02:59:36 kurt Exp $ */ +/* $OpenBSD: uthread_write.c,v 1.13 2007/05/18 19:28:50 kurt Exp $ */ /* * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> * All rights reserved. @@ -37,6 +37,7 @@ #include <sys/fcntl.h> #include <sys/uio.h> #include <errno.h> +#include <stddef.h> #include <unistd.h> #ifdef _THREAD_SAFE #include <pthread.h> @@ -58,9 +59,11 @@ write(int fd, const void *buf, size_t nbytes) /* POSIX says to do just this: */ if (nbytes == 0) ret = 0; - + else if (nbytes > SSIZE_MAX) { + errno = EINVAL; + ret = -1; /* Lock the file descriptor for write: */ - else if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) { + } else if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) { /* Get the read/write mode type: */ type = _thread_fd_table[fd]->status_flags->flags & O_ACCMODE; @@ -81,7 +84,7 @@ write(int fd, const void *buf, size_t nbytes) */ while (ret == 0) { /* Perform a non-blocking write syscall: */ - n = _thread_sys_write(fd, (caddr_t)buf + num, + n = _thread_sys_write(fd, (caddr_t)buf + (ptrdiff_t)num, nbytes - num); /* Check if one or more bytes were written: */ @@ -90,7 +93,7 @@ write(int fd, const void *buf, size_t nbytes) * Keep a count of the number of bytes * written: */ - num += n; + num += (size_t)n; /* * If performing a blocking write, check if the @@ -117,7 +120,7 @@ write(int fd, const void *buf, size_t nbytes) if (curthread->interrupted || curthread->closing_fd) { if (num > 0) { /* Return partial success: */ - ret = num; + ret = (ssize_t)num; } else { /* Return an error: */ if (curthread->closing_fd) @@ -143,7 +146,7 @@ write(int fd, const void *buf, size_t nbytes) */ } else if (n <= 0) { if (num > 0) - ret = num; + ret = (ssize_t)num; else ret = n; if (n == 0) @@ -152,7 +155,7 @@ write(int fd, const void *buf, size_t nbytes) /* Check if the write has completed: */ } else if (num >= nbytes) /* Return the number of bytes written: */ - ret = num; + ret = (ssize_t)num; } } _FD_UNLOCK(fd, FD_WRITE); diff --git a/lib/libpthread/uthread/uthread_writev.c b/lib/libpthread/uthread/uthread_writev.c index 45b1c80a2ee..17850b0f875 100644 --- a/lib/libpthread/uthread/uthread_writev.c +++ b/lib/libpthread/uthread/uthread_writev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_writev.c,v 1.12 2006/10/03 02:59:36 kurt Exp $ */ +/* $OpenBSD: uthread_writev.c,v 1.13 2007/05/18 19:28:50 kurt Exp $ */ /* * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> * All rights reserved. @@ -37,6 +37,7 @@ #include <sys/fcntl.h> #include <sys/uio.h> #include <errno.h> +#include <stddef.h> #include <stdlib.h> #include <string.h> #include <unistd.h> @@ -51,7 +52,7 @@ writev(int fd, const struct iovec * iov, int iovcnt) int blocking; int idx = 0; int type; - size_t num = 0; + ssize_t num = 0; size_t cnt; ssize_t n; ssize_t ret; @@ -65,16 +66,20 @@ writev(int fd, const struct iovec * iov, int iovcnt) if (iovcnt > (int) (sizeof(liov) / sizeof(struct iovec))) { /* Allocate memory for the local array: */ if ((p_iov = (struct iovec *) - malloc(iovcnt * sizeof(struct iovec))) == NULL) { + malloc((size_t)iovcnt * sizeof(struct iovec))) == NULL) { /* Insufficient memory: */ errno = ENOMEM; _thread_leave_cancellation_point(); return (-1); } + } else if (iovcnt <= 0) { + errno = EINVAL; + _thread_leave_cancellation_point(); + return (-1); } /* Copy the caller's array so that it can be modified locally: */ - memcpy(p_iov,iov,iovcnt * sizeof(struct iovec)); + memcpy(p_iov,iov,(size_t)iovcnt * sizeof(struct iovec)); /* Lock the file descriptor for write: */ if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) { @@ -117,7 +122,7 @@ writev(int fd, const struct iovec * iov, int iovcnt) * array entry where the short write * ended: */ - cnt = n; + cnt = (size_t)n; while (cnt > 0 && idx < iovcnt) { /* * If the residual count exceeds @@ -143,7 +148,7 @@ writev(int fd, const struct iovec * iov, int iovcnt) p_iov[idx].iov_len -= cnt; p_iov[idx].iov_base = (char *)p_iov[idx].iov_base - + cnt; + + (ptrdiff_t)cnt; cnt = 0; } } |