Always perform == or != operation on cmp function result
Although not required to address bad code generation in some versions of gcc 9 and 10, a coding style that requires explicit comparison of the result to zero before use is both clearer and would have avoided the generation of bad code. This change converts all use of cmp function usage from ``` if (strcmp(a, b) || !strcmp(c, d)) ... ``` to ``` if (strcmp(a, b) != 0 || strcmp(c, d)) == 0 ``` for all C library cmp functions and related: - strcmp(), strncmp() - strcasecmp(), strncasecmp() - stricmp(), strnicmp() - memcmp() Change-Id: Ic60c15e1e3a07e4faaf10648eefe3adae2543188
This commit is contained in:

committed by
Jeffrey Altman

parent
02200d55ea
commit
5f63215d0d
@@ -107,7 +107,7 @@ is_filename_cacheish(const char *name)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (strncmp(name, "tkt", sizeof("tkt") - 1))
|
||||
if (strncmp(name, "tkt", sizeof("tkt") - 1) != 0)
|
||||
return 0;
|
||||
for (i = sizeof("tkt") - 1; name[i]; i++)
|
||||
if (ISPATHSEP(name[i]))
|
||||
@@ -318,7 +318,7 @@ get_default_dir(krb5_context context, char **res)
|
||||
|
||||
if ((ret = dcc_get_default_name(context, &s)))
|
||||
return ret;
|
||||
if (strncmp(s, "DIR:", sizeof("DIR:") - 1)) {
|
||||
if (strncmp(s, "DIR:", sizeof("DIR:") - 1) != 0) {
|
||||
*res = s;
|
||||
s = NULL;
|
||||
} else if ((*res = strdup(s + sizeof("DIR:") - 1)) == NULL) {
|
||||
@@ -780,7 +780,7 @@ dcc_get_default_name(krb5_context context, char **str)
|
||||
NULL);
|
||||
|
||||
/* [libdefaults] default_cc_collection is for testing */
|
||||
if (strncmp(def_cc_colname, "DIR:", sizeof("DIR:") - 1))
|
||||
if (strncmp(def_cc_colname, "DIR:", sizeof("DIR:") - 1) != 0)
|
||||
def_cc_colname = KRB5_DEFAULT_CCNAME_DIR;
|
||||
return _krb5_expand_default_cc_name(context, def_cc_colname, str);
|
||||
}
|
||||
|
Reference in New Issue
Block a user