mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
const: use arrays of strings
Such string is stored directly in '.rodata' section.
This commit is contained in:
parent
efe2005022
commit
0bcf2c6514
@ -35,7 +35,7 @@
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
static const char *_config_source_names[] = {
|
||||
static const char _config_source_names[][24] = {
|
||||
[CONFIG_UNDEFINED] = "undefined",
|
||||
[CONFIG_FILE] = "file",
|
||||
[CONFIG_MERGED_FILES] = "merged files",
|
||||
|
@ -20,7 +20,7 @@
|
||||
#endif
|
||||
|
||||
struct ext_registry_item {
|
||||
const char *name;
|
||||
const char name[16];
|
||||
struct dev_ext *(* dev_ext_get) (struct device *dev);
|
||||
int (*dev_ext_release) (struct device *dev);
|
||||
};
|
||||
@ -90,7 +90,7 @@ static int _dev_ext_release_udev(struct device *dev)
|
||||
#endif
|
||||
}
|
||||
|
||||
static struct ext_registry_item _ext_registry[DEV_EXT_NUM] = {
|
||||
static const struct ext_registry_item _ext_registry[DEV_EXT_NUM] = {
|
||||
EXT_REGISTER(DEV_EXT_NONE, none),
|
||||
EXT_REGISTER(DEV_EXT_UDEV, udev)
|
||||
};
|
||||
|
@ -118,10 +118,10 @@ lock_type_t get_lock_type_from_string(const char *str)
|
||||
return LOCK_TYPE_INVALID;
|
||||
}
|
||||
|
||||
static const char *_percent_types[7] = { "NONE", "VG", "FREE", "LV", "PVS", "ORIGIN" };
|
||||
|
||||
const char *get_percent_string(percent_type_t def)
|
||||
{
|
||||
static const char _percent_types[][8] = { "NONE", "VG", "FREE", "LV", "PVS", "ORIGIN" };
|
||||
|
||||
return _percent_types[def];
|
||||
}
|
||||
|
||||
|
@ -224,14 +224,13 @@ static int _out_with_comment_raw(struct formatter *f,
|
||||
*/
|
||||
static int _sectors_to_units(uint64_t sectors, char *buffer, size_t s)
|
||||
{
|
||||
static const char *_units[] = {
|
||||
static const char _units[][16] = {
|
||||
"Kilobytes",
|
||||
"Megabytes",
|
||||
"Gigabytes",
|
||||
"Terabytes",
|
||||
"Petabytes",
|
||||
"Exabytes",
|
||||
NULL
|
||||
};
|
||||
|
||||
int i;
|
||||
@ -240,7 +239,7 @@ static int _sectors_to_units(uint64_t sectors, char *buffer, size_t s)
|
||||
/* to convert to K */
|
||||
d /= 2.0;
|
||||
|
||||
for (i = 0; (d > 1024.0) && _units[i]; i++)
|
||||
for (i = 0; (d > 1024.0) && i < DM_ARRAY_SIZE(_units); ++i)
|
||||
d /= 1024.0;
|
||||
|
||||
return dm_snprintf(buffer, s, "# %g %s", d, _units[i]) > 0;
|
||||
|
@ -145,7 +145,7 @@ enum {
|
||||
LV_TYPE_INTEGRITYORIGIN
|
||||
};
|
||||
|
||||
static const char *_lv_type_names[] = {
|
||||
static const char _lv_type_names[][24] = {
|
||||
[LV_TYPE_UNKNOWN] = "unknown",
|
||||
[LV_TYPE_NONE] = "none",
|
||||
[LV_TYPE_PUBLIC] = "public",
|
||||
|
@ -29,7 +29,7 @@ static volatile sig_atomic_t _handler_installed = 0;
|
||||
|
||||
struct ar_sigs {
|
||||
int sig;
|
||||
const char *name;
|
||||
const char name[8];
|
||||
int oldmasked[MAX_SIGINTS];
|
||||
struct sigaction oldhandler[MAX_SIGINTS];
|
||||
};
|
||||
|
@ -89,7 +89,7 @@ static int _priority;
|
||||
static int _default_priority;
|
||||
|
||||
/* list of maps, that are unconditionaly ignored */
|
||||
static const char * const _ignore_maps[] = {
|
||||
static const char _ignore_maps[][16] = {
|
||||
"[vdso]",
|
||||
"[vsyscall]",
|
||||
"[vectors]",
|
||||
|
@ -252,7 +252,7 @@ static const struct time_prop _time_props[] = {
|
||||
#define TIME_REG_PLURAL_S 0x00000001 /* also recognize plural form with "s" suffix */
|
||||
|
||||
struct time_reg {
|
||||
const char *name;
|
||||
const char name[16];
|
||||
const struct time_prop *prop;
|
||||
uint32_t reg_flags;
|
||||
};
|
||||
@ -355,7 +355,6 @@ static const struct time_reg _time_reg[] = {
|
||||
{"Nov", TIME_PROP(TIME_MONTH_NOVEMBER), 0},
|
||||
{"December", TIME_PROP(TIME_MONTH_DECEMBER), 0},
|
||||
{"Dec", TIME_PROP(TIME_MONTH_DECEMBER), 0},
|
||||
{NULL, TIME_PROP(TIME_NULL), 0},
|
||||
};
|
||||
|
||||
struct time_item {
|
||||
@ -588,7 +587,7 @@ static int _match_time_str(struct dm_list *ti_list, struct time_item *ti)
|
||||
|
||||
ti->prop = TIME_PROP(TIME_NULL);
|
||||
|
||||
for (i = 0; _time_reg[i].name; i++) {
|
||||
for (i = 0; i < DM_ARRAY_SIZE(_time_reg); ++i) {
|
||||
reg_len = strlen(_time_reg[i].name);
|
||||
if ((ti->len != reg_len) &&
|
||||
!((_time_reg[i].reg_flags & TIME_REG_PLURAL_S) &&
|
||||
|
Loading…
Reference in New Issue
Block a user