libc: resolve minix clang warnings

Change-Id: If6c42f7346cc1b00b387ae8d3b4f0df3ffb0244f
This commit is contained in:
David van Moolenbroek 2014-09-30 20:35:56 +00:00
parent 685aa79304
commit 5dd8da10c5
20 changed files with 37 additions and 30 deletions

View file

@ -15,6 +15,9 @@ void _cpuid(u32_t *eax, u32_t *ebx, u32_t *ecx, u32_t *edx);
int load_mtab(char *_prog_name); int load_mtab(char *_prog_name);
int get_mtab_entry(char dev[PATH_MAX], char mount_point[PATH_MAX], int get_mtab_entry(char dev[PATH_MAX], char mount_point[PATH_MAX],
char type[MNTNAMELEN], char flags[MNTFLAGLEN]); char type[MNTNAMELEN], char flags[MNTFLAGLEN]);
int servxcheck(unsigned long peer, const char *service,
void (*logf)(int pass, const char *name));
char *servxfile(const char *file);
/* read_tsc() and friends */ /* read_tsc() and friends */
void read_tsc(u32_t *hi, u32_t *lo); void read_tsc(u32_t *hi, u32_t *lo);

View file

@ -149,7 +149,7 @@ static void skipwhite(void)
} }
} }
static void parse_err(void) static void __dead parse_err(void)
/* Tell user that you can't parse past the current character. */ /* Tell user that you can't parse past the current character. */
{ {
char sc[2]; char sc[2];

View file

@ -42,7 +42,7 @@
#define BUF_SIZE 512 /* size of the /etc/mtab buffer */ #define BUF_SIZE 512 /* size of the /etc/mtab buffer */
char *etc_mtab = "/etc/mtab"; /* name of the /etc/mtab file */ const char *etc_mtab = "/etc/mtab"; /* name of the /etc/mtab file */
static char mtab_in[BUF_SIZE+1]; /* holds /etc/mtab when it is read in */ static char mtab_in[BUF_SIZE+1]; /* holds /etc/mtab when it is read in */
static char *iptr = mtab_in; /* pointer to next line to feed out. */ static char *iptr = mtab_in; /* pointer to next line to feed out. */

View file

@ -24,6 +24,8 @@
#include <net/gen/inet.h> #include <net/gen/inet.h>
#include <net/gen/socket.h> #include <net/gen/socket.h>
#include <netdb.h> #include <netdb.h>
#include <arpa/inet.h>
#include <minix/minlib.h>
/* Default service access file. */ /* Default service access file. */
static const char *path_servacces = _PATH_SERVACCES; static const char *path_servacces = _PATH_SERVACCES;
@ -76,12 +78,12 @@ static int netspec(char *word, ipaddr_t *addr, ipaddr_t *mask)
if ((slash= strchr(word, '/')) == NULL) slash= S32; if ((slash= strchr(word, '/')) == NULL) slash= S32;
*slash= 0; *slash= 0;
r= inet_aton(word, addr); r= inet_aton(word, (struct in_addr *)addr);
*slash++= '/'; *slash++= '/';
if (!r) return 0; if (!r) return 0;
r= 0; r= 0;
while ((*slash - '0') < 10u) { while ((unsigned int)(*slash - '0') < 10u) {
r= 10*r + (*slash++ - '0'); r= 10*r + (*slash++ - '0');
if (r > 32) return 0; if (r > 32) return 0;
} }
@ -148,7 +150,7 @@ static int get_name(ipaddr_t addr, char *name)
} }
} }
} }
strcpy(name, inet_ntoa(addr)); strcpy(name, inet_ntoa(*(struct in_addr *)&addr));
return 0; return 0;
} }

View file

@ -5,6 +5,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
@ -38,6 +39,7 @@ int sethostname(const char *buf, size_t len)
r = write(fd, buf, len); r = write(fd, buf, len);
tmperr = errno; tmperr = errno;
fsync(fd);
close(fd); close(fd);
if (r == -1) { if (r == -1) {
@ -46,7 +48,7 @@ int sethostname(const char *buf, size_t len)
return -1; return -1;
} }
if (r < len) { if ((size_t)r < len) {
unlink(name); unlink(name);
errno = ENOSPC; errno = ENOSPC;
return -1; return -1;

View file

@ -1,6 +1,7 @@
#include <lib.h> #include <lib.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <minix/minlib.h>
void std_err(const char *s) void std_err(const char *s)
{ {

View file

@ -29,7 +29,7 @@ int fcntl(int fd, int cmd, ...)
case F_SETLK: case F_SETLK:
case F_SETLKW: case F_SETLKW:
case F_FREESP: case F_FREESP:
m.m_lc_vfs_fcntl.arg_ptr = va_arg(argp, struct flock *); m.m_lc_vfs_fcntl.arg_ptr = (vir_bytes)va_arg(argp, struct flock *);
break; break;
} }

View file

@ -7,7 +7,7 @@ int gcov_flush_svr(char *buff, int buff_sz, int server_nr)
message m; message m;
memset(&m, 0, sizeof(m)); memset(&m, 0, sizeof(m));
m.m_lc_vfs_gcov.buff_p = buff; m.m_lc_vfs_gcov.buff_p = (vir_bytes)buff;
m.m_lc_vfs_gcov.buff_sz = buff_sz; m.m_lc_vfs_gcov.buff_sz = buff_sz;
m.m_lc_vfs_gcov.pid = server_nr; m.m_lc_vfs_gcov.pid = server_nr;

View file

@ -71,7 +71,7 @@ int ioctl(int fd, unsigned long request, ...)
break; break;
default: default:
/* Keep original as-is */ /* Keep original as-is */
addr = data; addr = (vir_bytes)data;
break; break;
} }

View file

@ -12,7 +12,7 @@ int ptrace(int req, pid_t pid, void *addr, int data)
memset(&m, 0, sizeof(m)); memset(&m, 0, sizeof(m));
m.m_lc_pm_ptrace.pid = pid; m.m_lc_pm_ptrace.pid = pid;
m.m_lc_pm_ptrace.req = req; m.m_lc_pm_ptrace.req = req;
m.m_lc_pm_ptrace.addr = addr; m.m_lc_pm_ptrace.addr = (vir_bytes)addr;
m.m_lc_pm_ptrace.data = data; m.m_lc_pm_ptrace.data = data;
if (_syscall(PM_PROC_NR, PM_PTRACE, &m) < 0) return(-1); if (_syscall(PM_PROC_NR, PM_PTRACE, &m) < 0) return(-1);

View file

@ -19,7 +19,6 @@
#include <net/gen/udp_io.h> #include <net/gen/udp_io.h>
#include <net/gen/ip_hdr.h> #include <net/gen/ip_hdr.h>
#include <net/gen/icmp_hdr.h>
#define DEBUG 0 #define DEBUG 0
@ -88,15 +87,14 @@ ssize_t recvfrom(int sock, void *__restrict buffer, size_t length,
{ {
ip_hdr_t *ip_hdr; ip_hdr_t *ip_hdr;
int ihl, rd; int rd;
icmp_hdr_t *icmp_hdr;
struct sockaddr_in sin; struct sockaddr_in sin;
rd = read(sock, buffer, length); rd = read(sock, buffer, length);
if(rd < 0) return rd; if(rd < 0) return rd;
assert(rd >= sizeof(*ip_hdr)); assert((size_t)rd >= sizeof(*ip_hdr));
ip_hdr= buffer; ip_hdr= buffer;
@ -108,8 +106,8 @@ ssize_t recvfrom(int sock, void *__restrict buffer, size_t length,
sin.sin_addr.s_addr= ip_hdr->ih_src; sin.sin_addr.s_addr= ip_hdr->ih_src;
sin.sin_len= sizeof(sin); sin.sin_len= sizeof(sin);
len= *address_len; len= *address_len;
if (len > sizeof(sin)) if ((size_t)len > sizeof(sin))
len= sizeof(sin); len= (int)sizeof(sin);
memcpy(address, &sin, len); memcpy(address, &sin, len);
*address_len= sizeof(sin); *address_len= sizeof(sin);
} }
@ -237,7 +235,7 @@ static ssize_t _udp_recvfrom(int sock, void *__restrict buffer, size_t length,
return -1; return -1;
} }
assert(r >= sizeof(*io_hdrp)); assert((size_t)r >= sizeof(*io_hdrp));
length= r-sizeof(*io_hdrp); length= r-sizeof(*io_hdrp);
io_hdrp= buf; io_hdrp= buf;

View file

@ -3,6 +3,7 @@
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/ioc_net.h> #include <sys/ioc_net.h>
#include <sys/socket.h> #include <sys/socket.h>

View file

@ -13,7 +13,6 @@
#include <net/gen/in.h> #include <net/gen/in.h>
#include <net/gen/ip_hdr.h> #include <net/gen/ip_hdr.h>
#include <net/gen/icmp_hdr.h>
#include <net/gen/tcp.h> #include <net/gen/tcp.h>
#include <net/gen/tcp_io.h> #include <net/gen/tcp_io.h>
#include <net/gen/udp.h> #include <net/gen/udp.h>
@ -78,8 +77,6 @@ ssize_t sendto(int sock, const void *message, size_t length, int flags,
{ {
ip_hdr_t *ip_hdr; ip_hdr_t *ip_hdr;
int ihl;
icmp_hdr_t *icmp_hdr;
struct sockaddr_in *sinp; struct sockaddr_in *sinp;
sinp = (struct sockaddr_in *) __UNCONST(dest_addr); sinp = (struct sockaddr_in *) __UNCONST(dest_addr);
@ -199,7 +196,7 @@ static ssize_t _udp_sendto(int sock, const void *message, size_t length,
errno= t_errno; errno= t_errno;
return -1; return -1;
} }
assert(r == buflen); assert((size_t)r == buflen);
free(buf); free(buf);
return length; return length;
} }

View file

@ -11,7 +11,7 @@
*/ */
int setpgid(pid_t pid, pid_t pgid) int setpgid(pid_t pid, pid_t pgid)
{ {
pid_t _pid, _pgid, sid, cpid; pid_t _pid, _pgid, cpid;
_pid = pid; _pid = pid;
_pgid = pgid; _pgid = pgid;

View file

@ -9,8 +9,7 @@
/* Simple stub for now. */ /* Simple stub for now. */
int setrlimit(int resource, const struct rlimit *rlp) int setrlimit(int resource, const struct rlimit *rlp)
{ {
rlim_t limit;
switch (resource) switch (resource)
{ {
case RLIMIT_CPU: case RLIMIT_CPU:
@ -35,4 +34,3 @@ int setrlimit(int resource, const struct rlimit *rlp)
return 0; return 0;
} }

View file

@ -17,6 +17,7 @@
#include <minix/type.h> #include <minix/type.h>
#include <minix/minlib.h> #include <minix/minlib.h>
#include <minix/partition.h> #include <minix/partition.h>
#include <sys/ioctl.h>
#include <sys/ioc_disk.h> #include <sys/ioc_disk.h>
#include <unistd.h> #include <unistd.h>

View file

@ -9,9 +9,11 @@ __weak_alias(socket, __socket30)
#include <fcntl.h> #include <fcntl.h>
#include <signal.h> #include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <unistd.h> #include <unistd.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/ioc_net.h> #include <sys/ioc_net.h>
#include <net/hton.h> #include <net/hton.h>
#include <net/gen/in.h> #include <net/gen/in.h>
@ -148,8 +150,7 @@ static int _udp_socket(int type, int protocol)
static int _raw_socket(int type, int protocol) static int _raw_socket(int type, int protocol)
{ {
int r, fd, t_errno, flags = O_RDWR; int fd, flags = O_RDWR;
struct sockaddr_in sin;
nwio_ipopt_t ipopt; nwio_ipopt_t ipopt;
int result; int result;

View file

@ -6,6 +6,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <net/netlib.h> #include <net/netlib.h>
#include <sys/ioctl.h>
#include <sys/ioc_net.h> #include <sys/ioc_net.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/stat.h> #include <sys/stat.h>

View file

@ -23,8 +23,8 @@ int sprofile(int action,
m.m_lc_pm_sprof.mem_size = size; m.m_lc_pm_sprof.mem_size = size;
m.m_lc_pm_sprof.freq = freq; m.m_lc_pm_sprof.freq = freq;
m.m_lc_pm_sprof.intr_type = type; m.m_lc_pm_sprof.intr_type = type;
m.m_lc_pm_sprof.ctl_ptr = ctl_ptr; m.m_lc_pm_sprof.ctl_ptr = (vir_bytes)ctl_ptr;
m.m_lc_pm_sprof.mem_ptr = mem_ptr; m.m_lc_pm_sprof.mem_ptr = (vir_bytes)mem_ptr;
return _syscall(PM_PROC_NR, PM_SPROF, &m); return _syscall(PM_PROC_NR, PM_SPROF, &m);
} }

View file

@ -39,7 +39,9 @@ static ssize_t vectorio_buffer(int fildes, const struct iovec *iov,
while (copied < r) while (copied < r)
{ {
assert(iovidx < iovcnt); assert(iovidx < iovcnt);
len = MIN(r - copied, iov[iovidx].iov_len); len = iov[iovidx].iov_len;
if (len > r - copied)
len = r - copied;
memcpy(iov[iovidx++].iov_base, buffer + copied, len); memcpy(iov[iovidx++].iov_base, buffer + copied, len);
copied += len; copied += len;
} }