[MERGED] libosmocore[master]: tests: utils_test: Fix test failure when compiling with -O0

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Feb 8 09:41:36 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: tests: utils_test: Fix test failure when compiling with -O0
......................................................................


tests: utils_test: Fix test failure when compiling with -O0

It seems with default flags in_buf was being memzeroed by the compiler.
When compiling with -O0, that's not the case anymore and printf prints
after first 16 bytes, printing extra garbage which doesn't match the
expected output.

Change-Id: I736c1e4d625f647d3bb794fa717256e9dbf36e87
---
M tests/utils/utils_test.c
1 file changed, 1 insertion(+), 0 deletions(-)

Approvals:
  Vadim Yanitskiy: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/tests/utils/utils_test.c b/tests/utils/utils_test.c
index b4f7cd3..f358e9a 100644
--- a/tests/utils/utils_test.c
+++ b/tests/utils/utils_test.c
@@ -334,6 +334,7 @@
 
 	printf("\nTesting string escaping\n");
 	printf("- all chars from 0 to 255 in batches of 16:\n");
+	in_buf[16] = '\0';
 	for (j = 0; j < 16; j++) {
 		for (i = 0; i < 16; i++)
 			in_buf[i] = (j << 4) | i;

-- 
To view, visit https://gerrit.osmocom.org/6236
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I736c1e4d625f647d3bb794fa717256e9dbf36e87
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>



More information about the gerrit-log mailing list