Change in libosmocore[master]: bssmap_le/bsslap tests: We must use %td for ptrdiff_t printing

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Fri Oct 9 08:18:42 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/20500 )

Change subject: bssmap_le/bsslap tests: We must use %td for ptrdiff_t printing
......................................................................

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
---
M tests/bsslap/bsslap_test.c
M tests/bssmap_le/bssmap_le_test.c
2 files changed, 9 insertions(+), 9 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/tests/bsslap/bsslap_test.c b/tests/bsslap/bsslap_test.c
index 43ea0d4..f20f7db 100644
--- a/tests/bsslap/bsslap_test.c
+++ b/tests/bsslap/bsslap_test.c
@@ -61,12 +61,12 @@
 		void *loop_ctx = msg;
 		rc = osmo_bsslap_enc(msg, pdu);
 		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));
 			goto loop_end;
 		}
 		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),
 			       rc, msg->len);
 			goto loop_end;
@@ -75,21 +75,21 @@
 		memset(&dec_pdu, 0xff, sizeof(dec_pdu));
 		rc = osmo_bsslap_dec(&dec_pdu, &err, loop_ctx, msg->data, msg->len);
 		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);
 			printf("     encoded data: %s\n", osmo_hexdump(msg->data, msg->len));
 			goto loop_end;
 		}
 
 		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));
 			printf("     original struct: %s\n", osmo_hexdump((void*)pdu, sizeof(*pdu)));
 			printf("      decoded struct: %s\n", osmo_hexdump((void*)&dec_pdu, sizeof(dec_pdu)));
 			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:
 		msgb_free(msg);
diff --git a/tests/bssmap_le/bssmap_le_test.c b/tests/bssmap_le/bssmap_le_test.c
index 59c7ed2..f9ebd92 100644
--- a/tests/bssmap_le/bssmap_le_test.c
+++ b/tests/bssmap_le/bssmap_le_test.c
@@ -138,7 +138,7 @@
 
 		msg = osmo_bssap_le_enc(&enc_pdu);
 		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));
 			goto loop_end;
 		}
@@ -147,14 +147,14 @@
 		memset(&dec_pdu, 0xff, sizeof(dec_pdu));
 		rc = osmo_bssap_le_dec(&dec_pdu, &err, loop_ctx, msg);
 		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);
 			printf("     encoded data: %s\n", osmo_hexdump(msg->data, msg->len));
 			goto loop_end;
 		}
 
 		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));
 			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)));
@@ -162,7 +162,7 @@
 			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);
 
 loop_end:

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/20500
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ib1c16b8adc5c8c0a2b418db51d12089f9b49a844
Gerrit-Change-Number: 20500
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201009/d4020da6/attachment.htm>


More information about the gerrit-log mailing list