git: a2eaf1cdd625 - stable/14 - dumpon: fix set but not used variable

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Thu, 25 Apr 2024 13:20:57 UTC
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=a2eaf1cdd62576be5e29155e4f10eeb4593e2992

commit a2eaf1cdd62576be5e29155e4f10eeb4593e2992
Author:     inkeliz <inkeliz@inkeliz.com>
AuthorDate: 2024-04-17 21:22:44 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-04-25 13:20:18 +0000

    dumpon: fix set but not used variable
    
    Signed-off-by: inkeliz <inkeliz@inkeliz.com>
    
    Reviewed by:    markj
    MFC after:      1 week
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/1178
    
    (cherry picked from commit 464b1ab216d5f78054626524addf99f5c622da96)
---
 sbin/dumpon/dumpon.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/sbin/dumpon/dumpon.c b/sbin/dumpon/dumpon.c
index 81144e33bc71..eb890e250fbb 100644
--- a/sbin/dumpon/dumpon.c
+++ b/sbin/dumpon/dumpon.c
@@ -475,20 +475,23 @@ main(int argc, char *argv[])
 	struct diocskerneldump_arg ndconf, *kdap;
 	struct addrinfo hints, *res;
 	const char *dev, *pubkeyfile, *server, *client, *gateway;
-	int ch, error, fd, cipher;
+	int ch, error, fd;
 	bool gzip, list, netdump, zstd, insert, rflag;
 	uint8_t ins_idx;
+#ifdef HAVE_CRYPTO
+	int cipher = KERNELDUMP_ENC_NONE;
+#endif
 
 	gzip = list = netdump = zstd = insert = rflag = false;
 	kdap = NULL;
 	pubkeyfile = NULL;
 	server = client = gateway = NULL;
 	ins_idx = KDA_APPEND;
-	cipher = KERNELDUMP_ENC_NONE;
 
 	while ((ch = getopt(argc, argv, "C:c:g:i:k:lrs:vZz")) != -1)
 		switch ((char)ch) {
 		case 'C':
+#ifdef HAVE_CRYPTO
 			if (strcasecmp(optarg, "chacha") == 0 ||
 			    strcasecmp(optarg, "chacha20") == 0)
 				cipher = KERNELDUMP_ENC_CHACHA20;
@@ -499,6 +502,11 @@ main(int argc, char *argv[])
 				errx(EX_USAGE, "Unrecognized cipher algorithm "
 				    "'%s'", optarg);
 			break;
+#else
+			errx(EX_USAGE,
+			    "Built without crypto support, -C is unhandled.");
+			break;
+#endif
 		case 'c':
 			client = optarg;
 			break;