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
@@ -426,7 +426,7 @@ gen_priv_key(krb5_context context,
|
||||
krb5_error_code ret;
|
||||
|
||||
_krb5_debug(context, 1, "kx509: gen priv key");
|
||||
if (strcmp(gen_type, "rsa")) {
|
||||
if (strcmp(gen_type, "rsa") != 0) {
|
||||
krb5_set_error_message(context, ENOTSUP, "Key type %s is not "
|
||||
"supported for kx509; only \"rsa\" is "
|
||||
"supported for kx509 at this time",
|
||||
@@ -967,7 +967,7 @@ rd_kx509_resp(krb5_context context,
|
||||
*chain = NULL;
|
||||
|
||||
/* Strip `version_2_0' prefix */
|
||||
if (rep->length < hdr_len || memcmp(rep->data, version_2_0, hdr_len)) {
|
||||
if (rep->length < hdr_len || memcmp(rep->data, version_2_0, hdr_len) != 0) {
|
||||
krb5_set_error_message(context, ENOTSUP,
|
||||
"KDC does not support kx509 protocol");
|
||||
return ENOTSUP; /* XXX */
|
||||
|
Reference in New Issue
Block a user