Make a few purpose things const
authortb <tb@openbsd.org>
Tue, 21 Nov 2023 17:56:19 +0000 (17:56 +0000)
committertb <tb@openbsd.org>
Tue, 21 Nov 2023 17:56:19 +0000 (17:56 +0000)
This should allow us to constify a sizable table in libcrypto in an
upcoming bump.

usr.bin/openssl/apps.c
usr.bin/openssl/cms.c
usr.bin/openssl/verify.c
usr.bin/openssl/x509.c

index 70857e0..6ffbe6f 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: apps.c,v 1.66 2023/07/23 11:39:29 tb Exp $ */
+/* $OpenBSD: apps.c,v 1.67 2023/11/21 17:56:19 tb Exp $ */
 /*
  * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
  *
@@ -1716,7 +1716,7 @@ args_verify(char ***pargs, int *pargc, int *badarg, BIO *err,
                }
                (*pargs)++;
        } else if (strcmp(arg, "-purpose") == 0) {
-               X509_PURPOSE *xptmp;
+               const X509_PURPOSE *xptmp;
                if (!argn)
                        *badarg = 1;
                else {
index 121a413..b94e146 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: cms.c,v 1.34 2023/04/14 15:27:13 tb Exp $ */
+/* $OpenBSD: cms.c,v 1.35 2023/11/21 17:56:19 tb Exp $ */
 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
  * project.
  */
@@ -1140,7 +1140,7 @@ cms_usage(void)
 
        fprintf(stderr, "\nValid purposes:\n\n");
        for (i = 0; i < X509_PURPOSE_get_count(); i++) {
-               X509_PURPOSE *ptmp = X509_PURPOSE_get0(i);
+               const X509_PURPOSE *ptmp = X509_PURPOSE_get0(i);
                fprintf(stderr, "  %-18s%s\n", X509_PURPOSE_get0_sname(ptmp),
                    X509_PURPOSE_get0_name(ptmp));
        }
index b4e0f33..a87d5d4 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: verify.c,v 1.17 2023/04/14 15:27:13 tb Exp $ */
+/* $OpenBSD: verify.c,v 1.18 2023/11/21 17:56:19 tb Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -251,7 +251,7 @@ verify_usage(void)
 
        fprintf(stderr, "\nValid purposes:\n\n");
        for (i = 0; i < X509_PURPOSE_get_count(); i++) {
-               X509_PURPOSE *ptmp = X509_PURPOSE_get0(i);
+               const X509_PURPOSE *ptmp = X509_PURPOSE_get0(i);
                fprintf(stderr, "  %-18s%s\n", X509_PURPOSE_get0_sname(ptmp),
                    X509_PURPOSE_get0_name(ptmp));
        }
index 8e8a9f2..7f60110 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: x509.c,v 1.34 2023/11/13 11:50:36 tb Exp $ */
+/* $OpenBSD: x509.c,v 1.35 2023/11/21 17:56:19 tb Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -86,7 +86,7 @@ static int x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest,
     X509 *x, X509 *xca, EVP_PKEY *pkey, STACK_OF(OPENSSL_STRING) *sigopts,
     char *serial, int create, int days, int clrext, CONF *conf, char *section,
     ASN1_INTEGER *sno);
-static int purpose_print(BIO *bio, X509 *cert, X509_PURPOSE *pt);
+static int purpose_print(BIO *bio, X509 *cert, const X509_PURPOSE *pt);
 
 static struct {
        char *alias;
@@ -1022,7 +1022,7 @@ x509_main(int argc, char **argv)
                        }
 #endif
                        else if (cfg.pprint == i) {
-                               X509_PURPOSE *ptmp;
+                               const X509_PURPOSE *ptmp;
                                int j;
 
                                BIO_printf(STDout, "Certificate purposes:\n");
@@ -1534,10 +1534,10 @@ sign(X509 *x, EVP_PKEY *pkey, int days, int clrext, const EVP_MD *digest,
 }
 
 static int
-purpose_print(BIO *bio, X509 *cert, X509_PURPOSE *pt)
+purpose_print(BIO *bio, X509 *cert, const X509_PURPOSE *pt)
 {
        int id, i, idret;
-       char *pname;
+       const char *pname;
 
        id = X509_PURPOSE_get_id(pt);
        pname = X509_PURPOSE_get0_name(pt);