Skip to content

Commit 703a8c4

Browse files
committed
Refactor: various: Replace gchar with char for function input arguments
The GLib documentation says the standard char should be preferred in new code. The two are equivalent (via typedef). This commit replaces gchar with char in function input arguments but continues to use gchar for output arguments and return values. We could make an argument for keeping gchar in those cases as a reminder to use g_free(). https://docs.gtk.org/glib/types.html#gchar Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
1 parent db8a48f commit 703a8c4

32 files changed

Lines changed: 151 additions & 155 deletions

daemons/based/pacemaker-based.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ based_metadata(pcmk__output_t *out)
121121
}
122122

123123
static gboolean
124-
disk_writes_cb(const gchar *option_name, const gchar *optarg, void *data,
124+
disk_writes_cb(const char *option_name, const char *optarg, void *data,
125125
GError **error)
126126
{
127127
based_enable_writes(0);

daemons/execd/cts-exec-helper.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ static struct {
5555
} options;
5656

5757
static gboolean
58-
interval_cb(const gchar *option_name, const gchar *optarg, void *data,
58+
interval_cb(const char *option_name, const char *optarg, void *data,
5959
GError **error)
6060
{
6161
return pcmk_parse_interval_spec(optarg,
6262
&options.interval_ms) == pcmk_rc_ok;
6363
}
6464

6565
static gboolean
66-
notify_cb(const gchar *option_name, const gchar *optarg, void *data,
66+
notify_cb(const char *option_name, const char *optarg, void *data,
6767
GError **error)
6868
{
6969
if (pcmk__str_any_of(option_name, "--notify-orig", "-n", NULL)) {
@@ -76,7 +76,7 @@ notify_cb(const gchar *option_name, const gchar *optarg, void *data,
7676
}
7777

7878
static gboolean
79-
param_key_val_cb(const gchar *option_name, const gchar *optarg, void *data,
79+
param_key_val_cb(const char *option_name, const char *optarg, void *data,
8080
GError **error)
8181
{
8282
if (pcmk__str_any_of(option_name, "--param-key", "-k", NULL)) {

daemons/execd/remoted_pidone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static struct {
7272
* [a-zA-Z0-9_] characters and do not start with a digit.
7373
*/
7474
static bool
75-
valid_env_var_name(const gchar *name)
75+
valid_env_var_name(const char *name)
7676
{
7777
if (!isalpha(*name) && (*name != '_')) {
7878
// Invalid first character

daemons/fenced/cts-fence-helper.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ struct {
5555
};
5656

5757
static gboolean
58-
mode_cb(const gchar *option_name, const gchar *optarg, void *data,
59-
GError **error)
58+
mode_cb(const char *option_name, const char *optarg, void *data, GError **error)
6059
{
6160
if (pcmk__str_any_of(option_name, "--mainloop_api_test", "-m", NULL)) {
6261
options.mode = test_api_mainloop;

daemons/pacemakerd/pacemakerd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ static pcmk__message_entry_t fmt_functions[] = {
9595
};
9696

9797
static gboolean
98-
pid_cb(const gchar *option_name, const gchar *optarg, void *data, GError **err)
98+
pid_cb(const char *option_name, const char *optarg, void *data, GError **err)
9999
{
100100
return TRUE;
101101
}
102102

103103
static gboolean
104-
standby_cb(const gchar *option_name, const gchar *optarg, void *data,
104+
standby_cb(const char *option_name, const char *optarg, void *data,
105105
GError **err)
106106
{
107107
options.standby = TRUE;

include/crm/common/cmdline_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void pcmk__add_arg_group(GOptionContext *context, const char *name,
117117
*
118118
* \param[in,out] argv Command line (typically from pcmk__cmdline_preproc())
119119
*/
120-
gchar *pcmk__quote_cmdline(gchar **argv);
120+
gchar *pcmk__quote_cmdline(char **argv);
121121

122122
/*!
123123
* \internal

include/crm/common/logging_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ void pcmk__log_xml_patchset_as(const char *file, const char *function,
405405
*/
406406
void pcmk__cli_init_logging(const char *name, unsigned int verbosity);
407407

408-
void pcmk__add_logfiles(gchar **log_files, pcmk__output_t *out);
408+
void pcmk__add_logfiles(char **log_files, pcmk__output_t *out);
409409

410410
#ifdef __cplusplus
411411
}

include/crm/common/nvpair_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ int pcmk__cmp_nvpair_blocks(const void *a, const void *b, void *user_data);
4747

4848
void pcmk__unpack_nvpair_block(void *data, void *user_data);
4949

50-
int pcmk__scan_nvpair(const gchar *input, gchar **name, gchar **value);
50+
int pcmk__scan_nvpair(const char *input, gchar **name, gchar **value);
5151
char *pcmk__format_nvpair(const char *name, const char *value,
5252
const char *units);
5353

include/crm/common/strings_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ pcmk__intkey_table_remove(GHashTable *hash_table, int key)
164164
}
165165

166166
bool pcmk__str_in_list(const char *str, const GList *list, uint32_t flags);
167-
bool pcmk__g_strv_contains(gchar **strv, const gchar *str);
167+
bool pcmk__g_strv_contains(char **strv, const char *str);
168168

169169
bool pcmk__strcase_any_of(const char *s, ...) G_GNUC_NULL_TERMINATED;
170170
bool pcmk__str_any_of(const char *s, ...) G_GNUC_NULL_TERMINATED;

lib/common/cmdline.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <crm/common/util.h>
1919

2020
static gboolean
21-
bump_verbosity(const gchar *option_name, const gchar *optarg, void *data,
21+
bump_verbosity(const char *option_name, const char *optarg, void *data,
2222
GError **error)
2323
{
2424
pcmk__common_args_t *common_args = (pcmk__common_args_t *) data;
@@ -146,7 +146,7 @@ pcmk__add_arg_group(GOptionContext *context, const char *name,
146146
}
147147

148148
gchar *
149-
pcmk__quote_cmdline(gchar **argv)
149+
pcmk__quote_cmdline(char **argv)
150150
{
151151
GString *cmdline = NULL;
152152

0 commit comments

Comments
 (0)