From 403c5d1cbe845df3812a6d6670979eea69b2d6e3 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Fri, 14 Apr 2023 19:36:23 +0200 Subject: [PATCH] examples: fix compile error when using float value for abs() ./lib/examples/npdsch_enodeb.c:509:11: error: using integer absolute value function 'abs' when argument is of floating point type [-Werror,-Wabsolute-value] if (abs(srate - srate_rf) > MAX_SRATE_DELTA) { --- lib/examples/npdsch_enodeb.c | 2 +- lib/examples/pdsch_enodeb.c | 2 +- lib/examples/pdsch_ue.c | 2 +- lib/examples/pssch_ue.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/examples/npdsch_enodeb.c b/lib/examples/npdsch_enodeb.c index 283fb56a9..c909e110b 100644 --- a/lib/examples/npdsch_enodeb.c +++ b/lib/examples/npdsch_enodeb.c @@ -506,7 +506,7 @@ int main(int argc, char** argv) if (srate != -1) { printf("Setting tx sampling rate %.2f MHz\n", (float)srate / 1000000); float srate_rf = srsran_rf_set_tx_srate(&radio, (double)srate); - if (abs(srate - srate_rf) > MAX_SRATE_DELTA) { + if (abs(srate - (int)srate_rf) > MAX_SRATE_DELTA) { ERROR("Could not set tx sampling rate : wanted %d got %f", srate, srate_rf); exit(-1); } diff --git a/lib/examples/pdsch_enodeb.c b/lib/examples/pdsch_enodeb.c index 46f89ee40..d39be21af 100644 --- a/lib/examples/pdsch_enodeb.c +++ b/lib/examples/pdsch_enodeb.c @@ -963,7 +963,7 @@ int main(int argc, char** argv) if (srate != -1) { printf("Setting tx sampling rate %.2f MHz\n", (float)srate / 1000000); float srate_rf = srsran_rf_set_tx_srate(&radio, (double)srate); - if (abs(srate - srate_rf) > MAX_SRATE_DELTA) { + if (abs(srate - (int)srate_rf) > MAX_SRATE_DELTA) { ERROR("Could not set tx sampling rate : wanted %d got %f", srate, srate_rf); exit(-1); } diff --git a/lib/examples/pdsch_ue.c b/lib/examples/pdsch_ue.c index eaed11353..117315141 100644 --- a/lib/examples/pdsch_ue.c +++ b/lib/examples/pdsch_ue.c @@ -502,7 +502,7 @@ int main(int argc, char** argv) if (srate != -1) { printf("Setting rx sampling rate %.2f MHz\n", (float)srate / 1000000); float srate_rf = srsran_rf_set_rx_srate(&rf, (double)srate); - if (abs(srate - srate_rf) > MAX_SRATE_DELTA) { + if (abs(srate - (int)srate_rf) > MAX_SRATE_DELTA) { ERROR("Could not set rx sampling rate : wanted %d got %f", srate, srate_rf); exit(-1); } diff --git a/lib/examples/pssch_ue.c b/lib/examples/pssch_ue.c index efddf66d4..334430554 100644 --- a/lib/examples/pssch_ue.c +++ b/lib/examples/pssch_ue.c @@ -262,7 +262,7 @@ int main(int argc, char** argv) if (srate != -1) { printf("Setting sampling rate %.2f MHz\n", (float)srate / 1000000); float srate_rf = srsran_rf_set_rx_srate(&radio, (double)srate); - if (abs(srate - srate_rf) > MAX_SRATE_DELTA) { + if (abs(srate - (int)srate_rf) > MAX_SRATE_DELTA) { ERROR("Could not set sampling rate : wanted %d got %f", srate, srate_rf); exit(-1); }