Commit 86885c28 authored by Rich Salz's avatar Rich Salz Committed by Rich Salz
Browse files

Use "==0" instead of "!strcmp" etc



For the various string-compare routines (strcmp, strcasecmp, str.*cmp)
use "strcmp()==0" instead of "!strcmp()"

Reviewed-by: default avatarTim Hudson <tjh@openssl.org>
parent dab18ab5
Loading
Loading
Loading
Loading
+11 −10
Original line number Diff line number Diff line
@@ -428,9 +428,10 @@ static char *app_get_pass(char *arg, int keepbio)
    char *tmp, tpass[APP_PASS_LEN];
    static BIO *pwdbio = NULL;
    int i;
    if (!strncmp(arg, "pass:", 5))

    if (strncmp(arg, "pass:", 5) == 0)
        return BUF_strdup(arg + 5);
    if (!strncmp(arg, "env:", 4)) {
    if (strncmp(arg, "env:", 4) == 0) {
        tmp = getenv(arg + 4);
        if (!tmp) {
            BIO_printf(bio_err, "Can't read environment variable %s\n", arg + 4);
@@ -439,7 +440,7 @@ static char *app_get_pass(char *arg, int keepbio)
        return BUF_strdup(tmp);
    }
    if (!keepbio || !pwdbio) {
        if (!strncmp(arg, "file:", 5)) {
        if (strncmp(arg, "file:", 5) == 0) {
            pwdbio = BIO_new_file(arg + 5, "r");
            if (!pwdbio) {
                BIO_printf(bio_err, "Can't open file %s\n", arg + 5);
@@ -454,7 +455,7 @@ static char *app_get_pass(char *arg, int keepbio)
             * on real Windows descriptors, such as those obtained
             * with CreateFile.
             */
        } else if (!strncmp(arg, "fd:", 3)) {
        } else if (strncmp(arg, "fd:", 3) == 0) {
            BIO *btmp;
            i = atoi(arg + 3);
            if (i >= 0)
@@ -469,7 +470,7 @@ static char *app_get_pass(char *arg, int keepbio)
            btmp = BIO_new(BIO_f_buffer());
            pwdbio = BIO_push(btmp, pwdbio);
#endif
        } else if (!strcmp(arg, "stdin")) {
        } else if (strcmp(arg, "stdin") == 0) {
            pwdbio = dup_bio_in();
            if (!pwdbio) {
                BIO_printf(bio_err, "Can't open BIO for stdin\n");
@@ -1083,11 +1084,11 @@ int set_name_ex(unsigned long *flags, const char *arg)

int set_ext_copy(int *copy_type, const char *arg)
{
    if (!strcasecmp(arg, "none"))
    if (strcasecmp(arg, "none") == 0)
        *copy_type = EXT_COPY_NONE;
    else if (!strcasecmp(arg, "copy"))
    else if (strcasecmp(arg, "copy") == 0)
        *copy_type = EXT_COPY_ADD;
    else if (!strcasecmp(arg, "copyall"))
    else if (strcasecmp(arg, "copyall") == 0)
        *copy_type = EXT_COPY_ALL;
    else
        return 0;
@@ -1169,7 +1170,7 @@ static int set_table_opts(unsigned long *flags, const char *arg,
        c = 1;

    for (ptbl = in_tbl; ptbl->name; ptbl++) {
        if (!strcasecmp(arg, ptbl->name)) {
        if (strcasecmp(arg, ptbl->name) == 0) {
            *flags &= ~ptbl->mask;
            if (c)
                *flags |= ptbl->flag;
@@ -2279,7 +2280,7 @@ static const char *get_dp_url(DIST_POINT *dp)
        uri = GENERAL_NAME_get0_value(gen, &gtype);
        if (gtype == GEN_URI && ASN1_STRING_length(uri) > 6) {
            char *uptr = (char *)ASN1_STRING_data(uri);
            if (!strncmp(uptr, "http://", 7))
            if (strncmp(uptr, "http://", 7) == 0)
                return uptr;
        }
    }
+4 −4
Original line number Diff line number Diff line
@@ -569,7 +569,7 @@ end_of_options:
        f = NCONF_get_string(conf, section, UTF8_IN);
        if (!f)
            ERR_clear_error();
        else if (!strcmp(f, "yes"))
        else if (strcmp(f, "yes") == 0)
            chtype = MBSTRING_UTF8;
    }

@@ -841,7 +841,7 @@ end_of_options:
        goto end;
    }

    if (!strcmp(md, "default")) {
    if (strcmp(md, "default") == 0) {
        int def_nid;
        if (EVP_PKEY_get_default_digest_nid(pkey, &def_nid) <= 0) {
            BIO_puts(bio_err, "no default digest\n");
@@ -2419,7 +2419,7 @@ char *make_revocation_str(int rev_type, char *rev_arg)

    case REV_CRL_REASON:
        for (i = 0; i < 8; i++) {
            if (!strcasecmp(rev_arg, crl_reasons[i])) {
            if (strcasecmp(rev_arg, crl_reasons[i]) == 0) {
                reason = crl_reasons[i];
                break;
            }
@@ -2637,7 +2637,7 @@ int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold,
    }
    if (reason_str) {
        for (i = 0; i < NUM_REASONS; i++) {
            if (!strcasecmp(reason_str, crl_reasons[i])) {
            if (strcasecmp(reason_str, crl_reasons[i]) == 0) {
                reason_code = i;
                break;
            }
+2 −2
Original line number Diff line number Diff line
@@ -265,11 +265,11 @@ int ecparam_main(int argc, char **argv)
         * are the same as the curves prime192v1 and prime256v1 defined in
         * X9.62)
         */
        if (!strcmp(curve_name, "secp192r1")) {
        if (strcmp(curve_name, "secp192r1") == 0) {
            BIO_printf(bio_err, "using curve name prime192v1 "
                       "instead of secp192r1\n");
            nid = NID_X9_62_prime192v1;
        } else if (!strcmp(curve_name, "secp256r1")) {
        } else if (strcmp(curve_name, "secp256r1") == 0) {
            BIO_printf(bio_err, "using curve name prime256v1 "
                       "instead of secp256r1\n");
            nid = NID_X9_62_prime256v1;
+1 −1
Original line number Diff line number Diff line
@@ -836,7 +836,7 @@ static int set_pbe(int *ppbe, const char *str)
{
    if (!str)
        return 0;
    if (!strcmp(str, "NONE")) {
    if (strcmp(str, "NONE") == 0) {
        *ppbe = -1;
        return 1;
    }
+3 −3
Original line number Diff line number Diff line
@@ -477,7 +477,7 @@ int req_main(int argc, char **argv)
        p = NCONF_get_string(req_conf, SECTION, UTF8_IN);
        if (!p)
            ERR_clear_error();
        else if (!strcmp(p, "yes"))
        else if (strcmp(p, "yes") == 0)
            chtype = MBSTRING_UTF8;
    }

@@ -904,7 +904,7 @@ static int make_REQ(X509_REQ *req, EVP_PKEY *pkey, char *subj, int multirdn,
    tmp = NCONF_get_string(req_conf, SECTION, PROMPT);
    if (tmp == NULL)
        ERR_clear_error();
    if ((tmp != NULL) && !strcmp(tmp, "no"))
    if ((tmp != NULL) && strcmp(tmp, "no") == 0)
        no_prompt = 1;

    dn_sect = NCONF_get_string(req_conf, SECTION, DISTINGUISHED_NAME);
@@ -1373,7 +1373,7 @@ static EVP_PKEY_CTX *set_keygen_ctx(const char *gstr,
        *pkey_type = EVP_PKEY_RSA;
        keylen = atol(gstr);
        *pkeylen = keylen;
    } else if (!strncmp(gstr, "param:", 6))
    } else if (strncmp(gstr, "param:", 6) == 0)
        paramfile = gstr + 6;
    else {
        const char *p = strchr(gstr, ':');
Loading