Fix comparison type mismatch warnings

Signed-off-by: Gary Bisson <gary.bisson@boundarydevices.com>
pull/208/head
Gary Bisson 2020-05-28 15:05:08 +02:00 committed by Oliver Hartkopp
parent 2c87dcf468
commit 46895a41c5
11 changed files with 14 additions and 14 deletions

View File

@ -300,7 +300,7 @@ int main(int argc, char **argv)
ptr = argv[optind+i]; ptr = argv[optind+i];
nbytes = strlen(ptr); nbytes = strlen(ptr);
if (nbytes >= IFNAMSIZ+sizeof("@1000000")+1) { if (nbytes >= (int)(IFNAMSIZ+sizeof("@1000000")+1)) {
printf("name of CAN device '%s' is too long!\n", ptr); printf("name of CAN device '%s' is too long!\n", ptr);
return 1; return 1;
} }
@ -324,7 +324,7 @@ int main(int argc, char **argv)
nbytes = nptr - ptr; /* interface name is up the first '@' */ nbytes = nptr - ptr; /* interface name is up the first '@' */
if (nbytes >= IFNAMSIZ) { if (nbytes >= (int)IFNAMSIZ) {
printf("name of CAN device '%s' is too long!\n", ptr); printf("name of CAN device '%s' is too long!\n", ptr);
return 1; return 1;
} }
@ -396,7 +396,7 @@ int main(int argc, char **argv)
return 1; return 1;
} }
if (nbytes < sizeof(struct can_frame)) { if (nbytes < (int)sizeof(struct can_frame)) {
fprintf(stderr, "read: incomplete CAN frame\n"); fprintf(stderr, "read: incomplete CAN frame\n");
return 1; return 1;
} }

View File

@ -201,7 +201,7 @@ int idx2dindex(int ifidx, int socket) {
if (ioctl(socket, SIOCGIFNAME, &ifr) < 0) if (ioctl(socket, SIOCGIFNAME, &ifr) < 0)
perror("SIOCGIFNAME"); perror("SIOCGIFNAME");
if (max_devname_len < strlen(ifr.ifr_name)) if (max_devname_len < (int)strlen(ifr.ifr_name))
max_devname_len = strlen(ifr.ifr_name); max_devname_len = strlen(ifr.ifr_name);
strcpy(devname[i], ifr.ifr_name); strcpy(devname[i], ifr.ifr_name);

View File

@ -88,7 +88,7 @@ int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data,
int len = RTA_LENGTH(alen); int len = RTA_LENGTH(alen);
struct rtattr *rta; struct rtattr *rta;
if (NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len) > maxlen) { if ((int)(NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len)) > maxlen) {
fprintf(stderr, "addattr_l: message exceeded bound of %d\n", fprintf(stderr, "addattr_l: message exceeded bound of %d\n",
maxlen); maxlen);
return -1; return -1;

View File

@ -140,7 +140,7 @@ int idx2dindex(int ifidx, int socket)
if (ioctl(socket, SIOCGIFNAME, &ifr) < 0) if (ioctl(socket, SIOCGIFNAME, &ifr) < 0)
perror("SIOCGIFNAME"); perror("SIOCGIFNAME");
if (max_devname_len < strlen(ifr.ifr_name)) if (max_devname_len < (int)strlen(ifr.ifr_name))
max_devname_len = strlen(ifr.ifr_name); max_devname_len = strlen(ifr.ifr_name);
strcpy(devname[i], ifr.ifr_name); strcpy(devname[i], ifr.ifr_name);

View File

@ -359,7 +359,7 @@ int main(int argc, char **argv)
return 1; return 1;
} }
strcpy(buf, argv[optind+i]); strcpy(buf, argv[optind+i]);
for (j=0; j<BUFSZ; j++) { /* find '=' in assignment */ for (j=0; j<(int)BUFSZ; j++) { /* find '=' in assignment */
if (buf[j] == '=') if (buf[j] == '=')
break; break;
} }
@ -495,7 +495,7 @@ int main(int argc, char **argv)
/* test for logfile timestamps jumping backwards OR */ /* test for logfile timestamps jumping backwards OR */
/* if the user likes to skip long gaps in the timestamps */ /* if the user likes to skip long gaps in the timestamps */
if ((last_log_tv.tv_sec > log_tv.tv_sec) || if ((last_log_tv.tv_sec > log_tv.tv_sec) ||
(skipgap && labs(last_log_tv.tv_sec - log_tv.tv_sec) > skipgap)) (skipgap && labs(last_log_tv.tv_sec - log_tv.tv_sec) > (long)skipgap))
create_diff_tv(&today_tv, &diff_tv, &log_tv); create_diff_tv(&today_tv, &diff_tv, &log_tv);
last_log_tv = log_tv; last_log_tv = log_tv;

View File

@ -121,7 +121,7 @@ int main(int argc, char **argv)
addr.can_family = AF_CAN; addr.can_family = AF_CAN;
addr.can_ifindex = ifr.ifr_ifindex; addr.can_ifindex = ifr.ifr_ifindex;
if (required_mtu > CAN_MTU) { if (required_mtu > (int)CAN_MTU) {
/* check if the frame fits into the CAN netdevice */ /* check if the frame fits into the CAN netdevice */
if (ioctl(s, SIOCGIFMTU, &ifr) < 0) { if (ioctl(s, SIOCGIFMTU, &ifr) < 0) {

View File

@ -405,7 +405,7 @@ int handle_keyb(void)
unsigned int mask; unsigned int mask;
unsigned int value; unsigned int value;
if (read(0, cmd, 24) > strlen("+1234567812345678\n")) if (read(0, cmd, 24) > (long)strlen("+1234567812345678\n"))
return 1; /* ignore */ return 1; /* ignore */
if (strlen(cmd) > 0) if (strlen(cmd) > 0)

View File

@ -96,7 +96,7 @@ struct nlmsghdr {
(struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len))) (struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len)))
#define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \ #define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \
(nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \ (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \
(nlh)->nlmsg_len <= (len)) (int)((nlh)->nlmsg_len) <= (len))
#define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len))) #define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len)))
#define NLMSG_NOOP 0x1 /* Nothing. */ #define NLMSG_NOOP 0x1 /* Nothing. */

View File

@ -365,7 +365,7 @@ int main(int argc, char **argv)
percent = 100; percent = 100;
for (i=0; i < NUMBAR; i++){ for (i=0; i < NUMBAR; i++){
if (i < percent/PERCENTRES) if (i < (int)(percent/PERCENTRES))
printf("X"); printf("X");
else else
printf("."); printf(".");

2
lib.c
View File

@ -583,7 +583,7 @@ void snprintf_can_error_frame(char *buf, size_t len, const struct canfd_frame *c
if (!sep) if (!sep)
sep = defsep; sep = defsep;
for (i = 0; i < ARRAY_SIZE(error_classes); i++) { for (i = 0; i < (int)ARRAY_SIZE(error_classes); i++) {
mask = 1 << i; mask = 1 << i;
if (class & mask) { if (class & mask) {
if (classes) if (classes)

View File

@ -138,7 +138,7 @@ void canfd_asc(struct canfd_frame *cf, int devno, int mtu, FILE *outfile)
fprintf(outfile, "%2d", dlen); fprintf(outfile, "%2d", dlen);
for (i = 0; i < dlen; i++) { for (i = 0; i < (int)dlen; i++) {
fprintf(outfile, " %02X", cf->data[i]); fprintf(outfile, " %02X", cf->data[i]);
} }