diff options
author | Julius Bünger <buenger@mytum.de> | 2018-04-09 00:17:57 +0200 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2018-04-09 00:17:57 +0200 |
commit | db67f7e2f62e38ee9b7cf5526609431a04f9bc9d (patch) | |
tree | a9fe34794f36c41ed168e42e181371c70638686b /src/rps | |
parent | ddd6bbe592939c66cf0bbe0f0591d86ab56946be (diff) | |
download | gnunet-db67f7e2f62e38ee9b7cf5526609431a04f9bc9d.tar.gz gnunet-db67f7e2f62e38ee9b7cf5526609431a04f9bc9d.zip |
rps test: be more flexible in printing
Diffstat (limited to 'src/rps')
-rw-r--r-- | src/rps/rps-test_util.h | 10 | ||||
-rw-r--r-- | src/rps/test_rps.c | 4 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/rps/rps-test_util.h b/src/rps/rps-test_util.h index e8e352ff6..725be815c 100644 --- a/src/rps/rps-test_util.h +++ b/src/rps/rps-test_util.h | |||
@@ -58,8 +58,18 @@ create_file (const char *name); | |||
58 | else\ | 58 | else\ |
59 | to_file_(file_name,tmp_buf);\ | 59 | to_file_(file_name,tmp_buf);\ |
60 | } while (0); | 60 | } while (0); |
61 | # define to_file_w_len(file_name, len, ...) do {char tmp_buf[len];\ | ||
62 | int size;\ | ||
63 | size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),__VA_ARGS__);\ | ||
64 | if (0 > size)\ | ||
65 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\ | ||
66 | "Failed to create tmp_buf\n");\ | ||
67 | else\ | ||
68 | to_file_(file_name,tmp_buf);\ | ||
69 | } while (0); | ||
61 | #else /* TO_FILE */ | 70 | #else /* TO_FILE */ |
62 | # define to_file(file_name, ...) | 71 | # define to_file(file_name, ...) |
72 | # define to_file_w_len(file_name, len, ...) | ||
63 | #endif /* TO_FILE */ | 73 | #endif /* TO_FILE */ |
64 | 74 | ||
65 | #endif /* RPS_TEST_UTIL_H */ | 75 | #endif /* RPS_TEST_UTIL_H */ |
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index b4c5e6cb1..b46fc0c1e 100644 --- a/src/rps/test_rps.c +++ b/src/rps/test_rps.c | |||
@@ -2017,7 +2017,9 @@ static void compute_probabilities (uint32_t peer_idx) | |||
2017 | GNUNET_assert (0 <= tmp); | 2017 | GNUNET_assert (0 <= tmp); |
2018 | } | 2018 | } |
2019 | 2019 | ||
2020 | to_file (rps_peers[peer_idx].file_name_probs, probs_as_str); | 2020 | to_file_w_len (rps_peers[peer_idx].file_name_probs, |
2021 | probs_as_str_size, | ||
2022 | probs_as_str); | ||
2021 | GNUNET_free (probs_as_str); | 2023 | GNUNET_free (probs_as_str); |
2022 | } | 2024 | } |
2023 | 2025 | ||