diff mbox

[FFmpeg-devel] lavc/utvideo: Use "&" instead of "&&" in expressions with "~"

Message ID CAB0OVGqwRk4+x6LcQf+aR=+3-8G0uJ40nBAFXZd5oBQ_yGvQdw@mail.gmail.com
State Superseded
Headers show

Commit Message

Carl Eugen Hoyos Oct. 7, 2017, 11:05 p.m. UTC
Hi!

Attached patch silences two warnings when compiling with gcc-7:
libavcodec/utvideodec.c:242:107: warning: ‘~’ on a boolean expression
[-Wbool-operation]
     const int cmask = c->interlaced ? ~(1 + 2 * (!plane_no &&
c->avctx->pix_fmt == AV_PIX_FMT_YUV420P)) : ~(!plane_no &&
c->avctx->pix_fmt == AV_PIX_FMT_YUV420P);

Please comment, Carl Eugen

Comments

Ronald S. Bultje Oct. 7, 2017, 11:58 p.m. UTC | #1
Hi,

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

> Hi!
>
> Attached patch silences two warnings when compiling with gcc-7:
> libavcodec/utvideodec.c:242:107: warning: ‘~’ on a boolean expression
> [-Wbool-operation]
>      const int cmask = c->interlaced ? ~(1 + 2 * (!plane_no &&
> c->avctx->pix_fmt == AV_PIX_FMT_YUV420P)) : ~(!plane_no &&
> c->avctx->pix_fmt == AV_PIX_FMT_YUV420P);
>
> Please comment, Carl Eugen
>

I personally think the warning is dumb... But I guess that's just me.

(I understand why it exists for javascript developers dipping their toes in
My First Pony C. But we're not these kind of developers.)

Ronald
Derek Buitenhuis Oct. 8, 2017, 3:36 p.m. UTC | #2
On 10/8/2017 12:58 AM, Ronald S. Bultje wrote:
> I personally think the warning is dumb... But I guess that's just me.

I agree; I don't even count it as a valid warning. Maybe disable it?

That's only my opinion, of course.

- Derek
Carl Eugen Hoyos Oct. 8, 2017, 9:09 p.m. UTC | #3
2017-10-08 1:58 GMT+02:00 Ronald S. Bultje <rsbultje@gmail.com>:
> Hi,
>
> On Sat, Oct 7, 2017 at 7:05 PM, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>
>> Hi!
>>
>> Attached patch silences two warnings when compiling with gcc-7:
>> libavcodec/utvideodec.c:242:107: warning: ‘~’ on a boolean expression
>> [-Wbool-operation]
>>      const int cmask = c->interlaced ? ~(1 + 2 * (!plane_no &&
>> c->avctx->pix_fmt == AV_PIX_FMT_YUV420P)) : ~(!plane_no &&
>> c->avctx->pix_fmt == AV_PIX_FMT_YUV420P);

> I personally think the warning is dumb...

I am less convinced but disabled the warning.

Thank you both, Carl Eugen
diff mbox

Patch

From 5fa1b443d1603d7d2d4860d43a7aefa7196c3cdb Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Sun, 8 Oct 2017 01:02:01 +0200
Subject: [PATCH] lavc/utvideo: Use "&" instead of "&&" in expressions with
 "~".

Silences two warnings with gcc-7:
warning: "~" on a boolean expression
---
 libavcodec/utvideodec.c |    2 +-
 libavcodec/utvideoenc.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/utvideodec.c b/libavcodec/utvideodec.c
index 40c1277..101b3a6 100644
--- a/libavcodec/utvideodec.c
+++ b/libavcodec/utvideodec.c
@@ -239,7 +239,7 @@  static int decode_plane(UtvideoContext *c, int plane_no,
     VLC vlc;
     GetBitContext gb;
     int prev, fsym;
-    const int cmask = c->interlaced ? ~(1 + 2 * (!plane_no && c->avctx->pix_fmt == AV_PIX_FMT_YUV420P)) : ~(!plane_no && c->avctx->pix_fmt == AV_PIX_FMT_YUV420P);
+    const int cmask = c->interlaced ? ~(1 + 2 * (!plane_no && c->avctx->pix_fmt == AV_PIX_FMT_YUV420P)) : ~(!plane_no & c->avctx->pix_fmt == AV_PIX_FMT_YUV420P);
 
     if (build_huff(src, &vlc, &fsym)) {
         av_log(c->avctx, AV_LOG_ERROR, "Cannot build Huffman codes\n");
diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c
index 840742c..96607d8 100644
--- a/libavcodec/utvideoenc.c
+++ b/libavcodec/utvideoenc.c
@@ -409,7 +409,7 @@  static int encode_plane(AVCodecContext *avctx, uint8_t *src,
     HuffEntry he[256];
 
     uint32_t offset = 0, slice_len = 0;
-    const int cmask = ~(!plane_no && avctx->pix_fmt == AV_PIX_FMT_YUV420P);
+    const int cmask = ~(!plane_no & avctx->pix_fmt == AV_PIX_FMT_YUV420P);
     int      i, sstart, send = 0;
     int      symbol;
     int      ret;
-- 
1.7.10.4