[PATCH] 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/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Thu Feb 1 11:51:15 UTC 2018


Review at  https://gerrit.osmocom.org/6236

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(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/36/6236/1

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: newchange
Gerrit-Change-Id: I736c1e4d625f647d3bb794fa717256e9dbf36e87
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>



More information about the gerrit-log mailing list