Found with bugprone-incorrect-roundings Found with performance-type-promotion-in-math-fn Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx> --- lib/libdvbv5/dvb-fe.c | 2 +- utils/rds-ctl/rds-ctl.cpp | 5 +++-- utils/v4l2-ctl/v4l2-ctl-tuner.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/libdvbv5/dvb-fe.c b/lib/libdvbv5/dvb-fe.c index 4ff64d58..46fadaf0 100644 --- a/lib/libdvbv5/dvb-fe.c +++ b/lib/libdvbv5/dvb-fe.c @@ -1638,7 +1638,7 @@ static int __dvb_fe_snprintf_eng(char *buf, int len, float val, int metric) * Converts the number into an expoent and a * value between 0 and 1000, exclusive */ - exp = (int)log10(val); + exp = (int)log10f(val); if (exp > 0) exp = (exp / 3) * 3; else diff --git a/utils/rds-ctl/rds-ctl.cpp b/utils/rds-ctl/rds-ctl.cpp index e0db5f39..58dc98a4 100644 --- a/utils/rds-ctl/rds-ctl.cpp +++ b/utils/rds-ctl/rds-ctl.cpp @@ -28,6 +28,7 @@ #include <libv4l2rds.h> #include <cctype> +#include <cmath> #include <ctime> #include <list> #include <vector> @@ -915,8 +916,8 @@ static void get_options(const int fd, const int capabilities, struct v4l2_freque else printf("\tFrequency range : %.1f MHz - %.1f MHz\n", vt.rangelow / 16.0, vt.rangehigh / 16.0); - printf("\tSignal strength/AFC : %d%%/%d\n", - static_cast<int>((vt.signal / 655.35)+0.5), vt.afc); + printf("\tSignal strength/AFC : %ld%%/%d\n", + std::lround(vt.signal / 655.25), vt.afc); printf("\tCurrent audio mode : %s\n", audmode2s(vt.audmode)); printf("\tAvailable subchannels: %s\n", rxsubchans2s(vt.rxsubchans).c_str()); diff --git a/utils/v4l2-ctl/v4l2-ctl-tuner.cpp b/utils/v4l2-ctl/v4l2-ctl-tuner.cpp index 87c7790d..f6e268e3 100644 --- a/utils/v4l2-ctl/v4l2-ctl-tuner.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-tuner.cpp @@ -422,7 +422,7 @@ void tuner_get(cv4l_fd &_fd) vt.rangelow / 16.0, vt.rangehigh / 16.0); if (vt.type != V4L2_TUNER_SDR && vt.type != V4L2_TUNER_RF) { - printf("\tSignal strength/AFC : %d%%/%d\n", static_cast<int>((vt.signal / 655.35)+0.5), vt.afc); + printf("\tSignal strength/AFC : %ld%%/%d\n", lround(vt.signal / 655.35), vt.afc); printf("\tCurrent audio mode : %s\n", audmode2s(vt.audmode)); printf("\tAvailable subchannels: %s\n", rxsubchans2s(vt.rxsubchans).c_str()); } -- 2.25.2