All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Rosen Penev <rosenp@gmail.com>, linux-media@vger.kernel.org
Subject: Re: [PATCH 11/12] utils: fix double promotions
Date: Thu, 23 Apr 2020 10:45:48 +0200	[thread overview]
Message-ID: <7b935d65-7555-4226-61e7-5c6a6bcecedf@xs4all.nl> (raw)
In-Reply-To: <20200422003735.3891-11-rosenp@gmail.com>

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);
> 


  reply	other threads:[~2020-04-23  8:45 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-22  0:37 [PATCH 01/12] utils: fix compilation with C++98 Rosen Penev
2020-04-22  0:37 ` [PATCH 02/12] utils: remove extra commas Rosen Penev
2020-04-22  0:37 ` [PATCH 03/12] utils: fix float equal warning Rosen Penev
2020-04-22  0:37 ` [PATCH 04/12] utils: don't check unsigned for < 0 Rosen Penev
2020-04-23  8:30   ` Hans Verkuil
2020-04-23  8:33     ` Rosen Penev
2020-04-22  0:37 ` [PATCH 05/12] utils: add copy assignment operator Rosen Penev
2020-04-22  0:37 ` [PATCH 06/12] utils: add noreturn attribute and remove dead code Rosen Penev
2020-04-23  8:34   ` Hans Verkuil
2020-04-22  0:37 ` [PATCH 07/12] utils: fix implicit double promotion Rosen Penev
2020-04-23  9:04   ` Hans Verkuil
2020-04-22  0:37 ` [PATCH 08/12] utils: initialize variable Rosen Penev
2020-04-22  0:37 ` [PATCH 09/12] utils: fix implicit float conversions Rosen Penev
2020-04-23  8:36   ` Hans Verkuil
2020-04-23  8:44     ` Rosen Penev
2020-04-23  9:01       ` Hans Verkuil
2020-04-22  0:37 ` [PATCH 10/12] utils: fix fallthrough warnings Rosen Penev
2020-04-23  8:43   ` Hans Verkuil
2020-04-23  8:46     ` Rosen Penev
2020-04-23  8:57       ` Hans Verkuil
2020-04-22  0:37 ` [PATCH 11/12] utils: fix double promotions Rosen Penev
2020-04-23  8:45   ` Hans Verkuil [this message]
2020-04-22  0:37 ` [PATCH 12/12] utils: fix wrong format Rosen Penev
2020-04-23  8:19 ` [PATCH 01/12] utils: fix compilation with C++98 Hans Verkuil
2020-04-23  8:30   ` Rosen Penev
2020-04-23  8:48     ` Hans Verkuil
2020-04-23  8:50       ` Rosen Penev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7b935d65-7555-4226-61e7-5c6a6bcecedf@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=rosenp@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.