diff mbox series

[FFmpeg-devel,4/4] avcodec/magicyuvenc: Use more correct cast in compare function

Message ID 20201008191842.385813-4-andreas.rheinhardt@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/4] avcodec/mjpegdec: Remove use_static from build_vlc() | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Oct. 8, 2020, 7:18 p.m. UTC
There is no need to cast const away (even if it was harmless) and to
copy the object at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/magicyuvenc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Paul B Mahol Oct. 8, 2020, 8:02 p.m. UTC | #1
On Thu, Oct 08, 2020 at 09:18:42PM +0200, Andreas Rheinhardt wrote:
> There is no need to cast const away (even if it was harmless) and to
> copy the object at all.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavcodec/magicyuvenc.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

lgtm
diff mbox series

Patch

diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c
index 1b8bb53114..440b3514c3 100644
--- a/libavcodec/magicyuvenc.c
+++ b/libavcodec/magicyuvenc.c
@@ -280,9 +280,9 @@  typedef struct PackageMergerList {
 
 static int compare_by_prob(const void *a, const void *b)
 {
-    PTable a_val = *(PTable *)a;
-    PTable b_val = *(PTable *)b;
-    return a_val.prob - b_val.prob;
+    const PTable *a2 = a;
+    const PTable *b2 = b;
+    return a2->prob - b2->prob;
 }
 
 static void magy_huffman_compute_bits(PTable *prob_table, HuffEntry *distincts,