j1939: Fix comparison type mismatch warnings

Fix missing (recently introduced) j1939 files that have not been fixed
in commit 46895a41c5 ("Fix comparison type mismatch warnings") from
Gary Bisson.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
pull/221/head
Oliver Hartkopp 2020-06-12 19:57:58 +02:00
parent 85ae5aaecf
commit 75d9c7e95f
4 changed files with 17 additions and 13 deletions

View File

@ -121,7 +121,7 @@ static ssize_t j1939cat_send_one(struct j1939cat_priv *priv, int out_fd,
return -EINVAL; return -EINVAL;
} }
if (num_sent > buf_size) /* Should never happen */ { if (num_sent > (ssize_t)buf_size) /* Should never happen */ {
warn("%s: send more then read", __func__); warn("%s: send more then read", __func__);
return -EINVAL; return -EINVAL;
} }
@ -372,7 +372,8 @@ static int j1939cat_sendfile(struct j1939cat_priv *priv, int out_fd, int in_fd,
int ret = EXIT_SUCCESS; int ret = EXIT_SUCCESS;
off_t orig = 0; off_t orig = 0;
char *buf; char *buf;
size_t to_read, num_read, buf_size; ssize_t num_read;
size_t to_read, buf_size;
buf_size = min(priv->max_transfer, count); buf_size = min(priv->max_transfer, count);
buf = malloc(buf_size); buf = malloc(buf_size);
@ -454,7 +455,8 @@ static size_t j1939cat_get_file_size(int fd)
static int j1939cat_send(struct j1939cat_priv *priv) static int j1939cat_send(struct j1939cat_priv *priv)
{ {
unsigned int size = 0; unsigned int size = 0;
int ret, i; unsigned int i;
int ret;
if (priv->todo_filesize) if (priv->todo_filesize)
size = j1939cat_get_file_size(priv->infile); size = j1939cat_get_file_size(priv->infile);

View File

@ -95,8 +95,8 @@ static uint8_t *buf;
*/ */
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int ret, sock, j, opt; int ret, sock, opt;
unsigned int len; unsigned int j, len;
struct timeval tref, tdut, ttmp; struct timeval tref, tdut, ttmp;
struct sockaddr_can src; struct sockaddr_can src;
struct j1939_filter filt; struct j1939_filter filt;
@ -287,7 +287,7 @@ int main(int argc, char **argv)
printf("[%i%s]", len, (msg.msg_flags & MSG_TRUNC) ? "..." : ""); printf("[%i%s]", len, (msg.msg_flags & MSG_TRUNC) ? "..." : "");
for (j = 0; j < len; ) { for (j = 0; j < len; ) {
int end = j + 4; unsigned int end = j + 4;
if (end > len) if (end > len)
end = len; end = len;
printf(" "); printf(" ");

View File

@ -53,7 +53,7 @@ static const char *libj1939_ifnam(int ifindex)
fetch_names(); fetch_names();
for (lp = saved; lp->if_index; ++lp) { for (lp = saved; lp->if_index; ++lp) {
if (lp->if_index == ifindex) if (lp->if_index == (unsigned int)ifindex)
return lp->if_name; return lp->if_name;
} }
if (cached) { if (cached) {

View File

@ -72,7 +72,8 @@ static void schedule_oneshot_itimer(double delay)
/* main */ /* main */
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int ret, sock, opt, j; int ret, sock, opt;
unsigned int j;
int verbose = 0; int verbose = 0;
socklen_t peernamelen; socklen_t peernamelen;
struct sockaddr_can sockname = { struct sockaddr_can sockname = {
@ -92,7 +93,8 @@ int main(int argc, char *argv[])
}; };
uint8_t dat[128]; uint8_t dat[128];
int valid_peername = 0; int valid_peername = 0;
int todo_send = 0, todo_recv = 0, todo_echo = 0, todo_prio = -1; unsigned int todo_send = 0;
int todo_recv = 0, todo_echo = 0, todo_prio = -1;
int todo_connect = 0, todo_names = 0, todo_wait = 0, todo_rebind = 0; int todo_connect = 0, todo_names = 0, todo_wait = 0, todo_rebind = 0;
int todo_broadcast = 0, todo_promisc = 0; int todo_broadcast = 0, todo_promisc = 0;
int no_bind = 0; int no_bind = 0;
@ -289,16 +291,16 @@ int main(int argc, char *argv[])
err(1, "sendto"); err(1, "sendto");
} }
if (todo_recv) { if (todo_recv) {
int i = 0; int i;
if (todo_names && peername.can_addr.j1939.name) if (todo_names && peername.can_addr.j1939.name)
printf("%016llx ", peername.can_addr.j1939.name); printf("%016llx ", peername.can_addr.j1939.name);
printf("%02x %05x:", peername.can_addr.j1939.addr, printf("%02x %05x:", peername.can_addr.j1939.addr,
peername.can_addr.j1939.pgn); peername.can_addr.j1939.pgn);
for (j = 0; j < ret; ++j, i++) { for (i = 0, j = 0; i < ret; ++i, j++) {
if (i == 8) { if (j == 8) {
printf("\n%05x ", j); printf("\n%05x ", j);
i = 0; j = 0;
} }
printf(" %02x", dat[j]); printf(" %02x", dat[j]);
} }