[FFmpeg-devel] [PATCH 3/3] avutil/tree: add additional const qualifier to the comparator

Michael Niedermayer michael at niedermayer.cc
Sun Oct 25 17:35:51 CET 2015


On Sat, Oct 24, 2015 at 09:03:03PM -0400, Ganesh Ajjanagadde wrote:
> On Sat, Oct 24, 2015 at 7:17 PM, Henrik Gramner <henrik at gramner.com> wrote:
> > On Sun, Oct 25, 2015 at 12:02 AM, Ganesh Ajjanagadde
> > <gajjanagadde at gmail.com> wrote:
> >> -static int cmp(void *key, const void *node)
> >> +static int cmp(const void *key, const void *node)
> >>  {
> >>      return (*(int64_t *) key) - ((const CacheEntry *) node)->logical_pos;
> >>  }
> >
> >> -int ff_nut_sp_pos_cmp(const Syncpoint *a, const Syncpoint *b)
> >> +int ff_nut_sp_pos_cmp(const void *a, const void *b)
> >>  {
> >> -    return ((a->pos - b->pos) >> 32) - ((b->pos - a->pos) >> 32);
> >> +    Syncpoint va = *(Syncpoint *)a, vb = *(Syncpoint *)b;
> >> +    return ((va.pos - vb.pos) >> 32) - ((vb.pos - va.pos) >> 32);
> >>  }
> >
> >> -int ff_nut_sp_pts_cmp(const Syncpoint *a, const Syncpoint *b)
> >> +int ff_nut_sp_pts_cmp(const void *a, const void *b)
> >>  {
> >> -    return ((a->ts - b->ts) >> 32) - ((b->ts - a->ts) >> 32);
> >> +    Syncpoint va = *(Syncpoint *)a, vb = *(Syncpoint *)b;
> >> +    return ((va.ts - vb.ts) >> 32) - ((vb.ts - va.ts) >> 32);
> >>  }
> >
> > Casts discards const qualifiers.
> 
> Good catch, changed. There is some more such constness being discarded
> in comparators, and some needlessly complex comparator logic in some
> places. Submitted a patch.
> 
> >
> > Furthermore, why are you changing the two last functions to copy the
> > entire struct to a temporary local copy?
> 
> Sorry, forgot they were structs.
> Fixed all, pushed. Thanks.

i think this results in some new warnings for the tree test build

libavutil/tree.c: In function ‘main’:
libavutil/tree.c:238:9: warning: passing argument 3 of ‘av_tree_insert’ from incompatible pointer type [enabled by default]
libavutil/tree.c:59:7: note: expected ‘int (*)(const void *, const void *)’ but argument is of type ‘int (*)(void *, const void *)’
libavutil/tree.c:244:13: warning: passing argument 3 of ‘av_tree_insert’ from incompatible pointer type [enabled by default]
libavutil/tree.c:59:7: note: expected ‘int (*)(const void *, const void *)’ but argument is of type ‘int (*)(void *, const void *)’
libavutil/tree.c:245:13: warning: passing argument 3 of ‘av_tree_find’ from incompatible pointer type [enabled by default]


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151025/7c584a8e/attachment.sig>


More information about the ffmpeg-devel mailing list