Fix the remaining signed/unsigned comparison warnings. Nothing stands out

as being dangerous or buggy.
This commit is contained in:
Nicholas J. Kain 2014-03-10 19:00:08 -04:00
parent e50bd431d6
commit e7838d542b
8 changed files with 28 additions and 28 deletions

View File

@ -112,7 +112,7 @@ static char arp_router_has_replied;
static char arp_server_has_replied;
static struct arpMsg arpreply;
static int arpreply_offset;
static size_t arpreply_offset;
static void arpreply_clear(void)
{
memset(&arpreply, 0, sizeof arpreply);

View File

@ -87,7 +87,7 @@ static void perform_ip4set(const char *buf, size_t len)
const char *eof = pe;
const char *arg_start;
size_t arg_len;
unsigned int cs = 0;
int cs = 0;
bool have_ip = false;
bool have_subnet = false;
bool have_bcast = false;
@ -199,7 +199,7 @@ buftooshort:
const char *pe = p + init_siz;
const char *arg_start;
size_t arg_len;
unsigned int cs = 0;
int cs = 0;
%% write init;
%% write exec;

View File

@ -290,19 +290,19 @@ static void setup_signals_ifch()
static void signal_dispatch()
{
int t, off = 0;
int t;
size_t off = 0;
struct signalfd_siginfo si;
again:
t = read(signalFd, (char *)&si + off, sizeof si - off);
if (t < sizeof si - off) {
if (t < 0) {
if (t == EAGAIN || t == EWOULDBLOCK || t == EINTR)
goto again;
else
suicide("signalfd read error");
}
off += t;
if (t < 0) {
if (t == EAGAIN || t == EWOULDBLOCK || t == EINTR)
goto again;
else
suicide("signalfd read error");
}
if (off + (unsigned)t < sizeof si)
off += t;
switch (si.ssi_signo) {
case SIGINT:
case SIGTERM:

View File

@ -125,19 +125,19 @@ static void show_usage(void)
static void signal_dispatch()
{
int t, off = 0;
int t;
size_t off = 0;
struct signalfd_siginfo si;
again:
t = read(cs.signalFd, (char *)&si + off, sizeof si - off);
if (t < sizeof si - off) {
if (t < 0) {
if (t == EAGAIN || t == EWOULDBLOCK || t == EINTR)
goto again;
else
suicide("signalfd read error");
}
off += t;
if (t < 0) {
if (t == EAGAIN || t == EWOULDBLOCK || t == EINTR)
goto again;
else
suicide("signalfd read error");
}
if (off + (unsigned)t < sizeof si)
off += t;
switch (si.ssi_signo) {
case SIGUSR1:
force_renew_action(&cs);

View File

@ -66,7 +66,7 @@ ssize_t nl_recv_buf(int fd, char *buf, size_t blen)
.msg_iov = &iov,
.msg_iovlen = 1,
};
size_t ret = recvmsg(fd, &msg, 0);
ssize_t ret = recvmsg(fd, &msg, 0);
if (ret == -1) {
if (errno != EAGAIN && errno != EWOULDBLOCK)
log_error("nl_fill_buf: recvmsg failed: %s", strerror(errno));
@ -83,7 +83,7 @@ ssize_t nl_recv_buf(int fd, char *buf, size_t blen)
return ret;
}
int nl_foreach_nlmsg(char *buf, size_t blen, int portid,
int nl_foreach_nlmsg(char *buf, size_t blen, uint32_t portid,
nlmsg_foreach_fn pfn, void *fnarg)
{
const struct nlmsghdr *nlh = (const struct nlmsghdr *)buf;

View File

@ -73,7 +73,7 @@ void nl_attr_parse(const struct nlmsghdr *nlh, size_t offset,
ssize_t nl_recv_buf(int fd, char *buf, size_t blen);
typedef int (*nlmsg_foreach_fn)(const struct nlmsghdr *, void *);
int nl_foreach_nlmsg(char *buf, size_t blen, int portid,
int nl_foreach_nlmsg(char *buf, size_t blen, uint32_t portid,
nlmsg_foreach_fn pfn, void *fnarg);
int nl_open(int nltype, int nlgroup, int *nlportid);

View File

@ -151,7 +151,7 @@ size_t add_option_string(struct dhcpmsg *packet, uint8_t code, const char *str,
}
ssize_t end = get_end_option_idx(packet);
if (end == -1) {
if (end < 0) {
log_warning("add_option_string: Buffer has no DCODE_END marker.");
return 0;
}
@ -170,11 +170,11 @@ static ssize_t add_option_check(struct dhcpmsg *packet, uint8_t code,
uint8_t rlen)
{
ssize_t end = get_end_option_idx(packet);
if (end == -1) {
if (end < 0) {
log_warning("add_u%01u_option: Buffer has no DCODE_END marker.", rlen*8);
return -1;
}
if (end + 2 + rlen >= sizeof packet->options) {
if ((size_t)end + 2 + rlen >= sizeof packet->options) {
log_warning("add_u%01u_option: No space for option 0x%02x.",
rlen*8, code);
return -1;

View File

@ -76,7 +76,7 @@ static const dhcp_state_t dhcp_states[] = {
static unsigned int num_dhcp_requests;
static long long dhcp_wake_ts = -1;
static int delay_timeout(int numpackets)
static int delay_timeout(size_t numpackets)
{
int to = 64;
char tot[] = { 4, 8, 16, 32, 64 };