All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rosen Penev <rosenp@gmail.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH 09/12] utils: fix implicit float conversions
Date: Thu, 23 Apr 2020 01:44:02 -0700	[thread overview]
Message-ID: <DBFC2366-4C35-43A2-8AC0-7F108FF6255F@gmail.com> (raw)
In-Reply-To: <614cd737-6d34-be13-2c45-da43652cf586@xs4all.nl>



> On Apr 23, 2020, at 1:36 AM, Hans Verkuil <hverkuil@xs4all.nl> wrote:
> 
> On 22/04/2020 02:37, Rosen Penev wrote:
>> Found with -Wfloat-conversion
>> 
>> Signed-off-by: Rosen Penev <rosenp@gmail.com>
>> ---
>> utils/cec-ctl/cec-ctl.cpp                   | 4 ++--
>> utils/cec-ctl/cec-pin.cpp                   | 2 +-
>> utils/v4l2-compliance/v4l2-test-buffers.cpp | 2 +-
>> utils/v4l2-ctl/v4l2-ctl-misc.cpp            | 4 ++--
>> utils/v4l2-ctl/v4l2-ctl-streaming.cpp       | 2 +-
>> utils/v4l2-ctl/v4l2-ctl-subdev.cpp          | 2 +-
>> 6 files changed, 8 insertions(+), 8 deletions(-)
>> 
>> diff --git a/utils/cec-ctl/cec-ctl.cpp b/utils/cec-ctl/cec-ctl.cpp
>> index f4133494..f0e31aca 100644
>> --- a/utils/cec-ctl/cec-ctl.cpp
>> +++ b/utils/cec-ctl/cec-ctl.cpp
>> @@ -1507,8 +1507,8 @@ static void stress_test_power_cycle(struct node &node, unsigned cnt,
>>    srandom(seed);
>> 
>>    for (;;) {
>> -        unsigned usecs1 = mod_usleep ? random() % mod_usleep : sleep_before_on * 1000000;
>> -        unsigned usecs2 = mod_usleep ? random() % mod_usleep : sleep_before_off * 1000000;
>> +        unsigned usecs1 = mod_usleep ? random() % mod_usleep : (unsigned)(sleep_before_on * 1000000);
>> +        unsigned usecs2 = mod_usleep ? random() % mod_usleep : (unsigned)(sleep_before_off * 1000000);
> 
> Shouldn't this be static_cast<unsigned>? Same elsewhere.
Sure, but that’s beyond this patch. It should be unsigned int actually. Implicit int is bad.
> 
> Regards,
> 
>    Hans
> 
>> 
>>        usecs1 += min_usleep;
>>        usecs2 += min_usleep;
>> diff --git a/utils/cec-ctl/cec-pin.cpp b/utils/cec-ctl/cec-pin.cpp
>> index 0322ad5e..10abea37 100644
>> --- a/utils/cec-ctl/cec-pin.cpp
>> +++ b/utils/cec-ctl/cec-pin.cpp
>> @@ -261,7 +261,7 @@ static void cec_pin_rx_data_bit_was_low(__u64 ev_ts, __u64 usecs, __u64 usecs_mi
>>     * If the low drive starts at the end of a 0 bit, then the actual
>>     * maximum time that the bus can be low is the two summed.
>>     */
>> -    const unsigned max_low_drive = CEC_TIM_LOW_DRIVE_ERROR_MAX +
>> +    const unsigned max_low_drive = (unsigned)CEC_TIM_LOW_DRIVE_ERROR_MAX +
>>        CEC_TIM_DATA_BIT_0_LOW_MAX + CEC_TIM_MARGIN;
>> 
>>    low_usecs = usecs;
>> diff --git a/utils/v4l2-compliance/v4l2-test-buffers.cpp b/utils/v4l2-compliance/v4l2-test-buffers.cpp
>> index 93df7034..87c2e523 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 ? 1.0 / fract2f(f) : 10;
>> +        frame_count = f ? (unsigned)(1.0f / fract2f(f)) : 10;
>>    node->g_fmt(fmt);
>>    fmt.s_pixelformat(pixelformat);
>>    fmt.s_width(w);
>> diff --git a/utils/v4l2-ctl/v4l2-ctl-misc.cpp b/utils/v4l2-ctl/v4l2-ctl-misc.cpp
>> index cb933217..2851886a 100644
>> --- a/utils/v4l2-ctl/v4l2-ctl-misc.cpp
>> +++ b/utils/v4l2-ctl/v4l2-ctl-misc.cpp
>> @@ -320,7 +320,7 @@ void misc_set(cv4l_fd &_fd)
>>        parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
>>        parm.parm.capture.timeperframe.numerator = 1000;
>>        parm.parm.capture.timeperframe.denominator =
>> -            fps * parm.parm.capture.timeperframe.numerator;
>> +            (uint32_t)(fps * parm.parm.capture.timeperframe.numerator);
>> 
>>        if (doioctl(fd, VIDIOC_S_PARM, &parm) == 0) {
>>            struct v4l2_fract *tf = &parm.parm.capture.timeperframe;
>> @@ -338,7 +338,7 @@ void misc_set(cv4l_fd &_fd)
>>        parm.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
>>        parm.parm.output.timeperframe.numerator = 1000;
>>        parm.parm.output.timeperframe.denominator =
>> -            output_fps * parm.parm.output.timeperframe.numerator;
>> +            (uint32_t)(output_fps * parm.parm.output.timeperframe.numerator);
>> 
>>        if (doioctl(fd, VIDIOC_S_PARM, &parm) == 0) {
>>            struct v4l2_fract *tf = &parm.parm.output.timeperframe;
>> diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
>> index 066a336a..6981a3cc 100644
>> --- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
>> +++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
>> @@ -569,7 +569,7 @@ static void print_concise_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt,
>>    if (!skip_ts && (buf.g_flags() & V4L2_BUF_FLAG_TIMESTAMP_MASK) != V4L2_BUF_FLAG_TIMESTAMP_COPY) {
>>        double ts = buf.g_timestamp().tv_sec + buf.g_timestamp().tv_usec / 1000000.0;
>>        fprintf(f, " ts: %.06f", ts);
>> -        if (last_ts)
>> +        if (last_ts <= 0.0)
>>            fprintf(f, " delta: %.03f ms", (ts - last_ts) * 1000.0);
>>        last_ts = ts;
>> 
>> diff --git a/utils/v4l2-ctl/v4l2-ctl-subdev.cpp b/utils/v4l2-ctl/v4l2-ctl-subdev.cpp
>> index 747f1699..f1223084 100644
>> --- a/utils/v4l2-ctl/v4l2-ctl-subdev.cpp
>> +++ b/utils/v4l2-ctl/v4l2-ctl-subdev.cpp
>> @@ -487,7 +487,7 @@ void subdev_set(cv4l_fd &_fd)
>>            exit(1);
>>        }
>>        fival.interval.numerator = 1000;
>> -        fival.interval.denominator = set_fps * fival.interval.numerator;
>> +        fival.interval.denominator = (uint32_t)(set_fps * fival.interval.numerator);
>>        printf("Note: --set-subdev-fps is only for testing.\n"
>>               "Normally media-ctl is used to configure the video pipeline.\n");
>>        printf("ioctl: VIDIOC_SUBDEV_S_FRAME_INTERVAL (pad=%u)\n", fival.pad);
>> 
> 

  reply	other threads:[~2020-04-23  8:44 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 [this message]
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
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=DBFC2366-4C35-43A2-8AC0-7F108FF6255F@gmail.com \
    --to=rosenp@gmail.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    /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.