[Libreoffice] [PATCH] Simple fix for fontconfig.cxx to review (from cppcheck report)

julien2412 serval2412 at yahoo.fr
Sat Jan 14 07:00:31 PST 2012


cppcheck reported this : 
196	duplicateExpression	style	Same expression on both sides of '-'

   class SortFont : public ::std::binary_function< const FcPattern*, const
FcPattern*, bool >
        bool operator()(const FcPattern *a, const FcPattern *b)
            int comp = compareFontNames(a, b);
            if (comp != 0)
                return comp < 0;

            int nVersionA=0, nVersionB=0;

            bool bHaveA = FcPatternGetInteger(a, FC_FONTVERSION, 0,
&nVersionA) == FcResultMatch;
            bool bHaveB = FcPatternGetInteger(b, FC_FONTVERSION, 0,
&nVersionB) == FcResultMatch;

            if (bHaveA && bHaveB)
                return nVersionA > nVersionB;

 196:           return bHaveA - bHaveA;<--- Same expression on both sides of

If we follow the same logic as the function compareFontNames defined some
lines above in the same file :
    int compareFontNames(const FcPattern *a, const FcPattern *b)
        FcChar8 *pNameA=NULL, *pNameB=NULL;

        bool bHaveA = FcPatternGetString(a, FC_FAMILY, 0, &pNameA) ==
        bool bHaveB = FcPatternGetString(b, FC_FAMILY, 0, &pNameB) ==

        if (bHaveA && bHaveB)
            return strcmp((const char*)pNameA, (const char*)pNameB);

        return bHaveA - bHaveB;

it seems it should be :
return bHaveA - bHaveB;

Any idea ?

(If it's ok, I can commit and push the fix on master)


View this message in context: http://nabble.documentfoundation.org/PATCH-Simple-fix-for-fontconfig-cxx-to-review-from-cppcheck-report-tp3659060p3659060.html
Sent from the Dev mailing list archive at Nabble.com.

More information about the LibreOffice mailing list