aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKelvin Zhang <zhangkelvin@google.com>2021-11-20 21:39:19 -0800
committerGao Xiang <xiang@kernel.org>2021-11-26 00:07:09 +0800
commitdb31e3f8f2deb9f9efdf9f91c2e1f428b184238e (patch)
tree00a28423782b5444d21e89a8cf166dcf284e7c87
parent17eb5c417bd56be4b2f7627c2d6879fbad6a86d6 (diff)
downloaderofs-utils-db31e3f8f2deb9f9efdf9f91c2e1f428b184238e.tar.gz
erofs-utils: mark certain callback function pointers as const
Global variables aren't bad, until you start mutating them in multiple places. Link: https://lore.kernel.org/r/20211121053920.2580751-3-zhangkelvin@google.com Signed-off-by: Kelvin Zhang <zhangkelvin@google.com> Signed-off-by: Gao Xiang <xiang@kernel.org>
-rw-r--r--include/erofs/cache.h8
-rw-r--r--lib/cache.c6
-rw-r--r--lib/compressor.c2
-rw-r--r--lib/compressor.h8
-rw-r--r--lib/compressor_liblzma.c2
-rw-r--r--lib/compressor_lz4.c2
-rw-r--r--lib/compressor_lz4hc.c2
7 files changed, 15 insertions, 15 deletions
diff --git a/include/erofs/cache.h b/include/erofs/cache.h
index b19d54e..87cd51d 100644
--- a/include/erofs/cache.h
+++ b/include/erofs/cache.h
@@ -32,7 +32,7 @@ struct erofs_buffer_head {
struct erofs_buffer_block *block;
erofs_off_t off;
- struct erofs_bhops *op;
+ const struct erofs_bhops *op;
void *fsprivate;
};
@@ -68,9 +68,9 @@ static inline const int get_alignsize(int type, int *type_ret)
return -EINVAL;
}
-extern struct erofs_bhops erofs_drop_directly_bhops;
-extern struct erofs_bhops erofs_skip_write_bhops;
-extern struct erofs_bhops erofs_buf_write_bhops;
+extern const struct erofs_bhops erofs_drop_directly_bhops;
+extern const struct erofs_bhops erofs_skip_write_bhops;
+extern const struct erofs_bhops erofs_buf_write_bhops;
static inline erofs_off_t erofs_btell(struct erofs_buffer_head *bh, bool end)
{
diff --git a/lib/cache.c b/lib/cache.c
index 8016e38..83d591f 100644
--- a/lib/cache.c
+++ b/lib/cache.c
@@ -26,7 +26,7 @@ static bool erofs_bh_flush_drop_directly(struct erofs_buffer_head *bh)
return erofs_bh_flush_generic_end(bh);
}
-struct erofs_bhops erofs_drop_directly_bhops = {
+const struct erofs_bhops erofs_drop_directly_bhops = {
.flush = erofs_bh_flush_drop_directly,
};
@@ -35,7 +35,7 @@ static bool erofs_bh_flush_skip_write(struct erofs_buffer_head *bh)
return false;
}
-struct erofs_bhops erofs_skip_write_bhops = {
+const struct erofs_bhops erofs_skip_write_bhops = {
.flush = erofs_bh_flush_skip_write,
};
@@ -58,7 +58,7 @@ static bool erofs_bh_flush_buf_write(struct erofs_buffer_head *bh)
return erofs_bh_flush_generic_end(bh);
}
-struct erofs_bhops erofs_buf_write_bhops = {
+const struct erofs_bhops erofs_buf_write_bhops = {
.flush = erofs_bh_flush_buf_write,
};
diff --git a/lib/compressor.c b/lib/compressor.c
index ad12cdf..6362825 100644
--- a/lib/compressor.c
+++ b/lib/compressor.c
@@ -10,7 +10,7 @@
#define EROFS_CONFIG_COMPR_DEF_BOUNDARY (128)
-static struct erofs_compressor *compressors[] = {
+static const struct erofs_compressor *compressors[] = {
#if LZ4_ENABLED
#if LZ4HC_ENABLED
&erofs_compressor_lz4hc,
diff --git a/lib/compressor.h b/lib/compressor.h
index aa85ae0..1ea2724 100644
--- a/lib/compressor.h
+++ b/lib/compressor.h
@@ -27,7 +27,7 @@ struct erofs_compressor {
};
struct erofs_compress {
- struct erofs_compressor *alg;
+ const struct erofs_compressor *alg;
unsigned int compress_threshold;
unsigned int compression_level;
@@ -41,9 +41,9 @@ struct erofs_compress {
};
/* list of compression algorithms */
-extern struct erofs_compressor erofs_compressor_lz4;
-extern struct erofs_compressor erofs_compressor_lz4hc;
-extern struct erofs_compressor erofs_compressor_lzma;
+extern const struct erofs_compressor erofs_compressor_lz4;
+extern const struct erofs_compressor erofs_compressor_lz4hc;
+extern const struct erofs_compressor erofs_compressor_lzma;
int erofs_compress_destsize(struct erofs_compress *c,
void *src, unsigned int *srcsize,
diff --git a/lib/compressor_liblzma.c b/lib/compressor_liblzma.c
index 40a05ef..578ba06 100644
--- a/lib/compressor_liblzma.c
+++ b/lib/compressor_liblzma.c
@@ -96,7 +96,7 @@ static int erofs_compressor_liblzma_init(struct erofs_compress *c)
return 0;
}
-struct erofs_compressor erofs_compressor_lzma = {
+const struct erofs_compressor erofs_compressor_lzma = {
.name = "lzma",
.default_level = LZMA_PRESET_DEFAULT,
.best_level = LZMA_PRESET_EXTREME,
diff --git a/lib/compressor_lz4.c b/lib/compressor_lz4.c
index f6832be..fc8c23c 100644
--- a/lib/compressor_lz4.c
+++ b/lib/compressor_lz4.c
@@ -37,7 +37,7 @@ static int compressor_lz4_init(struct erofs_compress *c)
return 0;
}
-struct erofs_compressor erofs_compressor_lz4 = {
+const struct erofs_compressor erofs_compressor_lz4 = {
.name = "lz4",
.default_level = 0,
.best_level = 0,
diff --git a/lib/compressor_lz4hc.c b/lib/compressor_lz4hc.c
index fd801ab..3f68b00 100644
--- a/lib/compressor_lz4hc.c
+++ b/lib/compressor_lz4hc.c
@@ -59,7 +59,7 @@ static int compressor_lz4hc_setlevel(struct erofs_compress *c,
return 0;
}
-struct erofs_compressor erofs_compressor_lz4hc = {
+const struct erofs_compressor erofs_compressor_lz4hc = {
.name = "lz4hc",
.default_level = LZ4HC_CLEVEL_DEFAULT,
.best_level = LZ4HC_CLEVEL_MAX,