From e6f46fafe7ad1e59be256887999823ec4973d1e0 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 3 May 2024 12:50:18 +0200 Subject: [PATCH] const: use arrays of strings 2 Next set of changes. --- daemons/dmeventd/dmeventd.c | 2 +- daemons/lvmlockd/lvmlockd-core.c | 2 +- device_mapper/libdm-report.c | 2 +- lib/commands/toolcontext.c | 14 +++++++------- lib/device/device_id.c | 6 +++--- lib/filters/filter-usable.c | 2 +- lib/label/hints.c | 6 +++--- libdm/libdm-report.c | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c index f2d6ff393..43e8e724f 100644 --- a/daemons/dmeventd/dmeventd.c +++ b/daemons/dmeventd/dmeventd.c @@ -2017,7 +2017,7 @@ static void _daemonize(void) static int _reinstate_registrations(struct dm_event_fifos *fifos) { static const char _failed_parsing_msg[] = "Failed to parse existing event registration.\n"; - static const char *_delim = " "; + static const char _delim[] = " "; struct dm_event_daemon_message msg = { 0 }; char *endp, *dso_name, *dev_name, *mask, *timeout; unsigned long mask_value, timeout_value; diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c index 73dfa17b3..327311b2f 100644 --- a/daemons/lvmlockd/lvmlockd-core.c +++ b/daemons/lvmlockd/lvmlockd-core.c @@ -140,7 +140,7 @@ static int str_to_mode(const char *str); * the act is passed back to the client_thread to be returned to the client. */ -static const char *lvmlockd_protocol = "lvmlockd"; +static const char lvmlockd_protocol[] = "lvmlockd"; static const int lvmlockd_protocol_version = 1; static int daemon_quit; static int adopt_opt; diff --git a/device_mapper/libdm-report.c b/device_mapper/libdm-report.c index 4973acd45..f9db92abd 100644 --- a/device_mapper/libdm-report.c +++ b/device_mapper/libdm-report.c @@ -2842,7 +2842,7 @@ struct time_value { time_t t2; }; -static const char *_out_of_range_msg = "Field selection value %s out of supported range for field %s."; +static const char _out_of_range_msg[] = "Field selection value %s out of supported range for field %s."; /* * Standard formatted date and time - ISO8601. diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c index f2f451b3e..2ad04d7ec 100644 --- a/lib/commands/toolcontext.c +++ b/lib/commands/toolcontext.c @@ -506,10 +506,10 @@ static int _check_config(struct cmd_context *cmd) static const char *_set_time_format(struct cmd_context *cmd) { /* Compared to strftime, we do not allow "newline" character - the %n in format. */ - static const char *allowed_format_chars = "aAbBcCdDeFGghHIjklmMpPrRsStTuUVwWxXyYzZ%"; - static const char *allowed_alternative_format_chars_e = "cCxXyY"; - static const char *allowed_alternative_format_chars_o = "deHImMSuUVwWy"; - static const char *chars_to_check; + static const char _allowed_format_chars[] = "aAbBcCdDeFGghHIjklmMpPrRsStTuUVwWxXyYzZ%"; + static const char _allowed_alternative_format_chars_e[] = "cCxXyY"; + static const char _allowed_alternative_format_chars_o[] = "deHImMSuUVwWy"; + const char *chars_to_check; const char *tf = find_config_tree_str(cmd, report_time_format_CFG, NULL); const char *p_fmt; size_t i; @@ -525,12 +525,12 @@ static const char *_set_time_format(struct cmd_context *cmd) c = *++p_fmt; if (c == 'E') { c = *++p_fmt; - chars_to_check = allowed_alternative_format_chars_e; + chars_to_check = _allowed_alternative_format_chars_e; } else if (c == 'O') { c = *++p_fmt; - chars_to_check = allowed_alternative_format_chars_o; + chars_to_check = _allowed_alternative_format_chars_o; } else - chars_to_check = allowed_format_chars; + chars_to_check = _allowed_format_chars; for (i = 0; chars_to_check[i]; i++) { if (c == chars_to_check[i]) diff --git a/lib/device/device_id.c b/lib/device/device_id.c index 65b68548a..2b183810a 100644 --- a/lib/device/device_id.c +++ b/lib/device/device_id.c @@ -45,9 +45,9 @@ static int _using_devices_file; static int _devices_file_locked; static char _devices_lockfile[PATH_MAX]; static char _devices_file_version[VERSION_LINE_MAX]; -static const char *_searched_file = DEFAULT_RUN_DIR "/searched_devnames"; -static const char *_searched_file_new = DEFAULT_RUN_DIR "/searched_devnames_new"; -static const char *_searched_file_dir = DEFAULT_RUN_DIR; +static const char _searched_file[] = DEFAULT_RUN_DIR "/searched_devnames"; +static const char _searched_file_new[] = DEFAULT_RUN_DIR "/searched_devnames_new"; +static const char _searched_file_dir[] = DEFAULT_RUN_DIR; /* Only for displaying in lvmdevices command output. */ char devices_file_hostname_orig[PATH_MAX]; diff --git a/lib/filters/filter-usable.c b/lib/filters/filter-usable.c index 2084c33ea..dcf9b9091 100644 --- a/lib/filters/filter-usable.c +++ b/lib/filters/filter-usable.c @@ -17,7 +17,7 @@ #include "lib/filters/filter.h" #include "lib/activate/activate.h" -static const char *_too_small_to_hold_pv_msg = "Too small to hold a PV"; +static const char _too_small_to_hold_pv_msg[] = "Too small to hold a PV"; static int _check_pv_min_size(struct device *dev) { diff --git a/lib/label/hints.c b/lib/label/hints.c index 5ea30e2ea..dc424c163 100644 --- a/lib/label/hints.c +++ b/lib/label/hints.c @@ -156,9 +156,9 @@ #include #include -static const char *_hints_file = DEFAULT_RUN_DIR "/hints"; -static const char *_nohints_file = DEFAULT_RUN_DIR "/nohints"; -static const char *_newhints_file = DEFAULT_RUN_DIR "/newhints"; +static const char _hints_file[] = DEFAULT_RUN_DIR "/hints"; +static const char _nohints_file[] = DEFAULT_RUN_DIR "/nohints"; +static const char _newhints_file[] = DEFAULT_RUN_DIR "/newhints"; /* * Format of hints file. Increase the major number when diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c index 78dcc54b3..ad963e05a 100644 --- a/libdm/libdm-report.c +++ b/libdm/libdm-report.c @@ -2840,7 +2840,7 @@ struct time_value { time_t t2; }; -static const char *_out_of_range_msg = "Field selection value %s out of supported range for field %s."; +static const char _out_of_range_msg[] = "Field selection value %s out of supported range for field %s."; /* * Standard formatted date and time - ISO8601.