summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-11-09 16:32:43 +0000
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-11-09 16:46:03 +0000
commitfdb46676094c50f1d2dcebfcb5e051c2baf984ac (patch)
treea8b1e18e185c02b46aee62db09e6d3d84982581e
parentee6652b4bcc1bffc0b7c181666c4c1b30f5abad2 (diff)
test: Fix compiler warnings on 64bit systems
Use %td to print ptrdiff_t use %zu to print size_t, include time.h on FreeBSD. Some more compiler warnings are left but they require more thinking.
-rw-r--r--tests/gb/gprs_bssgp_test.c4
-rw-r--r--tests/gb/gprs_ns_test.c14
-rw-r--r--tests/gsm0808/gsm0808_test.c2
-rw-r--r--tests/msgb/msgb_test.c12
-rw-r--r--tests/sms/sms_test.c2
-rw-r--r--tests/smscb/gsm0341_test.c1
6 files changed, 18 insertions, 17 deletions
diff --git a/tests/gb/gprs_bssgp_test.c b/tests/gb/gprs_bssgp_test.c
index 14ba4d1d..707b64bf 100644
--- a/tests/gb/gprs_bssgp_test.c
+++ b/tests/gb/gprs_bssgp_test.c
@@ -45,7 +45,7 @@ ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
if (!real_sendto)
real_sendto = dlsym(RTLD_NEXT, "sendto");
- fprintf(stderr, "MESSAGE to 0x%08x, msg length %d\n%s\n",
+ fprintf(stderr, "MESSAGE to 0x%08x, msg length %zu\n%s\n",
dest_host, len, osmo_hexdump(buf, len));
return len;
@@ -55,7 +55,7 @@ ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
int gprs_ns_callback(enum gprs_ns_evt event, struct gprs_nsvc *nsvc,
struct msgb *msg, uint16_t bvci)
{
- fprintf(stderr, "CALLBACK, event %d, msg length %d, bvci 0x%04x\n%s\n\n",
+ fprintf(stderr, "CALLBACK, event %d, msg length %td, bvci 0x%04x\n%s\n\n",
event, msgb_bssgp_len(msg), bvci,
osmo_hexdump(msgb_bssgph(msg), msgb_bssgp_len(msg)));
return 0;
diff --git a/tests/gb/gprs_ns_test.c b/tests/gb/gprs_ns_test.c
index a742130f..4c6fd391 100644
--- a/tests/gb/gprs_ns_test.c
+++ b/tests/gb/gprs_ns_test.c
@@ -249,7 +249,7 @@ int gprs_ns_rcvmsg(struct gprs_ns_inst *nsi, struct msgb *msg,
int gprs_ns_callback(enum gprs_ns_evt event, struct gprs_nsvc *nsvc,
struct msgb *msg, uint16_t bvci)
{
- printf("CALLBACK, event %d, msg length %d, bvci 0x%04x\n%s\n\n",
+ printf("CALLBACK, event %d, msg length %td, bvci 0x%04x\n%s\n\n",
event, msgb_bssgp_len(msg), bvci,
osmo_hexdump(msgb_bssgph(msg), msgb_bssgp_len(msg)));
return 0;
@@ -270,9 +270,9 @@ ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
sent_pdu_type = len > 0 ? ((uint8_t *)buf)[0] : -1;
if (dest_host == REMOTE_BSS_ADDR)
- printf("MESSAGE to BSS, msg length %d\n%s\n\n", len, osmo_hexdump(buf, len));
+ printf("MESSAGE to BSS, msg length %zu\n%s\n\n", len, osmo_hexdump(buf, len));
else if (dest_host == REMOTE_SGSN_ADDR)
- printf("MESSAGE to SGSN, msg length %d\n%s\n\n", len, osmo_hexdump(buf, len));
+ printf("MESSAGE to SGSN, msg length %zu\n%s\n\n", len, osmo_hexdump(buf, len));
else
return real_sendto(sockfd, buf, len, flags, dest_addr, addrlen);
@@ -294,10 +294,10 @@ int gprs_ns_sendmsg(struct gprs_ns_inst *nsi, struct msgb *msg)
real_gprs_ns_sendmsg = dlsym(RTLD_NEXT, "gprs_ns_sendmsg");
if (nsei == SGSN_NSEI)
- printf("NS UNITDATA MESSAGE to SGSN, BVCI 0x%04x, msg length %d\n%s\n\n",
+ printf("NS UNITDATA MESSAGE to SGSN, BVCI 0x%04x, msg length %zu\n%s\n\n",
bvci, len, osmo_hexdump(buf, len));
else
- printf("NS UNITDATA MESSAGE to BSS, BVCI 0x%04x, msg length %d\n%s\n\n",
+ printf("NS UNITDATA MESSAGE to BSS, BVCI 0x%04x, msg length %zu\n%s\n\n",
bvci, len, osmo_hexdump(buf, len));
return real_gprs_ns_sendmsg(nsi, msg);
@@ -382,7 +382,7 @@ static int gprs_process_message(struct gprs_ns_inst *nsi, const char *text, stru
struct msgb *msg;
int ret;
if (data_len > NS_ALLOC_SIZE - NS_ALLOC_HEADROOM) {
- fprintf(stderr, "message too long: %d\n", data_len);
+ fprintf(stderr, "message too long: %zu\n", data_len);
return -1;
}
@@ -411,7 +411,7 @@ static int gprs_send_message(struct gprs_ns_inst *nsi, const char *text,
struct msgb *msg;
int ret;
if (data_len > NS_ALLOC_SIZE - NS_ALLOC_HEADROOM) {
- fprintf(stderr, "message too long: %d\n", data_len);
+ fprintf(stderr, "message too long: %zu\n", data_len);
return -1;
}
diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c
index 7e5e97b5..98502b75 100644
--- a/tests/gsm0808/gsm0808_test.c
+++ b/tests/gsm0808/gsm0808_test.c
@@ -26,7 +26,7 @@
#define VERIFY(msg, data, len) \
if (msgb_l3len(msg) != len) { \
printf("%s:%d Length don't match: %d vs. %d. %s\n", \
- __func__, __LINE__, msgb_l3len(msg), len, \
+ __func__, __LINE__, msgb_l3len(msg), (int) len, \
osmo_hexdump(msg->l3h, msgb_l3len(msg))); \
abort(); \
} else if (memcmp(msg->l3h, data, len) != 0) { \
diff --git a/tests/msgb/msgb_test.c b/tests/msgb/msgb_test.c
index 8839a2ed..a726ef4d 100644
--- a/tests/msgb/msgb_test.c
+++ b/tests/msgb/msgb_test.c
@@ -76,24 +76,24 @@ static void test_msgb_api()
printf("Buffer: %s\n", msgb_hexdump(msg));
OSMO_ASSERT(msgb_test_invariant(msg));
cptr = msg->l1h = msgb_put(msg, 4);
- printf("put(4) -> data%+d\n", cptr - msg->data);
+ printf("put(4) -> data%+td\n", cptr - msg->data);
printf("Buffer: %s\n", msgb_hexdump(msg));
OSMO_ASSERT(msgb_test_invariant(msg));
cptr = msg->l2h = msgb_put(msg, 4);
- printf("put(4) -> data%+d\n", cptr - msg->data);
+ printf("put(4) -> data%+td\n", cptr - msg->data);
printf("Buffer: %s\n", msgb_hexdump(msg));
OSMO_ASSERT(msgb_test_invariant(msg));
cptr = msg->l3h = msgb_put(msg, 4);
- printf("put(4) -> data%+d\n", cptr - msg->data);
+ printf("put(4) -> data%+td\n", cptr - msg->data);
printf("Buffer: %s\n", msgb_hexdump(msg));
OSMO_ASSERT(msgb_test_invariant(msg));
cptr = msg->l4h = msgb_put(msg, 4);
- printf("put(4) -> data%+d\n", cptr - msg->data);
+ printf("put(4) -> data%+td\n", cptr - msg->data);
printf("Buffer: %s\n", msgb_hexdump(msg));
OSMO_ASSERT(msgb_test_invariant(msg));
OSMO_ASSERT(msgb_length(msg) == 16);
cptr = msgb_push(msg, 4);
- printf("push(4) -> data%+d\n", cptr - msg->data);
+ printf("push(4) -> data%+td\n", cptr - msg->data);
printf("Buffer: %s\n", msgb_hexdump(msg));
OSMO_ASSERT(msgb_test_invariant(msg));
OSMO_ASSERT(msgb_length(msg) == 20);
@@ -105,7 +105,7 @@ static void test_msgb_api()
OSMO_ASSERT(msgb_length(msg) == 16);
cptr = msgb_get(msg, 4);
- printf("get(4) -> data%+d\n", cptr - msg->data);
+ printf("get(4) -> data%+td\n", cptr - msg->data);
printf("Buffer: %s\n", msgb_hexdump(msg));
OSMO_ASSERT(msgb_test_invariant(msg));
OSMO_ASSERT(msgb_length(msg) == 12);
diff --git a/tests/sms/sms_test.c b/tests/sms/sms_test.c
index cdd41585..776c45a1 100644
--- a/tests/sms/sms_test.c
+++ b/tests/sms/sms_test.c
@@ -390,7 +390,7 @@ int main(int argc, char** argv)
memset(result, 0x42, sizeof(result));
nchars = gsm_7bit_decode_n_hdr(result, sizeof(result), test_decode[i].input,
test_decode[i].expected_septet_length, test_decode[i].ud_hdr_ind);
- printf("Decode case %d: return value %d (expected %d)\n", i, nchars, strlen(result));
+ printf("Decode case %d: return value %d (expected %zu)\n", i, nchars, strlen(result));
OSMO_ASSERT(strcmp(result, (const char *) test_decode[i].expected) == 0);
OSMO_ASSERT(nchars == strlen(result));
diff --git a/tests/smscb/gsm0341_test.c b/tests/smscb/gsm0341_test.c
index a8e32d47..c400f5c8 100644
--- a/tests/smscb/gsm0341_test.c
+++ b/tests/smscb/gsm0341_test.c
@@ -21,6 +21,7 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+#include <time.h>
#include <osmocom/gsm/protocol/gsm_03_41.h>
#include <osmocom/gsm/gsm0341.h>