memtest86plus / memtest86plus

Official repo for Memtest86+
https://memtest.org
GNU General Public License v2.0
973 stars 72 forks source link

Useless comparison in system/hwquirks.c #361

Open debrouxl opened 7 months ago

debrouxl commented 7 months ago

When trying to build memtest86+ with clang in order to determine the availability of strongly typed enums in C (they work with Clang 12-17 in -std=c11 mode, FTR), an interesting warning was present in the compiler output:

../system/hwquirks.c:85:46: warning: overlapping comparisons always evaluate to false [-Wtautological-overlap-compare]
    if (cpuid_info.version.extendedModel < 6 && cpuid_info.version.extendedModel > 7)   // Not Rev G
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

The && should certainly be a ||.

Also, the comparison just below the aforementioned one:

    if (cpuid_info.version.extendedModel == 6 && cpuid_info.version.extendedModel < 9)  // Not Desktop
        return;

looks odd ?

x86fr commented 7 months ago

Yes. Rev G are extModel = 6 or 7 so operator should be ||. Second line should be extModel == 6 and Model < 9 to skip PGA Mobile on Socket S1. Will correct that for 7.01.