Fix the remaining signed/unsigned comparison warnings. Nothing stands out
as being dangerous or buggy.
This commit is contained in:
parent
e50bd431d6
commit
e7838d542b
@ -112,7 +112,7 @@ static char arp_router_has_replied;
|
|||||||
static char arp_server_has_replied;
|
static char arp_server_has_replied;
|
||||||
|
|
||||||
static struct arpMsg arpreply;
|
static struct arpMsg arpreply;
|
||||||
static int arpreply_offset;
|
static size_t arpreply_offset;
|
||||||
static void arpreply_clear(void)
|
static void arpreply_clear(void)
|
||||||
{
|
{
|
||||||
memset(&arpreply, 0, sizeof arpreply);
|
memset(&arpreply, 0, sizeof arpreply);
|
||||||
|
@ -87,7 +87,7 @@ static void perform_ip4set(const char *buf, size_t len)
|
|||||||
const char *eof = pe;
|
const char *eof = pe;
|
||||||
const char *arg_start;
|
const char *arg_start;
|
||||||
size_t arg_len;
|
size_t arg_len;
|
||||||
unsigned int cs = 0;
|
int cs = 0;
|
||||||
bool have_ip = false;
|
bool have_ip = false;
|
||||||
bool have_subnet = false;
|
bool have_subnet = false;
|
||||||
bool have_bcast = false;
|
bool have_bcast = false;
|
||||||
@ -199,7 +199,7 @@ buftooshort:
|
|||||||
const char *pe = p + init_siz;
|
const char *pe = p + init_siz;
|
||||||
const char *arg_start;
|
const char *arg_start;
|
||||||
size_t arg_len;
|
size_t arg_len;
|
||||||
unsigned int cs = 0;
|
int cs = 0;
|
||||||
|
|
||||||
%% write init;
|
%% write init;
|
||||||
%% write exec;
|
%% write exec;
|
||||||
|
18
ndhc/ifchd.c
18
ndhc/ifchd.c
@ -290,19 +290,19 @@ static void setup_signals_ifch()
|
|||||||
|
|
||||||
static void signal_dispatch()
|
static void signal_dispatch()
|
||||||
{
|
{
|
||||||
int t, off = 0;
|
int t;
|
||||||
|
size_t off = 0;
|
||||||
struct signalfd_siginfo si;
|
struct signalfd_siginfo si;
|
||||||
again:
|
again:
|
||||||
t = read(signalFd, (char *)&si + off, sizeof si - off);
|
t = read(signalFd, (char *)&si + off, sizeof si - off);
|
||||||
if (t < sizeof si - off) {
|
if (t < 0) {
|
||||||
if (t < 0) {
|
if (t == EAGAIN || t == EWOULDBLOCK || t == EINTR)
|
||||||
if (t == EAGAIN || t == EWOULDBLOCK || t == EINTR)
|
goto again;
|
||||||
goto again;
|
else
|
||||||
else
|
suicide("signalfd read error");
|
||||||
suicide("signalfd read error");
|
|
||||||
}
|
|
||||||
off += t;
|
|
||||||
}
|
}
|
||||||
|
if (off + (unsigned)t < sizeof si)
|
||||||
|
off += t;
|
||||||
switch (si.ssi_signo) {
|
switch (si.ssi_signo) {
|
||||||
case SIGINT:
|
case SIGINT:
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
|
18
ndhc/ndhc.c
18
ndhc/ndhc.c
@ -125,19 +125,19 @@ static void show_usage(void)
|
|||||||
|
|
||||||
static void signal_dispatch()
|
static void signal_dispatch()
|
||||||
{
|
{
|
||||||
int t, off = 0;
|
int t;
|
||||||
|
size_t off = 0;
|
||||||
struct signalfd_siginfo si;
|
struct signalfd_siginfo si;
|
||||||
again:
|
again:
|
||||||
t = read(cs.signalFd, (char *)&si + off, sizeof si - off);
|
t = read(cs.signalFd, (char *)&si + off, sizeof si - off);
|
||||||
if (t < sizeof si - off) {
|
if (t < 0) {
|
||||||
if (t < 0) {
|
if (t == EAGAIN || t == EWOULDBLOCK || t == EINTR)
|
||||||
if (t == EAGAIN || t == EWOULDBLOCK || t == EINTR)
|
goto again;
|
||||||
goto again;
|
else
|
||||||
else
|
suicide("signalfd read error");
|
||||||
suicide("signalfd read error");
|
|
||||||
}
|
|
||||||
off += t;
|
|
||||||
}
|
}
|
||||||
|
if (off + (unsigned)t < sizeof si)
|
||||||
|
off += t;
|
||||||
switch (si.ssi_signo) {
|
switch (si.ssi_signo) {
|
||||||
case SIGUSR1:
|
case SIGUSR1:
|
||||||
force_renew_action(&cs);
|
force_renew_action(&cs);
|
||||||
|
@ -66,7 +66,7 @@ ssize_t nl_recv_buf(int fd, char *buf, size_t blen)
|
|||||||
.msg_iov = &iov,
|
.msg_iov = &iov,
|
||||||
.msg_iovlen = 1,
|
.msg_iovlen = 1,
|
||||||
};
|
};
|
||||||
size_t ret = recvmsg(fd, &msg, 0);
|
ssize_t ret = recvmsg(fd, &msg, 0);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
if (errno != EAGAIN && errno != EWOULDBLOCK)
|
if (errno != EAGAIN && errno != EWOULDBLOCK)
|
||||||
log_error("nl_fill_buf: recvmsg failed: %s", strerror(errno));
|
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;
|
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)
|
nlmsg_foreach_fn pfn, void *fnarg)
|
||||||
{
|
{
|
||||||
const struct nlmsghdr *nlh = (const struct nlmsghdr *)buf;
|
const struct nlmsghdr *nlh = (const struct nlmsghdr *)buf;
|
||||||
|
@ -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);
|
ssize_t nl_recv_buf(int fd, char *buf, size_t blen);
|
||||||
|
|
||||||
typedef int (*nlmsg_foreach_fn)(const struct nlmsghdr *, void *);
|
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);
|
nlmsg_foreach_fn pfn, void *fnarg);
|
||||||
|
|
||||||
int nl_open(int nltype, int nlgroup, int *nlportid);
|
int nl_open(int nltype, int nlgroup, int *nlportid);
|
||||||
|
@ -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);
|
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.");
|
log_warning("add_option_string: Buffer has no DCODE_END marker.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -170,11 +170,11 @@ static ssize_t add_option_check(struct dhcpmsg *packet, uint8_t code,
|
|||||||
uint8_t rlen)
|
uint8_t rlen)
|
||||||
{
|
{
|
||||||
ssize_t end = get_end_option_idx(packet);
|
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);
|
log_warning("add_u%01u_option: Buffer has no DCODE_END marker.", rlen*8);
|
||||||
return -1;
|
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.",
|
log_warning("add_u%01u_option: No space for option 0x%02x.",
|
||||||
rlen*8, code);
|
rlen*8, code);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -76,7 +76,7 @@ static const dhcp_state_t dhcp_states[] = {
|
|||||||
static unsigned int num_dhcp_requests;
|
static unsigned int num_dhcp_requests;
|
||||||
static long long dhcp_wake_ts = -1;
|
static long long dhcp_wake_ts = -1;
|
||||||
|
|
||||||
static int delay_timeout(int numpackets)
|
static int delay_timeout(size_t numpackets)
|
||||||
{
|
{
|
||||||
int to = 64;
|
int to = 64;
|
||||||
char tot[] = { 4, 8, 16, 32, 64 };
|
char tot[] = { 4, 8, 16, 32, 64 };
|
||||||
|
Loading…
Reference in New Issue
Block a user