swh / ladspa

The SWH Plugins package for the LADSPA plugin system
http://plugin.org.uk/
GNU General Public License v2.0
229 stars 52 forks source link

sifter_1210.xml:38: bad test ? #49

Closed dcb314 closed 7 years ago

dcb314 commented 7 years ago

sifter_1210.xml:38]: (style) Array index 'left' is used before limits check.

Source code is

    while (array[left] <= pivot && left < right) {

Suggest sanity check array index before use, not after.

Also, if the partition element is the first element, the code runs badly (Order N^2).

Looking at the bigger picture, sorting is a standard library algorithm. Suggest use standard library in preference to writing your own (buggy) code.

swh commented 7 years ago

It's not a limit check, I don't think it can lead to reading an uninitialised value, but I don't really have the time to check. Reversing the order of the tests would reduce performance, though that may be unimportant in 2017.

The libc qsort cannot be used here, as there's no realtime safe guarantees.