From ecdccc1af2f68b1a272110fffd92e6617456011a Mon Sep 17 00:00:00 2001 From: Bill Rees Date: Wed, 8 Mar 2023 15:45:44 -0800 Subject: [PATCH] Fix warnings building on ubuntu kinetic gcc --version gcc (Ubuntu 12.2.0-3ubuntu1) 12.2.0 Copyright (C) 2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --- benchmark.c | 27 ++++++++++++++------------- smoke.c | 3 ++- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/benchmark.c b/benchmark.c index 098b3b7..eb8bd4e 100644 --- a/benchmark.c +++ b/benchmark.c @@ -29,6 +29,7 @@ #include #include #include "utils/minmax.h" +#include #include "indicators.h" #include "candles.h" @@ -866,17 +867,17 @@ void bench_run(FILE *log, const ti_indicator_info *info, const void *run_info, r fun(run_info, 0, GOAL_FREE); - const int elapsed = (clock() - start) * 1000 / CLOCKS_PER_SEC; - const int performance = elapsed == 0 ? 0 : (iterations * INSIZE) / elapsed / 1000; + const ssize_t elapsed = (clock() - start) * 1000 / CLOCKS_PER_SEC; + const ssize_t performance = elapsed == 0 ? 0 : (iterations * INSIZE) / elapsed / 1000; /*Million floats per second input.*/ if (elapsed) - printf("\t%5dms\t%5dmfps\n", elapsed, performance); + printf("\t%5dms\t%5dmfps\n", (int)elapsed, (int)performance); else printf("\n"); - best_e = MIN(elapsed, best_e); - best_p = MAX(performance, best_p); + best_e = MIN((int)elapsed, best_e); + best_p = MAX((int)performance, best_p); } if (log) fprintf(log, ",\n \"%s\" => array(\"elapsed\" => %d, \"performance\" => %d)", name, best_e, best_p); @@ -982,17 +983,17 @@ void bench_run_candle(FILE *log, const tc_candle_info *info) { } - const int elapsed = (clock() - start) * 1000 / CLOCKS_PER_SEC; - const int performance = elapsed == 0 ? 0 : (iterations * INSIZE) / elapsed / 1000; + const ssize_t elapsed = (clock() - start) * 1000 / CLOCKS_PER_SEC; + const ssize_t performance = elapsed == 0 ? 0 : (iterations * INSIZE) / elapsed / 1000; /*Million floats per second input.*/ if (elapsed) - printf("\t%5dms\t%5dmfps\n", elapsed, performance); + printf("\t%5dms\t%5dmfps\n", (int)elapsed, (int)performance); else printf("\n"); - best_e = MIN(elapsed, best_e); - best_p = MAX(performance, best_p); + best_e = MIN((int)elapsed, best_e); + best_p = MAX((int)performance, best_p); } if (log) fprintf(log, ",\n \"%s\" => array(\"elapsed\" => %d, \"performance\" => %d)", name, best_e, best_p); @@ -1027,8 +1028,8 @@ void bench_run_candle_talib(FILE *log, const tc_candle_info *info, const cnd_cro } } - const int elapsed = (clock() - start) * 1000 / CLOCKS_PER_SEC; - const int performance = elapsed == 0 ? 0 : (iterations * INSIZE) / elapsed / 1000; + const ssize_t elapsed = (clock() - start) * 1000 / CLOCKS_PER_SEC; + const ssize_t performance = elapsed == 0 ? 0 : (iterations * INSIZE) / elapsed / 1000; /*Million floats per second input.*/ if (elapsed) @@ -1124,7 +1125,7 @@ void bench_candle(FILE *log, const tc_candle_info *info) { int main(int argc, char **argv) { printf("Tulip Charts Indicator benchmark.\n"); - printf("Using real size of: %d.\n\n", sizeof(TI_REAL)); + printf("Using real size of: %d.\n\n", (int)sizeof(TI_REAL)); generate_inputs(); diff --git a/smoke.c b/smoke.c index 08c4655..c591b87 100644 --- a/smoke.c +++ b/smoke.c @@ -266,7 +266,8 @@ void test_candles(FILE *fp, int count) { do { if (feof(fp)) break; - fgets(buf, maxline, fp); + // (void)! works around the Wunused-warning hit + (void)!fgets(buf, maxline, fp); if (buf[0] != '!' && (buf[0] < 'a' || buf[0] > 'z')) break; char *name = strtok(buf, " ");