]> Repos - portaudio/commit
Fix a GCC warning due to unsigned substraction
authorJean-Michaël Celerier <jeanmichael.celerier@gmail.com>
Mon, 21 Dec 2020 18:22:16 +0000 (19:22 +0100)
committerPhil Burk <philburk@mobileer.com>
Sat, 26 Dec 2020 23:41:53 +0000 (15:41 -0800)
commita7bda88e6b628c4c9879cac2b4b4c68da3a1a6b4
tree5873f21b3d1f13bda5cc04b7b8b41f9a3e0a4086
parent63bbb63343876d997a4b3914d21e638f92172979
Fix a GCC warning due to unsigned substraction

Given

    unsigned int reqRate, setRate, deviation;

then

    setRate - reqRate

is also an unsigned int - the code works "by chance" as `abs` casts that to an int which overflows and is technically undefined behaviour, for instance for setRate = 44100 and reqRate = 48000.

Thus cast them to int when computing the absolute value to ensure no UB.
src/hostapi/alsa/pa_linux_alsa.c