From 733b470eced028fac82a3cbfd064f2dcf545c6bc Mon Sep 17 00:00:00 2001 From: Michael Barker Date: Tue, 27 Sep 2022 07:44:39 +1300 Subject: [PATCH] Fix clang-15 warnings. --- CMakeLists.txt | 4 +- src/hdr_thread.c | 2 +- test/hdr_atomic_test.c | 14 ++--- test/hdr_histogram_atomic_concurrency_test.c | 8 +-- test/hdr_histogram_atomic_test.c | 40 +++++++------- test/hdr_histogram_log_test.c | 58 ++++++++++---------- test/hdr_histogram_perf.c | 6 +- test/hdr_histogram_test.c | 44 +++++++-------- 8 files changed, 88 insertions(+), 88 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea9439a1..66e08751 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.12) project(hdr_histogram - VERSION 0.11.4 + VERSION 0.11.6 LANGUAGES C DESCRIPTION "C port of the HdrHistogram" HOMEPAGE_URL "http://hdrhistogram.github.io/HdrHistogram/") @@ -21,7 +21,7 @@ include(CMakePackageConfigHelpers) set(HDR_SOVERSION_CURRENT 6) set(HDR_SOVERSION_AGE 1) -set(HDR_SOVERSION_REVISION 1) +set(HDR_SOVERSION_REVISION 2) set(HDR_VERSION ${HDR_SOVERSION_CURRENT}.${HDR_SOVERSION_AGE}.${HDR_SOVERSION_REVISION}) set(HDR_SOVERSION ${HDR_SOVERSION_CURRENT}) diff --git a/src/hdr_thread.c b/src/hdr_thread.c index f92f576b..3c35c43c 100644 --- a/src/hdr_thread.c +++ b/src/hdr_thread.c @@ -94,7 +94,7 @@ void hdr_mutex_unlock(struct hdr_mutex* mutex) pthread_mutex_unlock(&mutex->_mutex); } -void hdr_yield() +void hdr_yield(void) { sched_yield(); } diff --git a/test/hdr_atomic_test.c b/test/hdr_atomic_test.c index cb6a6d59..394d3999 100644 --- a/test/hdr_atomic_test.c +++ b/test/hdr_atomic_test.c @@ -13,7 +13,7 @@ int tests_run = 0; -static char* test_store_load_64() +static char* test_store_load_64(void) { int64_t value = 45; int64_t b; @@ -28,7 +28,7 @@ static char* test_store_load_64() return 0; } -static char* test_store_load_pointer() +static char* test_store_load_pointer(void) { int64_t r = 12; int64_t* q = 0; @@ -43,7 +43,7 @@ static char* test_store_load_pointer() return 0; } -static char* test_exchange() +static char* test_exchange(void) { int64_t val1 = 123124; int64_t val2 = 987234; @@ -57,7 +57,7 @@ static char* test_exchange() return 0; } -static char* test_add() +static char* test_add(void) { int64_t val1 = 123124; int64_t val2 = 987234; @@ -70,7 +70,7 @@ static char* test_add() return 0; } -static struct mu_result all_tests() +static struct mu_result all_tests(void) { mu_run_test(test_store_load_64); mu_run_test(test_store_load_pointer); @@ -80,7 +80,7 @@ static struct mu_result all_tests() mu_ok; } -static int hdr_atomic_run_tests() +static int hdr_atomic_run_tests(void) { struct mu_result result = all_tests(); @@ -98,7 +98,7 @@ static int hdr_atomic_run_tests() return result.message == NULL ? 0 : -1; } -int main() +int main(void) { return hdr_atomic_run_tests(); } diff --git a/test/hdr_histogram_atomic_concurrency_test.c b/test/hdr_histogram_atomic_concurrency_test.c index e1cad526..8735cd33 100644 --- a/test/hdr_histogram_atomic_concurrency_test.c +++ b/test/hdr_histogram_atomic_concurrency_test.c @@ -40,7 +40,7 @@ static void* record_values(void* thread_context) } -static char* test_recording_concurrently() +static char* test_recording_concurrently(void) { const int value_count = 10000000; int64_t* values = calloc(value_count, sizeof(int64_t)); @@ -85,14 +85,14 @@ static char* test_recording_concurrently() return compare_histograms(expected_histogram, actual_histogram); } -static struct mu_result all_tests() +static struct mu_result all_tests(void) { mu_run_test(test_recording_concurrently); mu_ok; } -static int hdr_histogram_run_tests() +static int hdr_histogram_run_tests(void) { struct mu_result result = all_tests(); @@ -110,7 +110,7 @@ static int hdr_histogram_run_tests() return result.message == NULL ? 0 : -1; } -int main() +int main(void) { return hdr_histogram_run_tests(); } diff --git a/test/hdr_histogram_atomic_test.c b/test/hdr_histogram_atomic_test.c index a21d1262..c48f88e7 100644 --- a/test/hdr_histogram_atomic_test.c +++ b/test/hdr_histogram_atomic_test.c @@ -34,7 +34,7 @@ static struct hdr_histogram* cor_histogram = NULL; static struct hdr_histogram* scaled_raw_histogram = NULL; static struct hdr_histogram* scaled_cor_histogram = NULL; -static void load_histograms() +static void load_histograms(void) { const int64_t highest_trackable_value = INT64_C(3600) * 1000 * 1000; const int32_t significant_figures = 3; @@ -87,7 +87,7 @@ static void load_histograms() hdr_record_corrected_value_atomic(scaled_cor_histogram, 100000000 * scale, scaled_interval); } -static char* test_create() +static char* test_create(void) { struct hdr_histogram* h = NULL; int r = hdr_init(1, INT64_C(3600000000), 3, &h); @@ -101,7 +101,7 @@ static char* test_create() return 0; } -static char* test_create_with_large_values() +static char* test_create_with_large_values(void) { struct hdr_histogram* h = NULL; int r = hdr_init(20000000, 100000000, 5, &h); @@ -130,7 +130,7 @@ static char* test_create_with_large_values() return 0; } -static char* test_invalid_significant_figures() +static char* test_invalid_significant_figures(void) { struct hdr_histogram* h = NULL; @@ -145,7 +145,7 @@ static char* test_invalid_significant_figures() return 0; } -static char* test_invalid_init() +static char* test_invalid_init(void) { struct hdr_histogram* h = NULL; @@ -155,7 +155,7 @@ static char* test_invalid_init() return 0; } -static char* test_total_count() +static char* test_total_count(void) { load_histograms(); @@ -165,7 +165,7 @@ static char* test_total_count() return 0; } -static char* test_get_max_value() +static char* test_get_max_value(void) { int64_t actual_raw_max, actual_cor_max; @@ -181,7 +181,7 @@ static char* test_get_max_value() return 0; } -static char* test_get_min_value() +static char* test_get_min_value(void) { load_histograms(); @@ -191,7 +191,7 @@ static char* test_get_min_value() return 0; } -static char* test_percentiles() +static char* test_percentiles(void) { load_histograms(); @@ -225,7 +225,7 @@ static char* test_percentiles() } -static char* test_recorded_values() +static char* test_recorded_values(void) { struct hdr_iter iter; int index; @@ -275,7 +275,7 @@ static char* test_recorded_values() return 0; } -static char* test_linear_values() +static char* test_linear_values(void) { struct hdr_iter iter; int index; @@ -330,7 +330,7 @@ static char* test_linear_values() return 0; } -static char* test_logarithmic_values() +static char* test_logarithmic_values(void) { struct hdr_iter iter; int index; @@ -383,7 +383,7 @@ static char* test_logarithmic_values() return 0; } -static char* test_reset() +static char* test_reset(void) { load_histograms(); @@ -402,7 +402,7 @@ static char* test_reset() return 0; } -static char* test_scaling_equivalence() +static char* test_scaling_equivalence(void) { int64_t expected_99th, scaled_99th; load_histograms(); @@ -431,7 +431,7 @@ static char* test_scaling_equivalence() return 0; } -static char* test_out_of_range_values() +static char* test_out_of_range_values(void) { struct hdr_histogram *h; hdr_init(1, 1000, 4, &h); @@ -441,7 +441,7 @@ static char* test_out_of_range_values() return 0; } -static char* test_linear_iter_buckets_correctly() +static char* test_linear_iter_buckets_correctly(void) { int step_count = 0; int64_t total_count = 0; @@ -477,7 +477,7 @@ static char* test_linear_iter_buckets_correctly() return 0; } -static char* test_interval_recording() +static char* test_interval_recording(void) { int value_count, i, value; char* result; @@ -521,7 +521,7 @@ static char* test_interval_recording() return 0; } -static struct mu_result all_tests() +static struct mu_result all_tests(void) { mu_run_test(test_create); mu_run_test(test_invalid_init); @@ -543,7 +543,7 @@ static struct mu_result all_tests() mu_ok; } -static int hdr_histogram_run_tests() +static int hdr_histogram_run_tests(void) { struct mu_result result = all_tests(); @@ -561,7 +561,7 @@ static int hdr_histogram_run_tests() return result.message == NULL ? 0 : -1; } -int main() +int main(void) { return hdr_histogram_run_tests(); } diff --git a/test/hdr_histogram_log_test.c b/test/hdr_histogram_log_test.c index 1b7e3e72..50a49262 100644 --- a/test/hdr_histogram_log_test.c +++ b/test/hdr_histogram_log_test.c @@ -159,7 +159,7 @@ static bool compare_histogram(struct hdr_histogram* a, struct hdr_histogram* b) static struct hdr_histogram* raw_histogram = NULL; static struct hdr_histogram* cor_histogram = NULL; -static void load_histograms() +static void load_histograms(void) { int i; @@ -199,7 +199,7 @@ int hdr_decode_compressed( uint8_t* buffer, size_t length, struct hdr_histogram** histogram); void hex_dump (char *desc, void *addr, int len); -static char* test_encode_and_decode_compressed() +static char* test_encode_and_decode_compressed(void) { uint8_t* buffer = NULL; size_t len = 0; @@ -228,7 +228,7 @@ static char* test_encode_and_decode_compressed() return 0; } -static char* test_encode_and_decode_compressed2() +static char* test_encode_and_decode_compressed2(void) { uint8_t* buffer = NULL; size_t len = 0; @@ -257,7 +257,7 @@ static char* test_encode_and_decode_compressed2() return 0; } -static char* test_bounds_check_on_decode() +static char* test_bounds_check_on_decode(void) { uint8_t* buffer = NULL; size_t len = 0; @@ -279,7 +279,7 @@ static char* test_bounds_check_on_decode() return 0; } -static char* test_encode_and_decode_base64() +static char* test_encode_and_decode_base64(void) { uint8_t* buffer = NULL; uint8_t* decoded = NULL; @@ -306,7 +306,7 @@ static char* test_encode_and_decode_base64() return 0; } -static char* test_encode_and_decode_empty() +static char* test_encode_and_decode_empty(void) { uint8_t* buffer; uint8_t* decoded; @@ -336,7 +336,7 @@ static char* test_encode_and_decode_empty() return 0; } -static char* test_encode_and_decode_compressed_large() +static char* test_encode_and_decode_compressed_large(void) { const int64_t limit = INT64_C(3600) * 1000 * 1000; struct hdr_histogram* actual = NULL; @@ -388,7 +388,7 @@ static bool assert_base64_encode(const char* input, const char* expected) return result; } -static char* base64_encode_encodes_without_padding() +static char* base64_encode_encodes_without_padding(void) { mu_assert( "Encoding without padding", @@ -399,7 +399,7 @@ static char* base64_encode_encodes_without_padding() return 0; } -static char* base64_encode_encodes_with_padding() +static char* base64_encode_encodes_with_padding(void) { mu_assert( "Encoding with padding '='", @@ -415,7 +415,7 @@ static char* base64_encode_encodes_with_padding() return 0; } -static char* base64_encode_fails_with_invalid_lengths() +static char* base64_encode_fails_with_invalid_lengths(void) { mu_assert( "Output length not 4/3 of input length", @@ -424,7 +424,7 @@ static char* base64_encode_fails_with_invalid_lengths() return 0; } -static char* base64_encode_block_encodes_3_bytes() +static char* base64_encode_block_encodes_3_bytes(void) { char output[5] = { 0 }; @@ -434,7 +434,7 @@ static char* base64_encode_block_encodes_3_bytes() return 0; } -static char* base64_decode_block_decodes_4_chars() +static char* base64_decode_block_decodes_4_chars(void) { uint8_t output[4] = { 0 }; @@ -456,7 +456,7 @@ static bool assert_base64_decode(const char* base64_encoded, const char* expecte return result == 0 && compare_string(expected, (char*)output, output_len); } -static char* base64_decode_decodes_strings_without_padding() +static char* base64_decode_decodes_strings_without_padding(void) { mu_assert( "Encoding without padding", @@ -467,7 +467,7 @@ static char* base64_decode_decodes_strings_without_padding() return 0; } -static char* base64_decode_decodes_strings_with_padding() +static char* base64_decode_decodes_strings_with_padding(void) { mu_assert( "Encoding with padding '='", @@ -484,7 +484,7 @@ static char* base64_decode_decodes_strings_with_padding() return 0; } -static char* base64_decode_fails_with_invalid_lengths() +static char* base64_decode_fails_with_invalid_lengths(void) { mu_assert("Input length % 4 != 0", hdr_base64_decode(NULL, 5, NULL, 3) != 0); mu_assert("Input length < 4", hdr_base64_decode(NULL, 3, NULL, 3) != 0); @@ -495,7 +495,7 @@ static char* base64_decode_fails_with_invalid_lengths() return 0; } -static char* writes_and_reads_log() +static char* writes_and_reads_log(void) { struct hdr_log_writer writer; struct hdr_log_reader reader; @@ -585,7 +585,7 @@ static char* writes_and_reads_log() return 0; } -static char* log_reader_aggregates_into_single_histogram() +static char* log_reader_aggregates_into_single_histogram(void) { const char* file_name = "histogram.log"; hdr_timespec timestamp; @@ -650,7 +650,7 @@ static char* log_reader_aggregates_into_single_histogram() return 0; } -static char* log_reader_fails_with_incorrect_version() +static char* log_reader_fails_with_incorrect_version(void) { const char* log_with_invalid_version = "#[Test log]\n" @@ -679,7 +679,7 @@ static char* log_reader_fails_with_incorrect_version() return 0; } -static char* test_encode_decode_empty() +static char* test_encode_decode_empty(void) { char *data; struct hdr_histogram *histogram, *hdr_new = NULL; @@ -695,7 +695,7 @@ static char* test_encode_decode_empty() return 0; } -static char* test_string_encode_decode() +static char* test_string_encode_decode(void) { int i; char *data; @@ -716,7 +716,7 @@ static char* test_string_encode_decode() return 0; } -static char* test_string_encode_decode_2() +static char* test_string_encode_decode_2(void) { int i; char *data; @@ -741,7 +741,7 @@ static char* test_string_encode_decode_2() } -static char* decode_v1_log() +static char* decode_v1_log(void) { const char* v1_log = "jHiccup-2.0.6.logV1.hlog"; struct hdr_histogram* accum; @@ -788,7 +788,7 @@ static char* decode_v1_log() } -static char* decode_v2_log() +static char* decode_v2_log(void) { struct hdr_histogram* accum; struct hdr_histogram* h = NULL; @@ -834,7 +834,7 @@ static char* decode_v2_log() return 0; } -static char* decode_v3_log() +static char* decode_v3_log(void) { struct hdr_histogram* accum; struct hdr_histogram* h = NULL; @@ -904,7 +904,7 @@ static int parse_line_from_file(const char* filename) return result; } -static char* handle_invalid_log_lines() +static char* handle_invalid_log_lines(void) { mu_assert("Should have invalid histogram", -EINVAL == parse_line_from_file("test_tagged_invalid_histogram.txt")); mu_assert("Should have invalid tag key", -EINVAL == parse_line_from_file("test_tagged_invalid_tag_key.txt")); @@ -914,7 +914,7 @@ static char* handle_invalid_log_lines() return 0; } -static char* decode_v0_log() +static char* decode_v0_log(void) { struct hdr_histogram* accum; const char* v1_log = "jHiccup-2.0.1.logV0.hlog"; @@ -959,7 +959,7 @@ static char* decode_v0_log() return 0; } -static struct mu_result all_tests() +static struct mu_result all_tests(void) { tests_run = 0; @@ -1001,7 +1001,7 @@ static struct mu_result all_tests() mu_ok; } -static int hdr_histogram_log_run_tests() +static int hdr_histogram_log_run_tests(void) { struct mu_result result = all_tests(); @@ -1019,7 +1019,7 @@ static int hdr_histogram_log_run_tests() return result.message == NULL ? 0 : -1; } -int main() +int main(void) { return hdr_histogram_log_run_tests(); } diff --git a/test/hdr_histogram_perf.c b/test/hdr_histogram_perf.c index 9d7d4aa3..3c2683ad 100644 --- a/test/hdr_histogram_perf.c +++ b/test/hdr_histogram_perf.c @@ -62,7 +62,7 @@ static char *format_double(double d) return buffer; } -int main() +int main(void) { struct hdr_histogram* histogram; hdr_timespec t0, t1; @@ -94,8 +94,8 @@ int main() hdr_gettime(&t1); taken = diff(t0, t1); - time_taken = taken.tv_sec + taken.tv_nsec / 1000000000.0; - ops_sec = (iterations - 1) / time_taken; + time_taken = (double)taken.tv_sec + (double)taken.tv_nsec / 1000000000.0; + ops_sec = (double)(iterations - 1) / time_taken; printf("%s - %d, ops/sec: %s\n", "Iteration", i + 1, format_double(ops_sec)); } diff --git a/test/hdr_histogram_test.c b/test/hdr_histogram_test.c index d473a3b5..baea3f08 100644 --- a/test/hdr_histogram_test.c +++ b/test/hdr_histogram_test.c @@ -34,7 +34,7 @@ static struct hdr_histogram* cor_histogram = NULL; static struct hdr_histogram* scaled_raw_histogram = NULL; static struct hdr_histogram* scaled_cor_histogram = NULL; -static void load_histograms() +static void load_histograms(void) { const int64_t highest_trackable_value = INT64_C(3600) * 1000 * 1000; const int32_t significant_figures = 3; @@ -87,7 +87,7 @@ static void load_histograms() hdr_record_corrected_value(scaled_cor_histogram, 100000000 * scale, scaled_interval); } -static char* test_create() +static char* test_create(void) { struct hdr_histogram* h = NULL; int r = hdr_init(1, INT64_C(3600000000), 3, &h); @@ -101,7 +101,7 @@ static char* test_create() return 0; } -static char* test_create_with_large_values() +static char* test_create_with_large_values(void) { struct hdr_histogram* h = NULL; int r = hdr_init(20000000, 100000000, 5, &h); @@ -130,7 +130,7 @@ static char* test_create_with_large_values() return 0; } -static char* test_invalid_significant_figures() +static char* test_invalid_significant_figures(void) { struct hdr_histogram* h = NULL; @@ -145,7 +145,7 @@ static char* test_invalid_significant_figures() return 0; } -static char* test_invalid_init() +static char* test_invalid_init(void) { struct hdr_histogram* h = NULL; @@ -155,7 +155,7 @@ static char* test_invalid_init() return 0; } -static char* test_total_count() +static char* test_total_count(void) { load_histograms(); @@ -165,7 +165,7 @@ static char* test_total_count() return 0; } -static char* test_get_max_value() +static char* test_get_max_value(void) { int64_t actual_raw_max, actual_cor_max; @@ -181,7 +181,7 @@ static char* test_get_max_value() return 0; } -static char* test_get_min_value() +static char* test_get_min_value(void) { load_histograms(); @@ -191,7 +191,7 @@ static char* test_get_min_value() return 0; } -static char* test_percentiles() +static char* test_percentiles(void) { load_histograms(); @@ -224,7 +224,7 @@ static char* test_percentiles() return 0; } -static char* test_percentiles_by_value_at_percentiles() +static char* test_percentiles_by_value_at_percentiles(void) { load_histograms(); int64_t values[5] = { 0 }; @@ -240,7 +240,7 @@ static char* test_percentiles_by_value_at_percentiles() } -static char* test_recorded_values() +static char* test_recorded_values(void) { struct hdr_iter iter; int index; @@ -290,7 +290,7 @@ static char* test_recorded_values() return 0; } -static char* test_linear_values() +static char* test_linear_values(void) { struct hdr_iter iter; int index; @@ -345,7 +345,7 @@ static char* test_linear_values() return 0; } -static char* test_logarithmic_values() +static char* test_logarithmic_values(void) { struct hdr_iter iter; int index; @@ -398,7 +398,7 @@ static char* test_logarithmic_values() return 0; } -static char* test_reset() +static char* test_reset(void) { load_histograms(); @@ -417,7 +417,7 @@ static char* test_reset() return 0; } -static char* test_scaling_equivalence() +static char* test_scaling_equivalence(void) { int64_t expected_99th, scaled_99th; load_histograms(); @@ -446,7 +446,7 @@ static char* test_scaling_equivalence() return 0; } -static char* test_out_of_range_values() +static char* test_out_of_range_values(void) { struct hdr_histogram *h; hdr_init(1, 1000, 4, &h); @@ -456,7 +456,7 @@ static char* test_out_of_range_values() return 0; } -static char* test_linear_iter_buckets_correctly() +static char* test_linear_iter_buckets_correctly(void) { int step_count = 0; int64_t total_count = 0; @@ -492,7 +492,7 @@ static char* test_linear_iter_buckets_correctly() return 0; } -static char* test_interval_recording() +static char* test_interval_recording(void) { int value_count, i, value; char* result; @@ -536,7 +536,7 @@ static char* test_interval_recording() return 0; } -static char* reset_histogram_on_sample_and_recycle() +static char* reset_histogram_on_sample_and_recycle(void) { struct hdr_interval_recorder recorder; struct hdr_histogram* inactive1; @@ -561,7 +561,7 @@ static char* reset_histogram_on_sample_and_recycle() return 0; } -static struct mu_result all_tests() +static struct mu_result all_tests(void) { mu_run_test(test_create); mu_run_test(test_invalid_init); @@ -585,7 +585,7 @@ static struct mu_result all_tests() mu_ok; } -static int hdr_histogram_run_tests() +static int hdr_histogram_run_tests(void) { struct mu_result result = all_tests(); @@ -603,7 +603,7 @@ static int hdr_histogram_run_tests() return result.message == NULL ? 0 : -1; } -int main() +int main(void) { return hdr_histogram_run_tests(); }