[FFmpeg-devel] [PATCH] all: simplify qsort comparators, and add const-correctness
Mark Harris
mark.hsj at gmail.com
Sun Oct 25 02:38:16 CET 2015
>>
>> static int compare_int64(const void *a, const void *b)
>> {
>> - int64_t va = *(int64_t *)a, vb = *(int64_t *)b;
>> - return va < vb ? -1 : va > vb ? +1 : 0;
>> + return *(const int64_t *)a - *(const int64_t *)b;
>> }
>>
>
> What if the result doesn't fit in int? The input is not int.
Even for int this transformation is not valid assuming that the full
range of int is possible. For example if *a = INT_MAX and *b = -1
then *a - *b = INT_MAX+1 which is negative when cast to an int.
More information about the ffmpeg-devel
mailing list