Skip to content

Commit

Permalink
testj1939: fix warning on 32 bit systems
Browse files Browse the repository at this point in the history
testj1939.c: In function 'main':
testj1939.c:201:3: warning: format '%li' expects argument of type 'long int', but argument 4 has type 'unsigned int' [-Wformat=]
   fprintf(stderr, "- bind(, %s, %li);\n", canaddr2str(&sockname), sizeof(sockname));
   ^
testj1939.c:210:4: warning: format '%li' expects argument of type 'long int', but argument 4 has type 'unsigned int' [-Wformat=]
    fprintf(stderr, "- connect(, %s, %li);\n", canaddr2str(&peername), sizeof(peername));
    ^
testj1939.c:228:5: warning: format '%li' expects argument of type 'long int', but argument 5 has type 'unsigned int' [-Wformat=]
     fprintf(stderr, "- sendto(, <dat>, %i, 0, %s, %li);\n", todo_send, canaddr2str(&peername), sizeof(peername));
     ^
testj1939.c:254:4: warning: format '%li' expects argument of type 'long int', but argument 3 has type 'unsigned int' [-Wformat=]
    fprintf(stderr, "- recvfrom(, <dat>, %li, 0, &<peername>, %li);\n", sizeof(peername), sizeof(peername));
    ^
testj1939.c:254:4: warning: format '%li' expects argument of type 'long int', but argument 4 has type 'unsigned int' [-Wformat=]

Use 'z' as correct modifier to print sizeof().

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
marckleinebudde committed Oct 4, 2016
1 parent 0e36114 commit 07daafc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions testj1939.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ int main(int argc, char *argv[])
}

if (verbose)
fprintf(stderr, "- bind(, %s, %li);\n", canaddr2str(&sockname), sizeof(sockname));
fprintf(stderr, "- bind(, %s, %zi);\n", canaddr2str(&sockname), sizeof(sockname));
ret = bind(sock, (void *)&sockname, sizeof(sockname));
if (ret < 0)
error(1, errno, "bind()");
Expand All @@ -207,7 +207,7 @@ int main(int argc, char *argv[])
if (!valid_peername)
error(1, 0, "no peername supplied");
if (verbose)
fprintf(stderr, "- connect(, %s, %li);\n", canaddr2str(&peername), sizeof(peername));
fprintf(stderr, "- connect(, %s, %zi);\n", canaddr2str(&peername), sizeof(peername));
ret = connect(sock, (void *)&peername, sizeof(peername));
if (ret < 0)
error(1, errno, "connect()");
Expand All @@ -225,7 +225,7 @@ int main(int argc, char *argv[])
*/
if (valid_peername && !todo_connect) {
if (verbose)
fprintf(stderr, "- sendto(, <dat>, %i, 0, %s, %li);\n", todo_send, canaddr2str(&peername), sizeof(peername));
fprintf(stderr, "- sendto(, <dat>, %i, 0, %s, %zi);\n", todo_send, canaddr2str(&peername), sizeof(peername));
ret = sendto(sock, dat, todo_send, 0,
(void *)&peername, sizeof(peername));
} else {
Expand All @@ -251,7 +251,7 @@ int main(int argc, char *argv[])
* received packets
*/
if (verbose)
fprintf(stderr, "- recvfrom(, <dat>, %li, 0, &<peername>, %li);\n", sizeof(peername), sizeof(peername));
fprintf(stderr, "- recvfrom(, <dat>, %zi, 0, &<peername>, %zi);\n", sizeof(peername), sizeof(peername));
peernamelen = sizeof(peername);
ret = recvfrom(sock, dat, sizeof(dat), 0,
(void *)&peername, &peernamelen);
Expand Down

0 comments on commit 07daafc

Please sign in to comment.