Remove unnecessary BIO dances and use stdout directly.
authortb <tb@openbsd.org>
Fri, 26 Aug 2022 06:28:41 +0000 (06:28 +0000)
committertb <tb@openbsd.org>
Fri, 26 Aug 2022 06:28:41 +0000 (06:28 +0000)
regress/usr.sbin/rpki-client/test-gbr.c
regress/usr.sbin/rpki-client/test-mft.c
regress/usr.sbin/rpki-client/test-roa.c
regress/usr.sbin/rpki-client/test-rsc.c

index 167b971..cd72697 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: test-gbr.c,v 1.9 2022/05/31 21:35:46 tb Exp $ */
+/*     $Id: test-gbr.c,v 1.10 2022/08/26 06:28:41 tb Exp $ */
 /*
  * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
  *
@@ -37,7 +37,6 @@ int
 main(int argc, char *argv[])
 {
        int              c, i, ppem = 0, verb = 0;
-       BIO             *bio_out = NULL;
        X509            *xp = NULL;
        struct gbr      *p;
        unsigned char   *buf;
@@ -55,8 +54,6 @@ main(int argc, char *argv[])
                        if (ppem)
                                break;
                        ppem = 1;
-                       if ((bio_out = BIO_new_fp(stdout, BIO_NOCLOSE)) == NULL)
-                               errx(1, "BIO_new_fp");
                        break;
                case 'v':
                        verb++;
@@ -80,7 +77,7 @@ main(int argc, char *argv[])
                if (verb)
                        gbr_print(xp, p);
                if (ppem) {
-                       if (!PEM_write_bio_X509(bio_out, xp))
+                       if (!PEM_write_X509(stdout, xp))
                                errx(1,
                                    "PEM_write_bio_X509: unable to write cert");
                }
@@ -89,7 +86,6 @@ main(int argc, char *argv[])
                X509_free(xp);
        }
 
-       BIO_free(bio_out);
        EVP_cleanup();
        CRYPTO_cleanup_all_ex_data();
        ERR_free_strings();
index 5c17ad9..1af4c68 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: test-mft.c,v 1.20 2022/05/31 21:35:46 tb Exp $ */
+/*     $Id: test-mft.c,v 1.21 2022/08/26 06:28:41 tb Exp $ */
 /*
  * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
  *
@@ -41,7 +41,6 @@ main(int argc, char *argv[])
 {
        int              c, i, ppem = 0, verb = 0;
        struct mft      *p;
-       BIO             *bio_out = NULL;
        X509            *xp = NULL;
        unsigned char   *buf;
        size_t           len;
@@ -57,8 +56,6 @@ main(int argc, char *argv[])
                        if (ppem)
                                break;
                        ppem = 1;
-                       if ((bio_out = BIO_new_fp(stdout, BIO_NOCLOSE)) == NULL)
-                               errx(1, "BIO_new_fp");
                        break;
                case 'v':
                        verb++;
@@ -82,7 +79,7 @@ main(int argc, char *argv[])
                if (verb)
                        mft_print(xp, p);
                if (ppem) {
-                       if (!PEM_write_bio_X509(bio_out, xp))
+                       if (!PEM_write_X509(stdout, xp))
                                errx(1,
                                    "PEM_write_bio_X509: unable to write cert");
                }
@@ -91,7 +88,6 @@ main(int argc, char *argv[])
                X509_free(xp);
        }
 
-       BIO_free(bio_out);
        EVP_cleanup();
        CRYPTO_cleanup_all_ex_data();
        ERR_free_strings();
index e314cea..da4e874 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: test-roa.c,v 1.17 2022/05/31 21:35:46 tb Exp $ */
+/*     $Id: test-roa.c,v 1.18 2022/08/26 06:28:41 tb Exp $ */
 /*
  * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
  *
@@ -37,7 +37,6 @@ int
 main(int argc, char *argv[])
 {
        int              c, i, ppem = 0, verb = 0;
-       BIO             *bio_out = NULL;
        X509            *xp = NULL;
        struct roa      *p;
        unsigned char   *buf;
@@ -54,8 +53,6 @@ main(int argc, char *argv[])
                        if (ppem)
                                break;
                        ppem = 1;
-                       if ((bio_out = BIO_new_fp(stdout, BIO_NOCLOSE)) == NULL)
-                               errx(1, "BIO_new_fp");
                        break;
                case 'v':
                        verb++;
@@ -79,7 +76,7 @@ main(int argc, char *argv[])
                if (verb)
                        roa_print(xp, p);
                if (ppem) {
-                       if (!PEM_write_bio_X509(bio_out, xp))
+                       if (!PEM_write_X509(stdout, xp))
                                errx(1,
                                    "PEM_write_bio_X509: unable to write cert");
                }
@@ -88,7 +85,6 @@ main(int argc, char *argv[])
                X509_free(xp);
        }
 
-       BIO_free(bio_out);
        EVP_cleanup();
        CRYPTO_cleanup_all_ex_data();
        ERR_free_strings();
index 5876e21..5c5e66c 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: test-rsc.c,v 1.2 2022/05/31 21:35:46 tb Exp $ */
+/*     $Id: test-rsc.c,v 1.3 2022/08/26 06:28:41 tb Exp $ */
 /*
  * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
  *
@@ -41,7 +41,6 @@ main(int argc, char *argv[])
 {
        int              c, i, ppem = 0, verb = 0;
        struct rsc      *p;
-       BIO             *bio_out = NULL;
        X509            *xp = NULL;
        unsigned char   *buf;
        size_t           len;
@@ -57,8 +56,6 @@ main(int argc, char *argv[])
                        if (ppem)
                                break;
                        ppem = 1;
-                       if ((bio_out = BIO_new_fp(stdout, BIO_NOCLOSE)) == NULL)
-                               errx(1, "BIO_new_fp");
                        break;
                case 'v':
                        verb++;
@@ -82,7 +79,7 @@ main(int argc, char *argv[])
                if (verb)
                        rsc_print(xp, p);
                if (ppem) {
-                       if (!PEM_write_bio_X509(bio_out, xp))
+                       if (!PEM_write_X509(stdout, xp))
                                errx(1,
                                    "PEM_write_bio_X509: unable to write cert");
                }
@@ -91,7 +88,6 @@ main(int argc, char *argv[])
                X509_free(xp);
        }
 
-       BIO_free(bio_out);
        EVP_cleanup();
        CRYPTO_cleanup_all_ex_data();
        ERR_free_strings();