diff mbox

[FFmpeg-devel] lavfi/af_aiir, af_afir: Remove a variable that is always -1

Message ID CAB0OVGpsvYje2bwLh3PZYL2WjN8AudA3dL2m2b_MViVqb33BGw@mail.gmail.com
State Accepted
Headers show

Commit Message

Carl Eugen Hoyos July 19, 2018, 12:35 a.m. UTC
Hi!

Two very similar conditions in af_aiir.c and af_afir.c can never be true afaict.

Please review, Carl Eugen

Comments

Paul B Mahol July 19, 2018, 7:36 p.m. UTC | #1
On 7/19/18, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> Hi!
>
> Two very similar conditions in af_aiir.c and af_afir.c can never be true
> afaict.
>
> Please review, Carl Eugen
>

Should be ok if properly tested.
Carl Eugen Hoyos July 19, 2018, 9:14 p.m. UTC | #2
2018-07-19 21:36 GMT+02:00, Paul B Mahol <onemda@gmail.com>:
> On 7/19/18, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:

>> Two very similar conditions in af_aiir.c and af_afir.c can
>> never be true afaict.
>>
>> Please review, Carl Eugen
>>
>
> Should be ok if properly tested.

Tested and applied.

Thank you, Carl Eugen
diff mbox

Patch

From 6c83ac40c1c83987fe4bc408e5408166815b88d8 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Thu, 19 Jul 2018 02:28:25 +0200
Subject: [PATCH] lavfi/af_afir,af_aiir: Remove a variable that is always -1.

Fixes two warnings:
libavfilter/af_afir.c:194:45: warning: assuming signed overflow does not occur when assuming that (X - c) > X is always false [-Wstrict-overflow]
     int dx = FFABS(x1-x0), sx = x0 < x1 ? 1 : -1;
                                 ~~~~~~~~~~~~^~~~
libavfilter/af_aiir.c:689:45: warning: assuming signed overflow does not occur when assuming that (X - c) > X is always false [-Wstrict-overflow]
     int dx = FFABS(x1-x0), sx = x0 < x1 ? 1 : -1;
                                 ~~~~~~~~~~~~^~~~
---
 libavfilter/af_afir.c |    4 ++--
 libavfilter/af_aiir.c |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c
index 75de147..a4a7160 100644
--- a/libavfilter/af_afir.c
+++ b/libavfilter/af_afir.c
@@ -191,7 +191,7 @@  static void drawtext(AVFrame *pic, int x, int y, const char *txt, uint32_t color
 
 static void draw_line(AVFrame *out, int x0, int y0, int x1, int y1, uint32_t color)
 {
-    int dx = FFABS(x1-x0), sx = x0 < x1 ? 1 : -1;
+    int dx = FFABS(x1-x0);
     int dy = FFABS(y1-y0), sy = y0 < y1 ? 1 : -1;
     int err = (dx>dy ? dx : -dy) / 2, e2;
 
@@ -205,7 +205,7 @@  static void draw_line(AVFrame *out, int x0, int y0, int x1, int y1, uint32_t col
 
         if (e2 >-dx) {
             err -= dy;
-            x0 += sx;
+            x0--;
         }
 
         if (e2 < dy) {
diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c
index 65c8201..9a4769c 100644
--- a/libavfilter/af_aiir.c
+++ b/libavfilter/af_aiir.c
@@ -686,7 +686,7 @@  static void drawtext(AVFrame *pic, int x, int y, const char *txt, uint32_t color
 
 static void draw_line(AVFrame *out, int x0, int y0, int x1, int y1, uint32_t color)
 {
-    int dx = FFABS(x1-x0), sx = x0 < x1 ? 1 : -1;
+    int dx = FFABS(x1-x0);
     int dy = FFABS(y1-y0), sy = y0 < y1 ? 1 : -1;
     int err = (dx>dy ? dx : -dy) / 2, e2;
 
@@ -700,7 +700,7 @@  static void draw_line(AVFrame *out, int x0, int y0, int x1, int y1, uint32_t col
 
         if (e2 >-dx) {
             err -= dy;
-            x0 += sx;
+            x0--;
         }
 
         if (e2 < dy) {
-- 
1.7.10.4