From 026344e8cce470217f2ac21bb9f8e3d189397bb7 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 13 May 2024 11:36:54 +0200 Subject: [PATCH] cleanup: local const arrays No need for relocation entries for locally used arrays. --- device_mapper/libdm-config.c | 7 +++---- device_mapper/libdm-deptree.c | 6 +++--- device_mapper/libdm-report.c | 2 +- lib/activate/activate.c | 4 ++-- libdm/libdm-config.c | 7 +++---- libdm/libdm-deptree.c | 6 +++--- libdm/libdm-report.c | 2 +- libdm/libdm-stats.c | 14 +++++++------- 8 files changed, 23 insertions(+), 25 deletions(-) diff --git a/device_mapper/libdm-config.c b/device_mapper/libdm-config.c index a4c79c20d..ec7ebca85 100644 --- a/device_mapper/libdm-config.c +++ b/device_mapper/libdm-config.c @@ -74,8 +74,6 @@ static struct dm_config_node *_create_node(struct dm_pool *mem); static char *_dup_tok(struct parser *p); static char *_dup_token(struct dm_pool *mem, const char *b, const char *e); -static const int _sep = '/'; - #define MAX_INDENT 32 #define match(t) do {\ @@ -526,17 +524,18 @@ static struct dm_config_node *_find_or_make_node(struct dm_pool *mem, const char *path, int no_dup_node_check) { + const int sep = '/'; const char *e; struct dm_config_node *cn = parent ? parent->child : NULL; struct dm_config_node *cn_found = NULL; while (cn || mem) { /* trim any leading slashes */ - while (*path && (*path == _sep)) + while (*path && (*path == sep)) path++; /* find the end of this segment */ - for (e = path; *e && (*e != _sep); e++) ; + for (e = path; *e && (*e != sep); e++) ; /* hunt for the node */ cn_found = NULL; diff --git a/device_mapper/libdm-deptree.c b/device_mapper/libdm-deptree.c index 5e0ddba5e..3140bbbf2 100644 --- a/device_mapper/libdm-deptree.c +++ b/device_mapper/libdm-deptree.c @@ -3864,7 +3864,7 @@ int dm_tree_node_add_cache_target(struct dm_tree_node *node, { struct dm_config_node *cn; struct load_segment *seg; - static const uint64_t _modemask = + const uint64_t modemask = DM_CACHE_FEATURE_PASSTHROUGH | DM_CACHE_FEATURE_WRITETHROUGH | DM_CACHE_FEATURE_WRITEBACK; @@ -3876,12 +3876,12 @@ int dm_tree_node_add_cache_target(struct dm_tree_node *node, return 0; } - switch (feature_flags & _modemask) { + switch (feature_flags & modemask) { case DM_CACHE_FEATURE_PASSTHROUGH: case DM_CACHE_FEATURE_WRITEBACK: if (strcmp(policy_name, "cleaner") == 0) { /* Enforce writethrough mode for cleaner policy */ - feature_flags = ~_modemask; + feature_flags = ~modemask; feature_flags |= DM_CACHE_FEATURE_WRITETHROUGH; } /* Fall through */ diff --git a/device_mapper/libdm-report.c b/device_mapper/libdm-report.c index 0506ba47f..6d861fdb4 100644 --- a/device_mapper/libdm-report.c +++ b/device_mapper/libdm-report.c @@ -2502,7 +2502,7 @@ float dm_percent_to_float(dm_percent_t percent) float dm_percent_to_round_float(dm_percent_t percent, unsigned digits) { - static const float power10[] = { + const float power10[] = { 1.f, .1f, .01f, .001f, .0001f, .00001f, .000001f, .0000001f, .00000001f, .000000001f, .0000000001f diff --git a/lib/activate/activate.c b/lib/activate/activate.c index d9f39d1f5..1737f6cb9 100644 --- a/lib/activate/activate.c +++ b/lib/activate/activate.c @@ -1792,7 +1792,7 @@ int monitor_dev_for_events(struct cmd_context *cmd, const struct logical_volume struct lv_segment *log_seg; int (*monitor_fn) (struct lv_segment *s, int e); uint32_t s; - static const struct lv_activate_opts zlaopts = { 0 }; + const struct lv_activate_opts zlaopts = { 0 }; struct lv_activate_opts mirr_laopts = { .origin_only = 1 }; struct lvinfo info; const char *dso = NULL; @@ -2458,7 +2458,7 @@ static int _lv_has_open_snapshots(const struct logical_volume *lv) int lv_deactivate(struct cmd_context *cmd, const char *lvid_s, const struct logical_volume *lv) { struct lvinfo info; - static const struct lv_activate_opts laopts = { .skip_in_use = 1 }; + const struct lv_activate_opts laopts = { .skip_in_use = 1 }; struct dm_list *snh; int r = 0; unsigned tmp_state; diff --git a/libdm/libdm-config.c b/libdm/libdm-config.c index 6edeee2d1..6383d9004 100644 --- a/libdm/libdm-config.c +++ b/libdm/libdm-config.c @@ -74,8 +74,6 @@ static struct dm_config_node *_create_node(struct dm_pool *mem); static char *_dup_tok(struct parser *p); static char *_dup_token(struct dm_pool *mem, const char *b, const char *e); -static const int _sep = '/'; - #define MAX_INDENT 32 #define match(t) do {\ @@ -526,17 +524,18 @@ static struct dm_config_node *_find_or_make_node(struct dm_pool *mem, const char *path, int no_dup_node_check) { + const int sep = '/'; const char *e; struct dm_config_node *cn = parent ? parent->child : NULL; struct dm_config_node *cn_found = NULL; while (cn || mem) { /* trim any leading slashes */ - while (*path && (*path == _sep)) + while (*path && (*path == sep)) path++; /* find the end of this segment */ - for (e = path; *e && (*e != _sep); e++) ; + for (e = path; *e && (*e != sep); e++) ; /* hunt for the node */ cn_found = NULL; diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c index ca526e6f6..1d33a6ef6 100644 --- a/libdm/libdm-deptree.c +++ b/libdm/libdm-deptree.c @@ -3405,7 +3405,7 @@ DM_EXPORT_NEW_SYMBOL(int, dm_tree_node_add_cache_target, 1_02_138) { struct dm_config_node *cn; struct load_segment *seg; - static const uint64_t _modemask = + const uint64_t _modemask = DM_CACHE_FEATURE_PASSTHROUGH | DM_CACHE_FEATURE_WRITETHROUGH | DM_CACHE_FEATURE_WRITEBACK; @@ -3977,12 +3977,12 @@ int dm_tree_node_add_cache_target_base(struct dm_tree_node *node, uint32_t data_block_size) { /* Old version supported only these FEATURE bits, others were ignored so masked them */ - static const uint64_t _mask = + const uint64_t mask = DM_CACHE_FEATURE_WRITEBACK | DM_CACHE_FEATURE_WRITETHROUGH | DM_CACHE_FEATURE_PASSTHROUGH; - return dm_tree_node_add_cache_target(node, size, feature_flags & _mask, + return dm_tree_node_add_cache_target(node, size, feature_flags & mask, metadata_uuid, data_uuid, origin_uuid, policy_name, policy_settings, data_block_size); } diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c index 78d08b234..f4d7ee32b 100644 --- a/libdm/libdm-report.c +++ b/libdm/libdm-report.c @@ -2500,7 +2500,7 @@ float dm_percent_to_float(dm_percent_t percent) float dm_percent_to_round_float(dm_percent_t percent, unsigned digits) { - static const float power10[] = { + const float power10[] = { 1.f, .1f, .01f, .001f, .0001f, .00001f, .000001f, .0000001f, .00000001f, .000000001f, .0000000001f diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c index 703b58a4b..a861d2998 100644 --- a/libdm/libdm-stats.c +++ b/libdm/libdm-stats.c @@ -833,7 +833,7 @@ static int _stats_parse_histogram_spec(struct dm_stats *dms, struct dm_stats_region *region, const char *histogram) { - static const char _valid_chars[] = "0123456789,"; + const char valid_chars[] = "0123456789,"; uint64_t scale = region->timescale, this_val = 0; struct dm_pool *mem = dms->hist_mem; struct dm_histogram_bin cur; @@ -866,7 +866,7 @@ static int _stats_parse_histogram_spec(struct dm_stats *dms, c = histogram; do { - for (v = _valid_chars; *v; v++) + for (v = valid_chars; *v; v++) if (*c == *v) break; if (!*v) { @@ -1202,7 +1202,7 @@ static int _stats_parse_histogram(struct dm_pool *mem, char *hist_str, struct dm_histogram **histogram, struct dm_stats_region *region) { - static const char _valid_chars[] = "0123456789:"; + const char valid_chars[] = "0123456789:"; struct dm_histogram *bounds = region->bounds; struct dm_histogram hist = { .nr_bins = region->bounds->nr_bins @@ -1223,7 +1223,7 @@ static int _stats_parse_histogram(struct dm_pool *mem, char *hist_str, do { memset(&cur, 0, sizeof(cur)); - for (v = _valid_chars; *v; v++) + for (v = valid_chars; *v; v++) if (*c == *v) break; if (!*v) @@ -3596,7 +3596,7 @@ static struct dm_histogram *_alloc_dm_histogram(int nr_bins) */ struct dm_histogram *dm_histogram_bounds_from_string(const char *bounds_str) { - static const char _valid_chars[] = "0123456789,muns"; + const char valid_chars[] = "0123456789,muns"; uint64_t this_val = 0, mult = 1; const char *c, *v, *val_start; struct dm_histogram_bin *cur; @@ -3621,7 +3621,7 @@ struct dm_histogram *dm_histogram_bounds_from_string(const char *bounds_str) cur = dmh->bins; do { - for (v = _valid_chars; *v; v++) + for (v = valid_chars; *v; v++) if (*c == *v) break; @@ -5008,7 +5008,7 @@ static const char _filemapd_mode_names[][8] = { dm_filemapd_mode_t dm_filemapd_mode_from_string(const char *mode_str) { - static const dm_filemapd_mode_t _mode[] = { + const dm_filemapd_mode_t _mode[] = { DM_FILEMAPD_FOLLOW_INODE, DM_FILEMAPD_FOLLOW_PATH };