mirror of https://gerrit.osmocom.org/libosmocore
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.
This commit is contained in:
parent
ee6652b4bc
commit
fdb4667609
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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) { \
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue