Cleanup GCC4 warnings about signedness.

This commit is contained in:
shemminger 2005-07-05 22:37:15 +00:00
parent 52d5ac3fcb
commit f332d16924
16 changed files with 39 additions and 33 deletions

View File

@ -21,7 +21,7 @@ int inet_proto_a2n(char *buf);
const char * ll_type_n2a(int type, char *buf, int len);
const char *ll_addr_n2a(unsigned char *addr, int alen, int type, char *buf, int blen);
int ll_addr_a2n(unsigned char *lladdr, int len, char *arg);
int ll_addr_a2n(char *lladdr, int len, char *arg);
const char * ll_proto_n2a(unsigned short id, char *buf, int len);
int ll_proto_a2n(unsigned short *id, char *buf);

View File

@ -86,8 +86,8 @@ extern int get_s16(__s16 *val, const char *arg, int base);
extern int get_u8(__u8 *val, const char *arg, int base);
extern int get_s8(__s8 *val, const char *arg, int base);
extern __u8* hexstring_n2a(const __u8 *str, int len, __u8 *buf, int blen);
extern __u8* hexstring_a2n(const __u8 *str, __u8 *buf, int blen);
extern char* hexstring_n2a(const __u8 *str, int len, char *buf, int blen);
extern __u8* hexstring_a2n(const char *str, __u8 *buf, int blen);
extern const char *format_host(int af, int len, const void *addr,
char *buf, int buflen);

View File

@ -524,7 +524,7 @@ int ipaddr_list_or_flush(int argc, char **argv, int flush)
if (filter.family == AF_UNSPEC)
filter.family = filter.pfx.family;
} else if (strcmp(*argv, "scope") == 0) {
int scope = 0;
unsigned scope = 0;
NEXT_ARG();
filter.scopemask = -1;
if (rtnl_rtscope_a2n(&scope, *argv)) {
@ -801,7 +801,7 @@ int ipaddr_modify(int cmd, int argc, char **argv)
addattr_l(&req.n, sizeof(req), IFA_ANYCAST, &addr.data, addr.bytelen);
any_len = addr.bytelen;
} else if (strcmp(*argv, "scope") == 0) {
int scope = 0;
unsigned scope = 0;
NEXT_ARG();
if (rtnl_rtscope_a2n(&scope, *argv))
invarg(*argv, "invalid scope value.");

View File

@ -178,7 +178,7 @@ static int get_address(const char *dev, int *htype)
{
struct ifreq ifr;
struct sockaddr_ll me;
int alen;
socklen_t alen;
int s;
s = socket(PF_PACKET, SOCK_DGRAM, 0);

View File

@ -298,7 +298,8 @@ int multiaddr_modify(int cmd, int argc, char **argv)
usage();
if (ifr.ifr_hwaddr.sa_data[0])
duparg("address", *argv);
if (ll_addr_a2n(ifr.ifr_hwaddr.sa_data, 14, *argv) < 0) {
if (ll_addr_a2n(ifr.ifr_hwaddr.sa_data,
14, *argv) < 0) {
fprintf(stderr, "Error: \"%s\" is not a legal ll address.\n", *argv);
exit(1);
}

View File

@ -726,7 +726,7 @@ int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
invarg("\"metric\" value is invalid\n", *argv);
addattr32(&req.n, sizeof(req), RTA_PRIORITY, metric);
} else if (strcmp(*argv, "scope") == 0) {
int scope = 0;
__u32 scope = 0;
NEXT_ARG();
if (rtnl_rtscope_a2n(&scope, *argv))
invarg("invalid \"scope\" value\n", *argv);
@ -831,14 +831,14 @@ int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
nhs_ok = 1;
break;
} else if (matches(*argv, "protocol") == 0) {
int prot;
__u32 prot;
NEXT_ARG();
if (rtnl_rtprot_a2n(&prot, *argv))
invarg("\"protocol\" value is invalid\n", *argv);
req.r.rtm_protocol = prot;
proto_ok =1;
} else if (matches(*argv, "table") == 0) {
int tid;
__u32 tid;
NEXT_ARG();
if (rtnl_rttable_a2n(&tid, *argv))
invarg("\"table\" value is invalid\n", *argv);
@ -1012,7 +1012,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush)
while (argc > 0) {
if (matches(*argv, "table") == 0) {
int tid;
__u32 tid;
NEXT_ARG();
if (rtnl_rttable_a2n(&tid, *argv)) {
if (strcmp(*argv, "all") == 0) {
@ -1038,7 +1038,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush)
filter.tos = tos;
filter.tosmask = -1;
} else if (matches(*argv, "protocol") == 0) {
int prot = 0;
__u32 prot = 0;
NEXT_ARG();
filter.protocolmask = -1;
if (rtnl_rtprot_a2n(&prot, *argv)) {
@ -1049,7 +1049,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush)
}
filter.protocol = prot;
} else if (matches(*argv, "scope") == 0) {
int scope = 0;
__u32 scope = 0;
NEXT_ARG();
filter.scopemask = -1;
if (rtnl_rtscope_a2n(&scope, *argv)) {

View File

@ -256,7 +256,7 @@ static int iprule_modify(int cmd, int argc, char **argv)
addattr32(&req.n, sizeof(req), RTA_FLOW, realm);
} else if (matches(*argv, "table") == 0 ||
strcmp(*argv, "lookup") == 0) {
int tid;
__u32 tid;
NEXT_ARG();
if (rtnl_rttable_a2n(&tid, *argv))
invarg("invalid table ID\n", *argv);

View File

@ -32,7 +32,7 @@ void rtnl_close(struct rtnl_handle *rth)
int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions, int protocol)
{
int addr_len;
socklen_t addr_len;
int sndbuf = 32768;
int rcvbuf = 32768;

View File

@ -53,7 +53,8 @@ const char *ll_addr_n2a(unsigned char *addr, int alen, int type, char *buf, int
return buf;
}
int ll_addr_a2n(unsigned char *lladdr, int len, char *arg)
/*NB: lladdr is char * (rather than u8 *) because sa_data is char * (1003.1g) */
int ll_addr_a2n(char *lladdr, int len, char *arg)
{
if (strchr(arg, '.')) {
inet_prefix pfx;

View File

@ -240,7 +240,7 @@ int get_prefix_1(inet_prefix *dst, char *arg, int family)
dst->bitlen = 32;
}
if (slash) {
if (get_integer(&plen, slash+1, 0) || plen > dst->bitlen) {
if (get_unsigned(&plen, slash+1, 0) || plen > dst->bitlen) {
err = -1;
goto done;
}
@ -504,9 +504,9 @@ const char *format_host(int af, int len, const void *addr,
}
__u8* hexstring_n2a(const __u8 *str, int len, __u8 *buf, int blen)
char *hexstring_n2a(const __u8 *str, int len, char *buf, int blen)
{
__u8 *ptr = buf;
char *ptr = buf;
int i;
for (i=0; i<len; i++) {
@ -523,7 +523,7 @@ __u8* hexstring_n2a(const __u8 *str, int len, __u8 *buf, int blen)
return buf;
}
__u8* hexstring_a2n(const __u8 *str, __u8 *buf, int blen)
__u8* hexstring_a2n(const char *str, __u8 *buf, int blen)
{
int cnt = 0;

View File

@ -180,7 +180,7 @@ int send_probe(int ifindex, __u32 addr)
{
struct ifreq ifr;
struct sockaddr_in dst;
int len;
socklen_t len;
unsigned char buf[256];
struct arphdr *ah = (struct arphdr*)buf;
unsigned char *p = (unsigned char *)(ah+1);
@ -228,8 +228,7 @@ int send_probe(int ifindex, __u32 addr)
memcpy(p, &addr, 4);
p+=4;
len = sendto(pset[0].fd, buf, p-buf, 0, (struct sockaddr*)&sll, sizeof(sll));
if (len < 0)
if (sendto(pset[0].fd, buf, p-buf, 0, (struct sockaddr*)&sll, sizeof(sll)) < 0)
return -1;
stats.probes_sent++;
return 0;
@ -480,13 +479,14 @@ void get_arp_pkt(void)
{
unsigned char buf[1024];
struct sockaddr_ll sll;
int sll_len = sizeof(sll);
socklen_t sll_len = sizeof(sll);
struct arphdr *a = (struct arphdr*)buf;
struct dbkey key;
DBT dbkey, dbdat;
int n;
n = recvfrom(pset[0].fd, buf, sizeof(buf), MSG_DONTWAIT, (struct sockaddr*)&sll, &sll_len);
n = recvfrom(pset[0].fd, buf, sizeof(buf), MSG_DONTWAIT,
(struct sockaddr*)&sll, &sll_len);
if (n < 0) {
if (errno != EINTR && errno != EAGAIN)
syslog(LOG_ERR, "recvfrom: %m");
@ -708,6 +708,7 @@ int main(int argc, char **argv)
fprintf(stderr, "Invalid IP address: \"%s\"\n", ipbuf);
goto do_abort;
}
dbdat.data = hexstring_a2n(macbuf, b1, 6);
if (dbdat.data == NULL)
goto do_abort;
@ -730,7 +731,7 @@ int main(int argc, char **argv)
struct dbkey *key = dbkey.data;
if (handle_if(key->iface)) {
if (!IS_NEG(dbdat.data)) {
__u8 b1[18];
char b1[18];
printf("%-8d %-15s %s\n",
key->iface,
inet_ntoa(*(struct in_addr*)&key->addr),

View File

@ -120,6 +120,7 @@ static int lookup_map_id(char *kind, int *dst, const char *file)
}
err = -ENOENT;
*dst = 0;
out:
fclose(fd);
return err;

View File

@ -10,7 +10,7 @@
struct bstr
{
unsigned char *data;
char *data;
unsigned int len;
int quoted;
struct bstr *next;
@ -53,7 +53,7 @@ static inline int bstrcmp(struct bstr *b, const char *text)
int d = b->len - len;
if (d == 0)
return strncmp((char *) b->data, text, len);
return strncmp(b->data, text, len);
return d;
}
@ -77,7 +77,7 @@ static inline unsigned long bstrtoul(struct bstr *b)
static inline void bstr_print(FILE *fd, struct bstr *b, int ascii)
{
int i;
char *s = (char *) b->data;
char *s = b->data;
if (ascii)
for (i = 0; i < b->len; i++)

View File

@ -238,9 +238,11 @@ parse_val(int *argc_p, char ***argv_p, __u32 * val, int type)
return -1;
if (TINT == type)
return get_integer(val, *argv, 0);
return get_integer((int *) val, *argv, 0);
if (TU32 == type)
return get_u32(val, *argv, 0);
if (TIPV4 == type) {
inet_prefix addr;
if (get_prefix_1(&addr, *argv, AF_INET)) {

View File

@ -70,7 +70,7 @@ static int cbq_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
}
} else if (strcmp(*argv, "ewma") == 0) {
NEXT_ARG();
if (get_unsigned(&ewma_log, *argv, 0)) {
if (get_integer(&ewma_log, *argv, 0)) {
explain1("ewma");
return -1;
}
@ -236,7 +236,7 @@ static int cbq_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, str
lss.change |= TCF_CBQ_LSS_FLAGS;
} else if (strcmp(*argv, "ewma") == 0) {
NEXT_ARG();
if (get_u32(&ewma_log, *argv, 0)) {
if (get_integer(&ewma_log, *argv, 0)) {
explain1("ewma");
return -1;
}

View File

@ -244,7 +244,7 @@ static size_t getcmdline(char **linep, size_t *lenp, FILE *in)
while ((cp = strstr(*linep, "\\\n")) != NULL) {
char *line1 = NULL;
ssize_t len1 = 0;
size_t len1 = 0;
size_t cc1;
if ((cc1 = getline(&line1, &len1, in)) < 0) {