git: 146d9da6c2ec - main - tarfs: Silence warnings when no supported compression is enabled.

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Tue, 07 Feb 2023 17:31:35 UTC
The branch main has been updated by des:

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

commit 146d9da6c2ece7edbc3c0c5cca4cf64e2b9e42c9
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2023-02-07 17:27:35 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2023-02-07 17:31:25 +0000

    tarfs: Silence warnings when no supported compression is enabled.
    
    Some of the code in sys/fs/tarfs/tarfs_io.c is not specific to zstd, but is still only used when some form of decompression is enabled.  Put it behind #ifdef TARFS_ZIO to silence warnings.
    
    Sponsored by:   Juniper Networks, Inc.
    Sponsored by:   Klara, Inc.
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D38415
---
 sys/fs/tarfs/tarfs_io.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/sys/fs/tarfs/tarfs_io.c b/sys/fs/tarfs/tarfs_io.c
index 6127299b23c1..c185de8beef1 100644
--- a/sys/fs/tarfs/tarfs_io.c
+++ b/sys/fs/tarfs/tarfs_io.c
@@ -40,6 +40,12 @@
 #include <sys/uio.h>
 #include <sys/vnode.h>
 
+#if defined(ZSTDIO)
+#define TARFS_ZIO 1
+#else
+#undef TARFS_ZIO
+#endif
+
 #ifdef ZSTDIO
 #define ZSTD_STATIC_LINKING_ONLY
 #include <contrib/zstd/lib/zstd.h>
@@ -214,6 +220,7 @@ static ZSTD_customMem tarfs_zstd_mem = {
 };
 #endif
 
+#ifdef TARFS_ZIO
 /*
  * Updates the decompression frame index, recording the current input and
  * output offsets in a new index entry, and growing the index if
@@ -240,6 +247,7 @@ tarfs_zio_update_index(struct tarfs_zio *zio, off_t i, off_t o)
 	MPASS(zio->idx[zio->curidx].i == i);
 	MPASS(zio->idx[zio->curidx].o == o);
 }
+#endif
 
 /*
  * VOP_ACCESS for zio node.
@@ -600,6 +608,7 @@ static struct vop_vector tarfs_znodeops = {
 };
 VFS_VOP_VECTOR_REGISTER(tarfs_znodeops);
 
+#ifdef TARFS_ZIO
 /*
  * Initializes the decompression layer.
  */
@@ -630,6 +639,7 @@ tarfs_zio_init(struct tarfs_mount *tmp, off_t i, off_t o)
 	TARFS_DPF(ZIO, "%s: created zio node\n", __func__);
 	return (zio);
 }
+#endif
 
 /*
  * Initializes the I/O layer, including decompression if the signature of
@@ -640,7 +650,7 @@ int
 tarfs_io_init(struct tarfs_mount *tmp)
 {
 	uint8_t *block;
-#ifdef ZSTDIO
+#ifdef TARFS_ZIO
 	struct tarfs_zio *zio = NULL;
 #endif
 	ssize_t res;
@@ -676,6 +686,7 @@ bad:
 	return (error);
 }
 
+#ifdef TARFS_ZIO
 /*
  * Tears down the decompression layer.
  */
@@ -712,6 +723,7 @@ tarfs_zio_fini(struct tarfs_mount *tmp)
 	tmp->zio = NULL;
 	return (error);
 }
+#endif
 
 /*
  * Tears down the I/O layer, including the decompression layer if
@@ -722,8 +734,10 @@ tarfs_io_fini(struct tarfs_mount *tmp)
 {
 	int error = 0;
 
+#ifdef TARFS_ZIO
 	if (tmp->zio != NULL) {
 		error = tarfs_zio_fini(tmp);
 	}
+#endif
 	return (error);
 }