diff mbox

[FFmpeg-devel,RFC] lavu/opt: Use && instead of * in boolean expression

Message ID 201705050132.45109.cehoyos@ag.or.at
State Accepted
Commit cd01b3cbcf3bc738dd9714fa760f6a8fec0b39d2
Headers show

Commit Message

Carl Eugen Hoyos May 4, 2017, 11:32 p.m. UTC
Hi!

It may be better to disable the warning.

Carl Eugen
From ab94367f502ab00f643a78608593eb9522e5c3be Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <cehoyos@ag.or.at>
Date: Fri, 5 May 2017 01:30:19 +0200
Subject: [PATCH] lavu/opt: Use "&&" instead of "*" in boolean expression.

Fixes the following warning:
libavutil/opt.c:101:47: warning: '*' in boolean context, suggest '&&' instead
---
 libavutil/opt.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Aaron Levinson May 5, 2017, 1:12 a.m. UTC | #1
On 5/4/2017 4:32 PM, Carl Eugen Hoyos wrote:
> Hi!
> 
> It may be better to disable the warning.
> 
> Carl Eugen
>
> -        num = den ? num * intnum / den : (num * intnum ? INFINITY : NAN);
> +        num = den ? num * intnum / den : (num && intnum ? INFINITY : NAN);

In order to preserve the original logic, why not do the following:

+        num = den ? num * intnum / den : (((num * intnum) != 0) ? INFINITY : NAN);

Aaron Levinson
Carl Eugen Hoyos Oct. 7, 2017, 11:14 p.m. UTC | #2
2017-05-05 1:32 GMT+02:00 Carl Eugen Hoyos <cehoyos@ag.or.at>:
> Hi!
>
> It may be better to disable the warning.

Ping, one of the two patches should be applied,
we currently have one vote for each.

Carl Eugen
Ronald S. Bultje Oct. 7, 2017, 11:55 p.m. UTC | #3
Hi,

On Sat, Oct 7, 2017 at 7:14 PM, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:

> 2017-05-05 1:32 GMT+02:00 Carl Eugen Hoyos <cehoyos@ag.or.at>:
> > Hi!
> >
> > It may be better to disable the warning.
>
> Ping, one of the two patches should be applied,
> we currently have one vote for each.
>

I'd go for && since it's boolean. No strong opinion though.

Ronald
Carl Eugen Hoyos Oct. 8, 2017, 9:16 p.m. UTC | #4
2017-10-08 1:55 GMT+02:00 Ronald S. Bultje <rsbultje@gmail.com>:
> Hi,
>
> On Sat, Oct 7, 2017 at 7:14 PM, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>
>> 2017-05-05 1:32 GMT+02:00 Carl Eugen Hoyos <cehoyos@ag.or.at>:
>> > Hi!
>> >
>> > It may be better to disable the warning.
>>
>> Ping, one of the two patches should be applied,
>> we currently have one vote for each.
>>
>
> I'd go for && since it's boolean. No strong opinion though.

Patch applied.

Thank you, Carl Eugen
diff mbox

Patch

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 6f87078..df88663 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -98,7 +98,7 @@  static int write_number(void *obj, const AVOption *o, void *dst, double num, int
 {
     if (o->type != AV_OPT_TYPE_FLAGS &&
         (!den || o->max * den < num * intnum || o->min * den > num * intnum)) {
-        num = den ? num * intnum / den : (num * intnum ? INFINITY : NAN);
+        num = den ? num * intnum / den : (num && intnum ? INFINITY : NAN);
         av_log(obj, AV_LOG_ERROR, "Value %f for parameter '%s' out of range [%g - %g]\n",
                num, o->name, o->min, o->max);
         return AVERROR(ERANGE);