From 4ca166b0b916839113fa32f4b818d274d96f105d Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Tue, 9 Aug 2022 00:19:26 +0200 Subject: [PATCH] Update examples to remove warnings with assertion disabled. --- example/ex-algo03.c | 2 +- example/ex-algo04.c | 2 +- example/ex-array00.c | 4 ++-- example/ex-dict02.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/example/ex-algo03.c b/example/ex-algo03.c index dd1e00ad..940b9837 100644 --- a/example/ex-algo03.c +++ b/example/ex-algo03.c @@ -23,7 +23,7 @@ ARRAY_DEF(vector_int, int) int main(void) { - int s; + int s = 0; // Init keys as a vector_int_t, initialize it (and prepare its destruction) M_LET(keys, vector_int_t) // Initialize m as a dictionnary and initialize it with the given database diff --git a/example/ex-algo04.c b/example/ex-algo04.c index c3b70750..14c9a701 100644 --- a/example/ex-algo04.c +++ b/example/ex-algo04.c @@ -19,7 +19,7 @@ int main(void) M_LET(s, string_t) // Let v be a vector of integer and initialize it. M_LET( (v, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), vector_int_t) { - int sum, product; + int sum = 0, product = 0; // Compute the sum of theses integers. ALGO_REDUCE(sum, v, vector_int_t, add); diff --git a/example/ex-array00.c b/example/ex-array00.c index 609a9ec7..6d92b19a 100644 --- a/example/ex-array00.c +++ b/example/ex-array00.c @@ -231,7 +231,7 @@ test_cstring(int n) r_cstring_init(array); for(int i = 0; i < n; i++) { - char buffer[10]; + char buffer[16]; // Create a string from the integer sprintf(buffer, "%d", i); // We need to make an explicit copy of the string @@ -612,7 +612,7 @@ int main (int argc, const char *argv[]) s = test_rockme3(n); printf ("S[rockme3] = %d\n", s); - s = test_rockme3(n); + s = test_rockme4(n); printf ("S[rockme4] = %d\n", s); exit(0); diff --git a/example/ex-dict02.c b/example/ex-dict02.c index c2cd9da1..b36f6640 100644 --- a/example/ex-dict02.c +++ b/example/ex-dict02.c @@ -14,7 +14,7 @@ int main(void) { dict_m32_set_at (h, 5, 10); // h[5] = 10 char *k = dict_m32_get(h, 10); // No 10 in h, so k == NULL int is_missing = (k != NULL); // true - assert (is_missing); + assert (is_missing); (void) is_missing; dict_m32_erase(h, 5); // h is now empty dict_m32_it_t it; // iterate over all dictionnary for (dict_m32_it (it, h) ; !dict_m32_end_p (it); dict_m32_next(it)) {