Message ID | 20200422003735.3891-11-rosenp@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [01/12] utils: fix compilation with C++98 | expand |
On 22/04/2020 02:37, Rosen Penev wrote: > Found with -Wdouble-promotion > > Signed-off-by: Rosen Penev <rosenp@gmail.com> > --- > utils/rds-ctl/rds-ctl.cpp | 4 ++-- > utils/v4l2-compliance/v4l2-test-buffers.cpp | 2 +- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/utils/rds-ctl/rds-ctl.cpp b/utils/rds-ctl/rds-ctl.cpp > index cc1d3bf7..cd6ece38 100644 > --- a/utils/rds-ctl/rds-ctl.cpp > +++ b/utils/rds-ctl/rds-ctl.cpp > @@ -528,7 +528,7 @@ static void print_rds_statistics(const struct v4l2_rds_statistics *statistics) > (static_cast<float>(statistics->block_error_cnt) / statistics->block_cnt) * 100.0f; > printf("block errors / group errors: %u (%3.2f%%) / %u \n", > statistics->block_error_cnt, > - block_error_percentage, statistics->group_error_cnt); > + (double)block_error_percentage, statistics->group_error_cnt); Rather than adding a cast, I think the block_error_percentage and block_corrected_percentage type should just be changed to double. Regards, Hans > > float block_corrected_percentage = 0; > > @@ -536,7 +536,7 @@ static void print_rds_statistics(const struct v4l2_rds_statistics *statistics) > block_corrected_percentage = ( > static_cast<float>(statistics->block_corrected_cnt) / statistics->block_cnt) * 100.0f; > printf("corrected blocks: %u (%3.2f%%)\n", > - statistics->block_corrected_cnt, block_corrected_percentage); > + statistics->block_corrected_cnt, (double)block_corrected_percentage); > for (int i = 0; i < 16; i++) > printf("Group %02d: %u\n", i, statistics->group_type_cnt[i]); > } > diff --git a/utils/v4l2-compliance/v4l2-test-buffers.cpp b/utils/v4l2-compliance/v4l2-test-buffers.cpp > index 87c2e523..abf39cc7 100644 > --- a/utils/v4l2-compliance/v4l2-test-buffers.cpp > +++ b/utils/v4l2-compliance/v4l2-test-buffers.cpp > @@ -2597,7 +2597,7 @@ static void streamFmt(struct node *node, __u32 pixelformat, __u32 w, __u32 h, > char hz[32] = ""; > > if (!frame_count) > - frame_count = f ? (unsigned)(1.0f / fract2f(f)) : 10; > + frame_count = f ? (unsigned)(1.0 / fract2f(f)) : 10; > node->g_fmt(fmt); > fmt.s_pixelformat(pixelformat); > fmt.s_width(w); >
diff --git a/utils/rds-ctl/rds-ctl.cpp b/utils/rds-ctl/rds-ctl.cpp index cc1d3bf7..cd6ece38 100644 --- a/utils/rds-ctl/rds-ctl.cpp +++ b/utils/rds-ctl/rds-ctl.cpp @@ -528,7 +528,7 @@ static void print_rds_statistics(const struct v4l2_rds_statistics *statistics) (static_cast<float>(statistics->block_error_cnt) / statistics->block_cnt) * 100.0f; printf("block errors / group errors: %u (%3.2f%%) / %u \n", statistics->block_error_cnt, - block_error_percentage, statistics->group_error_cnt); + (double)block_error_percentage, statistics->group_error_cnt); float block_corrected_percentage = 0; @@ -536,7 +536,7 @@ static void print_rds_statistics(const struct v4l2_rds_statistics *statistics) block_corrected_percentage = ( static_cast<float>(statistics->block_corrected_cnt) / statistics->block_cnt) * 100.0f; printf("corrected blocks: %u (%3.2f%%)\n", - statistics->block_corrected_cnt, block_corrected_percentage); + statistics->block_corrected_cnt, (double)block_corrected_percentage); for (int i = 0; i < 16; i++) printf("Group %02d: %u\n", i, statistics->group_type_cnt[i]); } diff --git a/utils/v4l2-compliance/v4l2-test-buffers.cpp b/utils/v4l2-compliance/v4l2-test-buffers.cpp index 87c2e523..abf39cc7 100644 --- a/utils/v4l2-compliance/v4l2-test-buffers.cpp +++ b/utils/v4l2-compliance/v4l2-test-buffers.cpp @@ -2597,7 +2597,7 @@ static void streamFmt(struct node *node, __u32 pixelformat, __u32 w, __u32 h, char hz[32] = ""; if (!frame_count) - frame_count = f ? (unsigned)(1.0f / fract2f(f)) : 10; + frame_count = f ? (unsigned)(1.0 / fract2f(f)) : 10; node->g_fmt(fmt); fmt.s_pixelformat(pixelformat); fmt.s_width(w);
Found with -Wdouble-promotion Signed-off-by: Rosen Penev <rosenp@gmail.com> --- utils/rds-ctl/rds-ctl.cpp | 4 ++-- utils/v4l2-compliance/v4l2-test-buffers.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)