On Wed, May 26, 2021 at 09:17:18AM -0500, Pierre-Louis Bossart wrote: > > > On 5/26/21 2:40 AM, Takashi Iwai wrote: > > On Tue, 25 May 2021 21:32:27 +0200, > > Pierre-Louis Bossart wrote: > > > > > > Hi Takashi, > > > Sparse reports a lot of new issues in our last checks with more options: > > > > > > export ARCH=x86_64 CF="-Wsparse-error -Wsparse-all > > > -Wno-bitwise-pointer -Wno-pointer-arith -Wno-typesign -Wnoshadow > > > -Wno-sizeof-bool" > > > make -k sound/ C=2 > > > > > > most are linked to the __user and pcm_format_t restricted types, but I > > > found the simpler ones below which are useless comparisons. I can send > > > a patch for the last but not sure how to address the first two. > > > > > > Thanks for your feedback > > > -Pierre > > > > > > sound/core/info.c:95:38: error: self-comparison always evaluates to false > > > > > > if (pos < 0 || (long) pos != pos || (ssize_t) count < 0) > > > return false; > > > > > > not sure what the second comparison is meant to check? > > > > As Dan suggested, it's a check only for 32bit architecture for a 64bit > > value. > > Isn't there a better way to check this? > I suppose you could do: if (pos > ULONG_MAX) { I think Smatch used to complain about code like that but it doesn't now? Really the correct thing is to fix the static checker because the code is fine. To me as a human reader it was pretty obvious that the code was deliberately checking that the value was still the same after a cast. regards, dan carpenter