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) {
master
Andre Puschmann 2 years ago committed by Justin Tallon
parent 376b4f0011
commit 403c5d1cbe

@ -506,7 +506,7 @@ int main(int argc, char** argv)
if (srate != -1) { if (srate != -1) {
printf("Setting tx sampling rate %.2f MHz\n", (float)srate / 1000000); printf("Setting tx sampling rate %.2f MHz\n", (float)srate / 1000000);
float srate_rf = srsran_rf_set_tx_srate(&radio, (double)srate); 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); ERROR("Could not set tx sampling rate : wanted %d got %f", srate, srate_rf);
exit(-1); exit(-1);
} }

@ -963,7 +963,7 @@ int main(int argc, char** argv)
if (srate != -1) { if (srate != -1) {
printf("Setting tx sampling rate %.2f MHz\n", (float)srate / 1000000); printf("Setting tx sampling rate %.2f MHz\n", (float)srate / 1000000);
float srate_rf = srsran_rf_set_tx_srate(&radio, (double)srate); 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); ERROR("Could not set tx sampling rate : wanted %d got %f", srate, srate_rf);
exit(-1); exit(-1);
} }

@ -502,7 +502,7 @@ int main(int argc, char** argv)
if (srate != -1) { if (srate != -1) {
printf("Setting rx sampling rate %.2f MHz\n", (float)srate / 1000000); printf("Setting rx sampling rate %.2f MHz\n", (float)srate / 1000000);
float srate_rf = srsran_rf_set_rx_srate(&rf, (double)srate); 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); ERROR("Could not set rx sampling rate : wanted %d got %f", srate, srate_rf);
exit(-1); exit(-1);
} }

@ -262,7 +262,7 @@ int main(int argc, char** argv)
if (srate != -1) { if (srate != -1) {
printf("Setting sampling rate %.2f MHz\n", (float)srate / 1000000); printf("Setting sampling rate %.2f MHz\n", (float)srate / 1000000);
float srate_rf = srsran_rf_set_rx_srate(&radio, (double)srate); 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); ERROR("Could not set sampling rate : wanted %d got %f", srate, srate_rf);
exit(-1); exit(-1);
} }

Loading…
Cancel
Save