Commit 1efd98f9 authored by Paul Yang's avatar Paul Yang Committed by Matt Caswell
Browse files

Fix coding style

parent 09ddb878
Loading
Loading
Loading
Loading
+32 −56
Original line number Diff line number Diff line
@@ -45,33 +45,24 @@ static int test_x509_check_cert_pkey(const char *c, const char *k,
    if (strcmp(e, "ok") == 0) {
        expected = 1;
    } else if (strcmp(e, "failed") == 0) {
        expected = 2;
        expected = 0;
    } else {
        TEST_error("invalid 'expected'");
        goto failed;
    }

    /* process private key */
    bio = BIO_new_file(k, "r");
    if (bio == NULL) {
        TEST_error("create BIO for private key failed");
    if (!TEST_ptr(bio = BIO_new_file(k, "r")))
        goto failed;
    }

    pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL);
    if (pkey == NULL) {
        TEST_error("read PEM private key failed");
    if (!TEST_ptr(pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL)))
        goto failed;
    }

    BIO_free(bio);

    /* process cert or cert request, use the same local var */
    bio = BIO_new_file(c, "r");
    if (bio == NULL) {
        TEST_error("create BIO for cert or cert req failed");
    if (!TEST_ptr(bio = BIO_new_file(c, "r")))
        goto failed;
    }

    switch (type) {
    case 1:
@@ -97,33 +88,18 @@ static int test_x509_check_cert_pkey(const char *c, const char *k,
        break;
    }

    if (expected == 1) {
        /* expected == 1 means we expect an "ok" */
        if (!TEST_int_eq(result, 1)) {
            TEST_error("check private key: expected: 1, got: %d", result);
            goto failed;
        }
    } else {
        if (!TEST_int_eq(result, 0)) {
            TEST_error("check private key: expected: 0, got: %d", result);
    if (!TEST_int_eq(result, expected)) {
        TEST_error("check private key: expected: %d, got: %d", expected, result);
        goto failed;
    }
    }

out:
    if (bio)
    ret = 1;
failed:
    BIO_free(bio);
    if (x509)
    X509_free(x509);
    if (x509_req)
    X509_REQ_free(x509_req);
    if (pkey)
    EVP_PKEY_free(pkey);
    return ret;

failed:
    ret = 1;
    goto out;
}

int test_main(int argc, char **argv)
@@ -134,5 +110,5 @@ int test_main(int argc, char **argv)
        return 1;
    }

    return test_x509_check_cert_pkey(argv[1], argv[2], argv[3], argv[4]);
    return !test_x509_check_cert_pkey(argv[1], argv[2], argv[3], argv[4]);
}