1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-30 17:18:21 +03:00

cleanup: local const arrays

No need for relocation entries for locally used arrays.
This commit is contained in:
Zdenek Kabelac 2024-05-13 11:36:54 +02:00
parent ee3be2807f
commit 026344e8cc
8 changed files with 23 additions and 25 deletions

View File

@ -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;

View File

@ -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 */

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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

View File

@ -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
};