diff options
author | Rich Salz <rsalz@akamai.com> | 2015-05-06 14:56:14 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2015-05-06 22:37:53 -0400 |
commit | 86885c289580066792415218754bd935b449f170 (patch) | |
tree | 8cab1bdeb50bfee21ce6677d9150c8d385379321 /crypto | |
parent | dab18ab596acb35eff2545643e25757e4f9cd777 (diff) |
Use "==0" instead of "!strcmp" etc
For the various string-compare routines (strcmp, strcasecmp, str.*cmp)
use "strcmp()==0" instead of "!strcmp()"
Reviewed-by: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'crypto')
36 files changed, 167 insertions, 152 deletions
diff --git a/crypto/asn1/a_strnid.c b/crypto/asn1/a_strnid.c index 071613b89b..92d4134fc5 100644 --- a/crypto/asn1/a_strnid.c +++ b/crypto/asn1/a_strnid.c @@ -100,19 +100,19 @@ int ASN1_STRING_set_default_mask_asc(const char *p) { unsigned long mask; char *end; - if (!strncmp(p, "MASK:", 5)) { + if (strncmp(p, "MASK:", 5) == 0) { if (!p[5]) return 0; mask = strtoul(p + 5, &end, 0); if (*end) return 0; - } else if (!strcmp(p, "nombstr")) + } else if (strcmp(p, "nombstr") == 0) mask = ~((unsigned long)(B_ASN1_BMPSTRING | B_ASN1_UTF8STRING)); - else if (!strcmp(p, "pkix")) + else if (strcmp(p, "pkix") == 0) mask = ~((unsigned long)B_ASN1_T61STRING); - else if (!strcmp(p, "utf8only")) + else if (strcmp(p, "utf8only") == 0) mask = B_ASN1_UTF8STRING; - else if (!strcmp(p, "default")) + else if (strcmp(p, "default") == 0) mask = 0xFFFFFFFFL; else return 0; diff --git a/crypto/asn1/ameth_lib.c b/crypto/asn1/ameth_lib.c index de70f9b4b2..ce4c0dcaf9 100644 --- a/crypto/asn1/ameth_lib.c +++ b/crypto/asn1/ameth_lib.c @@ -221,8 +221,8 @@ const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe, ameth = EVP_PKEY_asn1_get0(i); if (ameth->pkey_flags & ASN1_PKEY_ALIAS) continue; - if (((int)strlen(ameth->pem_str) == len) && - !strncasecmp(ameth->pem_str, str, len)) + if (((int)strlen(ameth->pem_str) == len) + && (strncasecmp(ameth->pem_str, str, len) == 0)) return ameth; } return NULL; diff --git a/crypto/asn1/asn1_gen.c b/crypto/asn1/asn1_gen.c index ab82b52c2b..84d85e63cd 100644 --- a/crypto/asn1/asn1_gen.c +++ b/crypto/asn1/asn1_gen.c @@ -375,13 +375,13 @@ static int asn1_cb(const char *elem, int len, void *bitstr) ASN1err(ASN1_F_ASN1_CB, ASN1_R_UNKNOWN_FORMAT); return -1; } - if (!strncmp(vstart, "ASCII", 5)) + if (strncmp(vstart, "ASCII", 5) == 0) arg->format = ASN1_GEN_FORMAT_ASCII; - else if (!strncmp(vstart, "UTF8", 4)) + else if (strncmp(vstart, "UTF8", 4) == 0) arg->format = ASN1_GEN_FORMAT_UTF8; - else if (!strncmp(vstart, "HEX", 3)) + else if (strncmp(vstart, "HEX", 3) == 0) arg->format = ASN1_GEN_FORMAT_HEX; - else if (!strncmp(vstart, "BITLIST", 7)) + else if (strncmp(vstart, "BITLIST", 7) == 0) arg->format = ASN1_GEN_FORMAT_BITLIST; else { ASN1err(ASN1_F_ASN1_CB, ASN1_R_UNKNOWN_FORMAT); @@ -621,7 +621,7 @@ static int asn1_str2tag(const char *tagstr, int len) tntmp = tnst; for (i = 0; i < OSSL_NELEM(tnst); i++, tntmp++) { - if ((len == tntmp->len) && !strncmp(tntmp->strnam, tagstr, len)) + if ((len == tntmp->len) && (strncmp(tntmp->strnam, tagstr, len) == 0)) return tntmp->tag; } @@ -829,7 +829,7 @@ static int mask_cb(const char *elem, int len, void *arg) int tag; if (elem == NULL) return 0; - if (len == 3 && !strncmp(elem, "DIR", 3)) { + if ((len == 3) && (strncmp(elem, "DIR", 3) == 0)) { *pmask |= B_ASN1_DIRECTORYSTRING; return 1; } diff --git a/crypto/asn1/asn_mime.c b/crypto/asn1/asn_mime.c index da5b417048..2fe6cf987e 100644 --- a/crypto/asn1/asn_mime.c +++ b/crypto/asn1/asn_mime.c @@ -440,7 +440,7 @@ ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it) /* Handle multipart/signed */ - if (!strcmp(hdr->value, "multipart/signed")) { + if (strcmp(hdr->value, "multipart/signed") == 0) { /* Split into two parts */ prm = mime_param_find(hdr, "boundary"); if (!prm || !prm->param_value) { @@ -971,8 +971,9 @@ static int mime_bound_check(char *line, int linelen, char *bound, int blen) if (blen + 2 > linelen) return 0; /* Check for part boundary */ - if (!strncmp(line, "--", 2) && !strncmp(line + 2, bound, blen)) { - if (!strncmp(line + blen + 2, "--", 2)) + if ((strncmp(line, "--", 2) == 0) + && strncmp(line + 2, bound, blen) == 0) { + if (strncmp(line + blen + 2, "--", 2) == 0) return 2; else return 1; diff --git a/crypto/asn1/asn_mstbl.c b/crypto/asn1/asn_mstbl.c index 94ffbd8ada..9b50d14001 100644 --- a/crypto/asn1/asn_mstbl.c +++ b/crypto/asn1/asn_mstbl.c @@ -118,21 +118,21 @@ static int do_tcreate(char *value, char *name) goto err; for (i = 0; i < sk_CONF_VALUE_num(lst); i++) { cnf = sk_CONF_VALUE_value(lst, i); - if (!strcmp(cnf->name, "min")) { + if (strcmp(cnf->name, "min") == 0) { tbl_min = strtoul(cnf->value, &eptr, 0); if (*eptr) goto err; - } else if (!strcmp(cnf->name, "max")) { + } else if (strcmp(cnf->name, "max") == 0) { tbl_max = strtoul(cnf->value, &eptr, 0); if (*eptr) goto err; - } else if (!strcmp(cnf->name, "mask")) { + } else if (strcmp(cnf->name, "mask") == 0) { if (!ASN1_str2mask(cnf->value, &tbl_mask) || !tbl_mask) goto err; - } else if (!strcmp(cnf->name, "flags")) { - if (!strcmp(cnf->value, "nomask")) + } else if (strcmp(cnf->name, "flags") == 0) { + if (strcmp(cnf->value, "nomask") == 0) tbl_flags = STABLE_NO_MASK; - else if (!strcmp(cnf->value, "none")) + else if (strcmp(cnf->value, "none") == 0) tbl_flags = STABLE_FLAGS_CLEAR; else goto err; diff --git a/crypto/asn1/t_bitst.c b/crypto/asn1/t_bitst.c index d5cf3c7732..83c5af7005 100644 --- a/crypto/asn1/t_bitst.c +++ b/crypto/asn1/t_bitst.c @@ -98,7 +98,8 @@ int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl) { BIT_STRING_BITNAME *bnam; for (bnam = tbl; bnam->lname; bnam++) { - if (!strcmp(bnam->sname, name) || !strcmp(bnam->lname, name)) + if ((strcmp(bnam->sname, name) == 0) + || (strcmp(bnam->lname, name) == 0)) return bnam->bitnum; } return -1; diff --git a/crypto/cmac/cm_pmeth.c b/crypto/cmac/cm_pmeth.c index 389ae5da84..013ac57094 100644 --- a/crypto/cmac/cm_pmeth.c +++ b/crypto/cmac/cm_pmeth.c @@ -157,18 +157,18 @@ static int pkey_cmac_ctrl_str(EVP_PKEY_CTX *ctx, if (!value) { return 0; } - if (!strcmp(type, "key")) { + if (strcmp(type, "key") == 0) { void *p = (void *)value; return pkey_cmac_ctrl(ctx, EVP_PKEY_CTRL_SET_MAC_KEY, strlen(p), p); } - if (!strcmp(type, "cipher")) { + if (strcmp(type, "cipher") == 0) { const EVP_CIPHER *c; c = EVP_get_cipherbyname(value); if (!c) return 0; return pkey_cmac_ctrl(ctx, EVP_PKEY_CTRL_CIPHER, -1, (void *)c); } - if (!strcmp(type, "hexkey")) { + if (strcmp(type, "hexkey") == 0) { unsigned char *key; int r; long keylen; diff --git a/crypto/conf/conf_mod.c b/crypto/conf/conf_mod.c index 23d2a58e82..b01319fd39 100644 --- a/crypto/conf/conf_mod.c +++ b/crypto/conf/conf_mod.c @@ -319,7 +319,7 @@ static CONF_MODULE *module_find(char *name) for (i = 0; i < sk_CONF_MODULE_num(supported_modules); i++) { tmod = sk_CONF_MODULE_value(supported_modules, i); - if (!strncmp(tmod->name, name, nchar)) + if (strncmp(tmod->name, name, nchar) == 0) return tmod; } diff --git a/crypto/dh/dh_pmeth.c b/crypto/dh/dh_pmeth.c index 1e1036491e..07d74dc929 100644 --- a/crypto/dh/dh_pmeth.c +++ b/crypto/dh/dh_pmeth.c @@ -259,12 +259,12 @@ static int pkey_dh_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) static int pkey_dh_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) { - if (!strcmp(type, "dh_paramgen_prime_len")) { + if (strcmp(type, "dh_paramgen_prime_len") == 0) { int len; len = atoi(value); return EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, len); } - if (!strcmp(type, "dh_rfc5114")) { + if (strcmp(type, "dh_rfc5114") == 0) { DH_PKEY_CTX *dctx = ctx->data; int len; len = atoi(value); @@ -273,17 +273,17 @@ static int pkey_dh_ctrl_str(EVP_PKEY_CTX *ctx, dctx->rfc5114_param = len; return 1; } - if (!strcmp(type, "dh_paramgen_generator")) { + if (strcmp(type, "dh_paramgen_generator") == 0) { int len; len = atoi(value); return EVP_PKEY_CTX_set_dh_paramgen_generator(ctx, len); } - if (!strcmp(type, "dh_paramgen_subprime_len")) { + if (strcmp(type, "dh_paramgen_subprime_len") == 0) { int len; len = atoi(value); return EVP_PKEY_CTX_set_dh_paramgen_subprime_len(ctx, len); } - if (!strcmp(type, "dh_paramgen_type")) { + if (strcmp(type, "dh_paramgen_type") == 0) { int typ; typ = atoi(value); return EVP_PKEY_CTX_set_dh_paramgen_type(ctx, typ); diff --git a/crypto/dsa/dsa_pmeth.c b/crypto/dsa/dsa_pmeth.c index 853612ac74..1bb3683a92 100644 --- a/crypto/dsa/dsa_pmeth.c +++ b/crypto/dsa/dsa_pmeth.c @@ -218,18 +218,18 @@ static int pkey_dsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) static int pkey_dsa_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) { - if (!strcmp(type, "dsa_paramgen_bits")) { + if (strcmp(type, "dsa_paramgen_bits") == 0) { int nbits; nbits = atoi(value); return EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, nbits); } - if (!strcmp(type, "dsa_paramgen_q_bits")) { + if (strcmp(type, "dsa_paramgen_q_bits") == 0) { int qbits = atoi(value); return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS, qbits, NULL); } - if (!strcmp(type, "dsa_paramgen_md")) { + if (strcmp(type, "dsa_paramgen_md") == 0) { return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, EVP_PKEY_CTRL_DSA_PARAMGEN_MD, 0, (void *)EVP_get_digestbyname(value)); diff --git a/crypto/ec/ec_curve.c b/crypto/ec/ec_curve.c index d0f1fcb2fd..8f9308dbfd 100644 --- a/crypto/ec/ec_curve.c +++ b/crypto/ec/ec_curve.c @@ -3206,7 +3206,7 @@ int EC_curve_nist2nid(const char *name) { size_t i; for (i = 0; i < OSSL_NELEM(nist_curves); i++) { - if (!strcmp(nist_curves[i].name, name)) + if (strcmp(nist_curves[i].name, name) == 0) return nist_curves[i].nid; } return NID_undef; diff --git a/crypto/ec/ec_pmeth.c b/crypto/ec/ec_pmeth.c index 3fbeac5789..37d3efb314 100644 --- a/crypto/ec/ec_pmeth.c +++ b/crypto/ec/ec_pmeth.c @@ -404,7 +404,7 @@ static int pkey_ec_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) static int pkey_ec_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) { - if (!strcmp(type, "ec_paramgen_curve")) { + if (strcmp(type, "ec_paramgen_curve") == 0) { int nid; nid = EC_curve_nist2nid(value); if (nid == NID_undef) @@ -416,23 +416,23 @@ static int pkey_ec_ctrl_str(EVP_PKEY_CTX *ctx, return 0; } return EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid); - } else if (!strcmp(type, "ec_param_enc")) { + } else if (strcmp(type, "ec_param_enc") == 0) { int param_enc; - if (!strcmp(value, "explicit")) + if (strcmp(value, "explicit") == 0) param_enc = 0; - else if (!strcmp(value, "named_curve")) + else if (strcmp(value, "named_curve") == 0) param_enc = OPENSSL_EC_NAMED_CURVE; else return -2; return EVP_PKEY_CTX_set_ec_param_enc(ctx, param_enc); - } else if (!strcmp(type, "ecdh_kdf_md")) { + } else if (strcmp(type, "ecdh_kdf_md") == 0) { const EVP_MD *md; if (!(md = EVP_get_digestbyname(value))) { ECerr(EC_F_PKEY_EC_CTRL_STR, EC_R_INVALID_DIGEST); return 0; } return EVP_PKEY_CTX_set_ecdh_kdf_md(ctx, md); - } else if (!strcmp(type, "ecdh_cofactor_mode")) { + } else if (strcmp(type, "ecdh_cofactor_mode") == 0) { int co_mode; co_mode = atoi(value); return EVP_PKEY_CTX_set_ecdh_cofactor_mode(ctx, co_mode); diff --git a/crypto/engine/eng_cnf.c b/crypto/engine/eng_cnf.c index e84281f22e..ca45af564f 100644 --- a/crypto/engine/eng_cnf.c +++ b/crypto/engine/eng_cnf.c @@ -124,12 +124,12 @@ static int int_engine_configure(char *name, char *value, const CONF *cnf) /* First handle some special pseudo ctrls */ /* Override engine name to use */ - if (!strcmp(ctrlname, "engine_id")) + if (strcmp(ctrlname, "engine_id") == 0) name = ctrlvalue; - else if (!strcmp(ctrlname, "soft_load")) + else if (strcmp(ctrlname, "soft_load") == 0) soft = 1; /* Load a dynamic ENGINE */ - else if (!strcmp(ctrlname, "dynamic_path")) { + else if (strcmp(ctrlname, "dynamic_path") == 0) { e = ENGINE_by_id("dynamic"); if (!e) goto err; @@ -159,9 +159,9 @@ static int int_engine_configure(char *name, char *value, const CONF *cnf) * Allow "EMPTY" to mean no value: this allows a valid "value" to * be passed to ctrls of type NO_INPUT */ - if (!strcmp(ctrlvalue, "EMPTY")) + if (strcmp(ctrlvalue, "EMPTY") == 0) ctrlvalue = NULL; - if (!strcmp(ctrlname, "init")) { + if (strcmp(ctrlname, "init") == 0) { if (!NCONF_get_number_e(cnf, value, "init", &do_init)) goto err; if (do_init == 1) { @@ -172,7 +172,7 @@ static int int_engine_configure(char *name, char *value, const CONF *cnf) ENGINE_R_INVALID_INIT_VALUE); goto err; } - } else if (!strcmp(ctrlname, "default_algorithms")) { + } else if (strcmp(ctrlname, "default_algorithms") == 0) { if (!ENGINE_set_default_string(e, ctrlvalue)) goto err; } else if (!ENGINE_ctrl_cmd_string(e, ctrlname, ctrlvalue, 0)) diff --git a/crypto/engine/eng_fat.c b/crypto/engine/eng_fat.c index af353bd936..e0c8f96f69 100644 --- a/crypto/engine/eng_fat.c +++ b/crypto/engine/eng_fat.c @@ -103,29 +103,29 @@ static int int_def_cb(const char *alg, int len, void *arg) unsigned int *pflags = arg; if (alg == NULL) return 0; - if (!strncmp(alg, "ALL", len)) + if (strncmp(alg, "ALL", len) == 0) *pflags |= ENGINE_METHOD_ALL; - else if (!strncmp(alg, "RSA", len)) + else if (strncmp(alg, "RSA", len) == 0) *pflags |= ENGINE_METHOD_RSA; - else if (!strncmp(alg, "DSA", len)) + else if (strncmp(alg, "DSA", len) == 0) *pflags |= ENGINE_METHOD_DSA; - else if (!strncmp(alg, "ECDH", len)) + else if (strncmp(alg, "ECDH", len) == 0) *pflags |= ENGINE_METHOD_ECDH; - else if (!strncmp(alg, "ECDSA", len)) + else if (strncmp(alg, "ECDSA", len) == 0) *pflags |= ENGINE_METHOD_ECDSA; - else if (!strncmp(alg, "DH", len)) + else if (strncmp(alg, "DH", len) == 0) *pflags |= ENGINE_METHOD_DH; - else if (!strncmp(alg, "RAND", len)) + else if (strncmp(alg, "RAND", len) == 0) *pflags |= ENGINE_METHOD_RAND; - else if (!strncmp(alg, "CIPHERS", len)) + else if (strncmp(alg, "CIPHERS", len) == 0) *pflags |= ENGINE_METHOD_CIPHERS; - else if (!strncmp(alg, "DIGESTS", len)) + else if (strncmp(alg, "DIGESTS", len) == 0) *pflags |= ENGINE_METHOD_DIGESTS; - else if (!strncmp(alg, "PKEY", len)) + else if (strncmp(alg, "PKEY", len) == 0) *pflags |= ENGINE_METHOD_PKEY_METHS | ENGINE_METHOD_PKEY_ASN1_METHS; - else if (!strncmp(alg, "PKEY_CRYPTO", len)) + else if (strncmp(alg, "PKEY_CRYPTO", len) == 0) *pflags |= ENGINE_METHOD_PKEY_METHS; - else if (!strncmp(alg, "PKEY_ASN1", len)) + else if (strncmp(alg, "PKEY_ASN1", len) == 0) *pflags |= ENGINE_METHOD_PKEY_ASN1_METHS; else return 0; diff --git a/crypto/engine/eng_openssl.c b/crypto/engine/eng_openssl.c index e9bdd01043..560c9b3c93 100644 --- a/crypto/engine/eng_openssl.c +++ b/crypto/engine/eng_openssl.c @@ -556,11 +556,11 @@ static int ossl_hmac_ctrl_str(EVP_PKEY_CTX *ctx, if (!value) { return 0; } - if (!strcmp(type, "key")) { + if (strcmp(type, "key") == 0) { void *p = (void *)value; return ossl_hmac_ctrl(ctx, EVP_PKEY_CTRL_SET_MAC_KEY, -1, p); } - if (!strcmp(type, "hexkey")) { + if (strcmp(type, "hexkey") == 0) { unsigned char *key; int r; long keylen; diff --git a/crypto/engine/tb_asnmth.c b/crypto/engine/tb_asnmth.c index 4685fcf2ad..407023fdf6 100644 --- a/crypto/engine/tb_asnmth.c +++ b/crypto/engine/tb_asnmth.c @@ -191,8 +191,8 @@ const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e, nidcount = e->pkey_asn1_meths(e, NULL, &nids, 0); for (i = 0; i < nidcount; i++) { e->pkey_asn1_meths(e, &ameth, NULL, nids[i]); - if (((int)strlen(ameth->pem_str) == len) && - !strncasecmp(ameth->pem_str, str, len)) + if (((int)strlen(ameth->pem_str) == len) + && strncasecmp(ameth->pem_str, str, len) == 0) return ameth; } return NULL; @@ -215,8 +215,8 @@ static void look_str_cb(int nid, STACK_OF(ENGINE) *sk, ENGINE *def, void *arg) ENGINE *e = sk_ENGINE_value(sk, i); EVP_PKEY_ASN1_METHOD *ameth; e->pkey_asn1_meths(e, &ameth, NULL, nid); - if (((int)strlen(ameth->pem_str) == lk->len) && - !strncasecmp(ameth->pem_str, lk->str, lk->len)) { + if (((int)strlen(ameth->pem_str) == lk->len) + && strncasecmp(ameth->pem_str, lk->str, lk->len) == 0) { lk->e = e; lk->ameth = ameth; return; diff --git a/crypto/evp/evp_cnf.c b/crypto/evp/evp_cnf.c index 31a90543c5..3073091cbe 100644 --- a/crypto/evp/evp_cnf.c +++ b/crypto/evp/evp_cnf.c @@ -81,7 +81,7 @@ static int alg_module_init(CONF_IMODULE *md, const CONF *cnf) } for (i = 0; i < sk_CONF_VALUE_num(sktmp); i++) { oval = sk_CONF_VALUE_value(sktmp, i); - if (!strcmp(oval->name, "fips_mode")) { + if (strcmp(oval->name, "fips_mode") == 0) { int m; if (!X509V3_get_value_bool(oval, &m)) { EVPerr(EVP_F_ALG_MODULE_INIT, EVP_R_INVALID_FIPS_MODE); diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c index eeee53a2ef..10d974633d 100644 --- a/crypto/evp/pmeth_lib.c +++ b/crypto/evp/pmeth_lib.c @@ -414,7 +414,7 @@ int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, EVPerr(EVP_F_EVP_PKEY_CTX_CTRL_STR, EVP_R_COMMAND_NOT_SUPPORTED); return -2; } - if (!strcmp(name, "digest")) { + if (strcmp(name, "digest") == 0) { const EVP_MD *md; if (!value || !(md = EVP_get_digestbyname(value))) { EVPerr(EVP_F_EVP_PKEY_CTX_CTRL_STR, EVP_R_INVALID_DIGEST); diff --git a/crypto/hmac/hm_pmeth.c b/crypto/hmac/hm_pmeth.c index 845a72b2eb..2980254402 100644 --- a/crypto/hmac/hm_pmeth.c +++ b/crypto/hmac/hm_pmeth.c @@ -206,11 +206,11 @@ static int pkey_hmac_ctrl_str(EVP_PKEY_CTX *ctx, if (!value) { return 0; } - if (!strcmp(type, "key")) { + if (strcmp(type, "key") == 0) { void *p = (void *)value; return pkey_hmac_ctrl(ctx, EVP_PKEY_CTRL_SET_MAC_KEY, -1, p); } - if (!strcmp(type, "hexkey")) { + if (strcmp(type, "hexkey") == 0) { unsigned char *key; int r; long keylen; diff --git a/crypto/ocsp/ocsp_lib.c b/crypto/ocsp/ocsp_lib.c index 62a5812b56..1f383f6c83 100644 --- a/crypto/ocsp/ocsp_lib.c +++ b/crypto/ocsp/ocsp_lib.c @@ -196,10 +196,10 @@ int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath, *(p++) = '\0'; - if (!strcmp(buf, "http")) { + if (strcmp(buf, "http") == 0) { *pssl = 0; port = "80"; - } else if (!strcmp(buf, "https")) { + } else if (strcmp(buf, "https") == 0) { *pssl = 1; port = "443"; } else diff --git a/crypto/pem/pem_lib.c b/crypto/pem/pem_lib.c index bb3b31ebbf..088288d0d4 100644 --- a/crypto/pem/pem_lib.c +++ b/crypto/pem/pem_lib.c @@ -182,17 +182,17 @@ void *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x, static int check_pem(const char *nm, const char *name) { /* Normal matching nm and name */ - if (!strcmp(nm, name)) + if (strcmp(nm, name) == 0) return 1; /* Make PEM_STRING_EVP_PKEY match any private key */ - if (!strcmp(name, PEM_STRING_EVP_PKEY)) { + if (strcmp(name, PEM_STRING_EVP_PKEY) == 0) { int slen; const EVP_PKEY_ASN1_METHOD *ameth; - if (!strcmp(nm, PEM_STRING_PKCS8)) + if (strcmp(nm, PEM_STRING_PKCS8) == 0) return 1; - if (!strcmp(nm, PEM_STRING_PKCS8INF)) + if (strcmp(nm, PEM_STRING_PKCS8INF) == 0) return 1; slen = pem_check_suffix(nm, "PRIVATE KEY"); if (slen > 0) { @@ -207,7 +207,7 @@ static int check_pem(const char *nm, const char *name) return 0; } - if (!strcmp(name, PEM_STRING_PARAMETERS)) { + if (strcmp(name, PEM_STRING_PARAMETERS) == 0) { int slen; const EVP_PKEY_ASN1_METHOD *ameth; slen = pem_check_suffix(nm, "PARAMETERS"); @@ -230,41 +230,45 @@ static int check_pem(const char *nm, const char *name) return 0; } /* If reading DH parameters handle X9.42 DH format too */ - if (!strcmp(nm, PEM_STRING_DHXPARAMS) && - !strcmp(name, PEM_STRING_DHPARAMS)) + if (strcmp(nm, PEM_STRING_DHXPARAMS) == 0 + && strcmp(name, PEM_STRING_DHPARAMS) == 0) return 1; /* Permit older strings */ - if (!strcmp(nm, PEM_STRING_X509_OLD) && !strcmp(name, PEM_STRING_X509)) + if (strcmp(nm, PEM_STRING_X509_OLD) == 0 + && strcmp(name, PEM_STRING_X509) == 0) return 1; - if (!strcmp(nm, PEM_STRING_X509_REQ_OLD) && - !strcmp(name, PEM_STRING_X509_REQ)) + if (strcmp(nm, PEM_STRING_X509_REQ_OLD) == 0 + && strcmp(name, PEM_STRING_X509_REQ) == 0) return 1; /* Allow normal certs to be read as trusted certs */ - if (!strcmp(nm, PEM_STRING_X509) && - !strcmp(name, PEM_STRING_X509_TRUSTED)) + if (strcmp(nm, PEM_STRING_X509) == 0 + && strcmp(name, PEM_STRING_X509_TRUSTED) == 0) return 1; - if (!strcmp(nm, PEM_STRING_X509_OLD) && - !strcmp(name, PEM_STRING_X509_TRUSTED)) + if (strcmp(nm, PEM_STRING_X509_OLD) == 0 + && strcmp(name, PEM_STRING_X509_TRUSTED) == 0) return 1; /* Some CAs use PKCS#7 with CERTIFICATE headers */ - if (!strcmp(nm, PEM_STRING_X509) && !strcmp(name, PEM_STRING_PKCS7)) + if (strcmp(nm, PEM_STRING_X509) == 0 + && strcmp(name, PEM_STRING_PKCS7) == 0) return 1; - if (!strcmp(nm, PEM_STRING_PKCS7_SIGNED) && - !strcmp(name, PEM_STRING_PKCS7)) + if (strcmp(nm, PEM_STRING_PKCS7_SIGNED) == 0 + && strcmp(name, PEM_STRING_PKCS7) == 0) return 1; #ifndef OPENSSL_NO_CMS - if (!strcmp(nm, PEM_STRING_X509) && !strcmp(name, PEM_STRING_CMS)) + if (strcmp(nm, PEM_STRING_X509) == 0 + && strcmp(name, PEM_STRING_CMS) == 0) return 1; /* Allow CMS to be read from PKCS#7 headers */ - if (!strcmp(nm, PEM_STRING_PKCS7) && !strcmp(name, PEM_STRING_CMS)) + if (strcmp(nm, PEM_STRING_PKCS7) == 0 + && strcmp(name, PEM_STRING_CMS) == 0) return 1; #endif diff --git a/crypto/pem/pem_pkey.c b/crypto/pem/pem_pkey.c index 0a110e15b9..a7dd27f061 100644 --- a/crypto/pem/pem_pkey.c +++ b/crypto/pem/pem_pkey.c @@ -257,7 +257,7 @@ DH *PEM_read_bio_DHparams(BIO *bp, DH **x, pem_password_cb *cb, void *u) return NULL; |