mirror of https://gerrit.osmocom.org/libosmocore
bssmap_le/bsslap tests: We must use %td for ptrdiff_t printing
Otherwise we get (valid!) format string warnings like these on 32bit targets: [ 372s] bssmap_le/bssmap_le_test.c: In function 'test_bssmap_le_enc_dec': [ 372s] bssmap_le/bssmap_le_test.c:141:15: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'int' [-Wformat=] [ 372s] printf("[%ld] %s: ERROR: failed to encode pdu\n", (pdu - bssmap_le_test_pdus), [ 372s] ^ Closes: OS#4786 Change-Id: Ib1c16b8adc5c8c0a2b418db51d12089f9b49a844
This commit is contained in:
parent
a5218ea9b3
commit
f445150c57
|
@ -61,12 +61,12 @@ void test_bsslap_enc_dec()
|
||||||
void *loop_ctx = msg;
|
void *loop_ctx = msg;
|
||||||
rc = osmo_bsslap_enc(msg, pdu);
|
rc = osmo_bsslap_enc(msg, pdu);
|
||||||
if (rc <= 0) {
|
if (rc <= 0) {
|
||||||
printf("[%ld] %s: ERROR: failed to encode pdu\n", (pdu - bsslap_test_pdus),
|
printf("[%td] %s: ERROR: failed to encode pdu\n", (pdu - bsslap_test_pdus),
|
||||||
osmo_bsslap_msgt_name(pdu->msg_type));
|
osmo_bsslap_msgt_name(pdu->msg_type));
|
||||||
goto loop_end;
|
goto loop_end;
|
||||||
}
|
}
|
||||||
if (rc != msg->len) {
|
if (rc != msg->len) {
|
||||||
printf("[%ld] %s: ERROR: osmo_bsslap_enc() returned length %d but msgb has %d bytes\n",
|
printf("[%td] %s: ERROR: osmo_bsslap_enc() returned length %d but msgb has %d bytes\n",
|
||||||
(pdu - bsslap_test_pdus), osmo_bsslap_msgt_name(pdu->msg_type),
|
(pdu - bsslap_test_pdus), osmo_bsslap_msgt_name(pdu->msg_type),
|
||||||
rc, msg->len);
|
rc, msg->len);
|
||||||
goto loop_end;
|
goto loop_end;
|
||||||
|
@ -75,21 +75,21 @@ void test_bsslap_enc_dec()
|
||||||
memset(&dec_pdu, 0xff, sizeof(dec_pdu));
|
memset(&dec_pdu, 0xff, sizeof(dec_pdu));
|
||||||
rc = osmo_bsslap_dec(&dec_pdu, &err, loop_ctx, msg->data, msg->len);
|
rc = osmo_bsslap_dec(&dec_pdu, &err, loop_ctx, msg->data, msg->len);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
printf("[%ld] %s: ERROR: failed to decode pdu: %s\n", (pdu - bsslap_test_pdus),
|
printf("[%td] %s: ERROR: failed to decode pdu: %s\n", (pdu - bsslap_test_pdus),
|
||||||
osmo_bsslap_msgt_name(pdu->msg_type), err->logmsg);
|
osmo_bsslap_msgt_name(pdu->msg_type), err->logmsg);
|
||||||
printf(" encoded data: %s\n", osmo_hexdump(msg->data, msg->len));
|
printf(" encoded data: %s\n", osmo_hexdump(msg->data, msg->len));
|
||||||
goto loop_end;
|
goto loop_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memcmp(pdu, &dec_pdu, sizeof(dec_pdu))) {
|
if (memcmp(pdu, &dec_pdu, sizeof(dec_pdu))) {
|
||||||
printf("[%ld] %s: ERROR: decoded PDU != encoded PDU\n", (pdu - bsslap_test_pdus),
|
printf("[%td] %s: ERROR: decoded PDU != encoded PDU\n", (pdu - bsslap_test_pdus),
|
||||||
osmo_bsslap_msgt_name(pdu->msg_type));
|
osmo_bsslap_msgt_name(pdu->msg_type));
|
||||||
printf(" original struct: %s\n", osmo_hexdump((void*)pdu, sizeof(*pdu)));
|
printf(" original struct: %s\n", osmo_hexdump((void*)pdu, sizeof(*pdu)));
|
||||||
printf(" decoded struct: %s\n", osmo_hexdump((void*)&dec_pdu, sizeof(dec_pdu)));
|
printf(" decoded struct: %s\n", osmo_hexdump((void*)&dec_pdu, sizeof(dec_pdu)));
|
||||||
goto loop_end;
|
goto loop_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("[%ld] %s: ok\n", (pdu - bsslap_test_pdus), osmo_bsslap_msgt_name(pdu->msg_type));
|
printf("[%td] %s: ok\n", (pdu - bsslap_test_pdus), osmo_bsslap_msgt_name(pdu->msg_type));
|
||||||
|
|
||||||
loop_end:
|
loop_end:
|
||||||
msgb_free(msg);
|
msgb_free(msg);
|
||||||
|
|
|
@ -138,7 +138,7 @@ void test_bssmap_le_enc_dec()
|
||||||
|
|
||||||
msg = osmo_bssap_le_enc(&enc_pdu);
|
msg = osmo_bssap_le_enc(&enc_pdu);
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
printf("[%ld] %s: ERROR: failed to encode pdu\n", (pdu - bssmap_le_test_pdus),
|
printf("[%td] %s: ERROR: failed to encode pdu\n", (pdu - bssmap_le_test_pdus),
|
||||||
osmo_bssmap_le_msgt_name(pdu->msg_type));
|
osmo_bssmap_le_msgt_name(pdu->msg_type));
|
||||||
goto loop_end;
|
goto loop_end;
|
||||||
}
|
}
|
||||||
|
@ -147,14 +147,14 @@ void test_bssmap_le_enc_dec()
|
||||||
memset(&dec_pdu, 0xff, sizeof(dec_pdu));
|
memset(&dec_pdu, 0xff, sizeof(dec_pdu));
|
||||||
rc = osmo_bssap_le_dec(&dec_pdu, &err, loop_ctx, msg);
|
rc = osmo_bssap_le_dec(&dec_pdu, &err, loop_ctx, msg);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
printf("[%ld] %s: ERROR: failed to decode pdu: %s\n", (pdu - bssmap_le_test_pdus),
|
printf("[%td] %s: ERROR: failed to decode pdu: %s\n", (pdu - bssmap_le_test_pdus),
|
||||||
osmo_bssmap_le_msgt_name(pdu->msg_type), err->logmsg);
|
osmo_bssmap_le_msgt_name(pdu->msg_type), err->logmsg);
|
||||||
printf(" encoded data: %s\n", osmo_hexdump(msg->data, msg->len));
|
printf(" encoded data: %s\n", osmo_hexdump(msg->data, msg->len));
|
||||||
goto loop_end;
|
goto loop_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memcmp(&enc_pdu, &dec_pdu, sizeof(dec_pdu))) {
|
if (memcmp(&enc_pdu, &dec_pdu, sizeof(dec_pdu))) {
|
||||||
printf("[%ld] %s: ERROR: decoded PDU != encoded PDU\n", (pdu - bssmap_le_test_pdus),
|
printf("[%td] %s: ERROR: decoded PDU != encoded PDU\n", (pdu - bssmap_le_test_pdus),
|
||||||
osmo_bssmap_le_msgt_name(pdu->msg_type));
|
osmo_bssmap_le_msgt_name(pdu->msg_type));
|
||||||
printf(" original struct: %s\n", osmo_hexdump((void*)&enc_pdu, sizeof(enc_pdu)));
|
printf(" original struct: %s\n", osmo_hexdump((void*)&enc_pdu, sizeof(enc_pdu)));
|
||||||
printf(" decoded struct: %s\n", osmo_hexdump((void*)&dec_pdu, sizeof(dec_pdu)));
|
printf(" decoded struct: %s\n", osmo_hexdump((void*)&dec_pdu, sizeof(dec_pdu)));
|
||||||
|
@ -162,7 +162,7 @@ void test_bssmap_le_enc_dec()
|
||||||
goto loop_end;
|
goto loop_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("[%ld] %s: ok (encoded len = %d)\n", (pdu - bssmap_le_test_pdus),
|
printf("[%td] %s: ok (encoded len = %d)\n", (pdu - bssmap_le_test_pdus),
|
||||||
osmo_bssmap_le_msgt_name(pdu->msg_type), msg->len);
|
osmo_bssmap_le_msgt_name(pdu->msg_type), msg->len);
|
||||||
|
|
||||||
loop_end:
|
loop_end:
|
||||||
|
|
Loading…
Reference in New Issue