Skip to content

Commit 6ec2a49

Browse files
kulaginmGrigory Smolkin
authored andcommitted
[refactoring] 's/char const/const char/g'
I prefer the declaration in form 'char const', but in the source code the form 'const char' is used more often
1 parent f239d39 commit 6ec2a49

File tree

5 files changed

+42
-42
lines changed

5 files changed

+42
-42
lines changed

src/utils/configuration.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static const unit_conversion time_unit_conversion_table[] =
9090
};
9191

9292
/* Order is important, keep it in sync with utils/configuration.h:enum ProbackupSubcmd declaration */
93-
static char const * const subcmd_names[] =
93+
static const char * const subcmd_names[] =
9494
{
9595
"NO_CMD",
9696
"init",
@@ -116,7 +116,7 @@ static char const * const subcmd_names[] =
116116
};
117117

118118
ProbackupSubcmd
119-
parse_subcmd(char const * const subcmd_str)
119+
parse_subcmd(const char * const subcmd_str)
120120
{
121121
struct {
122122
ProbackupSubcmd id;
@@ -139,7 +139,7 @@ parse_subcmd(char const * const subcmd_str)
139139
return NO_CMD;
140140
}
141141

142-
char const *
142+
const char *
143143
get_subcmd_name(ProbackupSubcmd const subcmd)
144144
{
145145
Assert((int)subcmd < sizeof(subcmd_names) / sizeof(subcmd_names[0]));

src/utils/configuration.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ struct ConfigOption
101101

102102
#define OPTION_UNIT (OPTION_UNIT_MEMORY | OPTION_UNIT_TIME)
103103

104-
extern ProbackupSubcmd parse_subcmd(char const * const subcmd_str);
105-
extern char const *get_subcmd_name(ProbackupSubcmd const subcmd);
104+
extern ProbackupSubcmd parse_subcmd(const char * const subcmd_str);
105+
extern const char *get_subcmd_name(ProbackupSubcmd const subcmd);
106106
extern int config_get_opt(int argc, char **argv, ConfigOption cmd_options[],
107107
ConfigOption options[]);
108108
extern int config_read_opt(const char *path, ConfigOption options[], int elevel,

src/utils/file.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fio_redirect(int in, int out, int err)
104104
}
105105

106106
void
107-
fio_error(int rc, int size, char const* file, int line)
107+
fio_error(int rc, int size, const char* file, int line)
108108
{
109109
if (remote_agent)
110110
{
@@ -221,7 +221,7 @@ fio_get_agent_version(int* protocol, char* payload_buf, size_t payload_buf_size)
221221

222222
/* Open input stream. Remote file is fetched to the in-memory buffer and then accessed through Linux fmemopen */
223223
FILE*
224-
fio_open_stream(fio_location location, char const* path)
224+
fio_open_stream(fio_location location, const char* path)
225225
{
226226
FILE* f;
227227
if (fio_is_remote(location))
@@ -268,7 +268,7 @@ fio_close_stream(FILE* f)
268268

269269
/* Open directory */
270270
DIR*
271-
fio_opendir(fio_location location, char const* path)
271+
fio_opendir(fio_location location, const char* path)
272272
{
273273
DIR* dir;
274274
if (fio_is_remote(location))
@@ -360,7 +360,7 @@ fio_closedir(DIR *dir)
360360

361361
/* Open file */
362362
int
363-
fio_open(fio_location location, char const* path, int mode)
363+
fio_open(fio_location location, const char* path, int mode)
364364
{
365365
int fd;
366366
if (fio_is_remote(location))
@@ -430,7 +430,7 @@ fio_disconnect(void)
430430

431431
/* Open stdio file */
432432
FILE*
433-
fio_fopen(fio_location location, char const* path, char const* mode)
433+
fio_fopen(fio_location location, const char* path, const char* mode)
434434
{
435435
FILE *f = NULL;
436436

@@ -476,7 +476,7 @@ fio_fopen(fio_location location, char const* path, char const* mode)
476476

477477
/* Format output to file stream */
478478
int
479-
fio_fprintf(FILE* f, char const* format, ...)
479+
fio_fprintf(FILE* f, const char* format, ...)
480480
{
481481
int rc;
482482
va_list args;
@@ -1042,7 +1042,7 @@ fio_read(int fd, void* buf, size_t size)
10421042

10431043
/* Get information about file */
10441044
int
1045-
fio_stat(fio_location location, char const* path, struct stat* st, bool follow_symlink)
1045+
fio_stat(fio_location location, const char* path, struct stat* st, bool follow_symlink)
10461046
{
10471047
if (fio_is_remote(location))
10481048
{
@@ -1078,7 +1078,7 @@ fio_stat(fio_location location, char const* path, struct stat* st, bool follow_s
10781078
* Compare, that filename1 and filename2 is the same file
10791079
*/
10801080
bool
1081-
fio_is_same_file(fio_location location, char const* filename1, char const* filename2, bool follow_symlink)
1081+
fio_is_same_file(fio_location location, const char* filename1, const char* filename2, bool follow_symlink)
10821082
{
10831083
struct stat stat1, stat2;
10841084

@@ -1133,7 +1133,7 @@ fio_readlink(fio_location location, const char *path, char *value, size_t valsiz
11331133

11341134
/* Check presence of the file */
11351135
int
1136-
fio_access(fio_location location, char const* path, int mode)
1136+
fio_access(fio_location location, const char* path, int mode)
11371137
{
11381138
if (fio_is_remote(location))
11391139
{
@@ -1165,7 +1165,7 @@ fio_access(fio_location location, char const* path, int mode)
11651165

11661166
/* Create symbolic link */
11671167
int
1168-
fio_symlink(fio_location location, char const* target, char const* link_path, bool overwrite)
1168+
fio_symlink(fio_location location, const char* target, const char* link_path, bool overwrite)
11691169
{
11701170
if (fio_is_remote(location))
11711171
{
@@ -1208,7 +1208,7 @@ fio_symlink_impl(int out, char *buf, bool overwrite)
12081208

12091209
/* Rename file */
12101210
int
1211-
fio_rename(fio_location location, char const* old_path, char const* new_path)
1211+
fio_rename(fio_location location, const char* old_path, const char* new_path)
12121212
{
12131213
if (fio_is_remote(location))
12141214
{
@@ -1235,7 +1235,7 @@ fio_rename(fio_location location, char const* old_path, char const* new_path)
12351235

12361236
/* Sync file to disk */
12371237
int
1238-
fio_sync(fio_location location, char const* path)
1238+
fio_sync(fio_location location, const char* path)
12391239
{
12401240
if (fio_is_remote(location))
12411241
{
@@ -1343,7 +1343,7 @@ fio_get_crc32_truncated(fio_location location, const char *file_path,
13431343
* if missing_ok, then ignore ENOENT error
13441344
*/
13451345
int
1346-
fio_remove(fio_location location, char const* path, bool missing_ok)
1346+
fio_remove(fio_location location, const char* path, bool missing_ok)
13471347
{
13481348
int result = 0;
13491349

@@ -1381,7 +1381,7 @@ fio_remove(fio_location location, char const* path, bool missing_ok)
13811381

13821382

13831383
static void
1384-
fio_remove_impl(char const* path, bool missing_ok, int out)
1384+
fio_remove_impl(const char* path, bool missing_ok, int out)
13851385
{
13861386
fio_header hdr = {
13871387
.cop = FIO_REMOVE,
@@ -1403,7 +1403,7 @@ fio_remove_impl(char const* path, bool missing_ok, int out)
14031403
* TODO: add strict flag
14041404
*/
14051405
int
1406-
fio_mkdir(fio_location location, char const* path, int mode)
1406+
fio_mkdir(fio_location location, const char* path, int mode)
14071407
{
14081408
if (fio_is_remote(location))
14091409
{
@@ -1430,7 +1430,7 @@ fio_mkdir(fio_location location, char const* path, int mode)
14301430

14311431
/* Change file mode */
14321432
int
1433-
fio_chmod(fio_location location, char const* path, int mode)
1433+
fio_chmod(fio_location location, const char* path, int mode)
14341434
{
14351435
if (fio_is_remote(location))
14361436
{
@@ -1502,7 +1502,7 @@ fio_check_error_fd_gz(gzFile f, char **errmsg)
15021502

15031503
/* On error returns NULL and errno should be checked */
15041504
gzFile
1505-
fio_gzopen(fio_location location, char const* path, char const* mode, int level)
1505+
fio_gzopen(fio_location location, const char* path, const char* mode, int level)
15061506
{
15071507
int rc;
15081508
if (fio_is_remote(location))
@@ -1769,7 +1769,7 @@ fio_gzseek(gzFile f, z_off_t offset, int whence)
17691769
* Note: it should not be used for large files.
17701770
*/
17711771
static void
1772-
fio_load_file(int out, char const* path)
1772+
fio_load_file(int out, const char* path)
17731773
{
17741774
int fd = open(path, O_RDONLY);
17751775
fio_header hdr;
@@ -2945,7 +2945,7 @@ fio_send_file_local(const char *from_fullpath, FILE* out, bool cut_zero_tail,
29452945
*
29462946
*/
29472947
static void
2948-
fio_send_file_impl(int out, char const* path)
2948+
fio_send_file_impl(int out, const char* path)
29492949
{
29502950
FILE *fp;
29512951
fio_header hdr;

src/utils/file.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -97,28 +97,28 @@ extern void fio_communicate(int in, int out);
9797
extern void fio_disconnect(void);
9898

9999
extern void fio_get_agent_version(int* protocol, char* payload_buf, size_t payload_buf_size);
100-
extern void fio_error(int rc, int size, char const* file, int line);
100+
extern void fio_error(int rc, int size, const char* file, int line);
101101

102102
/* FILE-style functions */
103-
extern FILE* fio_fopen(fio_location location, char const* name, char const* mode);
103+
extern FILE* fio_fopen(fio_location location, const char* name, const char* mode);
104104
extern size_t fio_fwrite(FILE* f, void const* buf, size_t size);
105105
extern ssize_t fio_fwrite_async_compressed(FILE* f, void const* buf, size_t size, int compress_alg);
106106
extern size_t fio_fwrite_async(FILE* f, void const* buf, size_t size);
107107
extern int fio_check_error_file(FILE* f, char **errmsg);
108108
extern ssize_t fio_fread(FILE* f, void* buf, size_t size);
109109
extern int fio_pread(FILE* f, void* buf, off_t offs);
110-
extern int fio_fprintf(FILE* f, char const* arg, ...) pg_attribute_printf(2, 3);
110+
extern int fio_fprintf(FILE* f, const char* arg, ...) pg_attribute_printf(2, 3);
111111
extern int fio_fflush(FILE* f);
112112
extern int fio_fseek(FILE* f, off_t offs);
113113
extern int fio_ftruncate(FILE* f, off_t size);
114114
extern int fio_fclose(FILE* f);
115115
extern int fio_ffstat(FILE* f, struct stat* st);
116116

117-
extern FILE* fio_open_stream(fio_location location, char const* name);
117+
extern FILE* fio_open_stream(fio_location location, const char* name);
118118
extern int fio_close_stream(FILE* f);
119119

120120
/* fd-style functions */
121-
extern int fio_open(fio_location location, char const* name, int mode);
121+
extern int fio_open(fio_location location, const char* name, int mode);
122122
extern ssize_t fio_write(int fd, void const* buf, size_t size);
123123
extern ssize_t fio_write_async(int fd, void const* buf, size_t size);
124124
extern int fio_check_error_fd(int fd, char **errmsg);
@@ -131,30 +131,30 @@ extern int fio_truncate(int fd, off_t size);
131131
extern int fio_close(int fd);
132132

133133
/* DIR-style functions */
134-
extern DIR* fio_opendir(fio_location location, char const* path);
134+
extern DIR* fio_opendir(fio_location location, const char* path);
135135
extern struct dirent * fio_readdir(DIR *dirp);
136136
extern int fio_closedir(DIR *dirp);
137137

138138
/* pathname-style functions */
139-
extern int fio_sync(fio_location location, char const* path);
139+
extern int fio_sync(fio_location location, const char* path);
140140
extern pg_crc32 fio_get_crc32(fio_location location, const char *file_path,
141141
bool decompress, bool missing_ok);
142142
extern pg_crc32 fio_get_crc32_truncated(fio_location location, const char *file_path,
143143
bool missing_ok);
144144

145-
extern int fio_rename(fio_location location, char const* old_path, char const* new_path);
146-
extern int fio_symlink(fio_location location, char const* target, char const* link_path, bool overwrite);
147-
extern int fio_remove(fio_location location, char const* path, bool missing_ok);
148-
extern int fio_mkdir(fio_location location, char const* path, int mode);
149-
extern int fio_chmod(fio_location location, char const* path, int mode);
150-
extern int fio_access(fio_location location, char const* path, int mode);
151-
extern int fio_stat(fio_location location, char const* path, struct stat* st, bool follow_symlinks);
152-
extern bool fio_is_same_file(fio_location location, char const* filename1, char const* filename2, bool follow_symlink);
145+
extern int fio_rename(fio_location location, const char* old_path, const char* new_path);
146+
extern int fio_symlink(fio_location location, const char* target, const char* link_path, bool overwrite);
147+
extern int fio_remove(fio_location location, const char* path, bool missing_ok);
148+
extern int fio_mkdir(fio_location location, const char* path, int mode);
149+
extern int fio_chmod(fio_location location, const char* path, int mode);
150+
extern int fio_access(fio_location location, const char* path, int mode);
151+
extern int fio_stat(fio_location location, const char* path, struct stat* st, bool follow_symlinks);
152+
extern bool fio_is_same_file(fio_location location, const char* filename1, const char* filename2, bool follow_symlink);
153153
extern ssize_t fio_readlink(fio_location location, const char *path, char *value, size_t valsiz);
154154

155155
/* gzFile-style functions */
156156
#ifdef HAVE_LIBZ
157-
extern gzFile fio_gzopen(fio_location location, char const* path, char const* mode, int level);
157+
extern gzFile fio_gzopen(fio_location location, const char* path, const char* mode, int level);
158158
extern int fio_gzclose(gzFile file);
159159
extern int fio_gzread(gzFile f, void *buf, unsigned size);
160160
extern int fio_gzwrite(gzFile f, void const* buf, unsigned size);

src/utils/remote.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void wait_ssh(void)
7373
elog(LOG, "SSH process %d is terminated with status %d", child_pid, status);
7474
}
7575

76-
static bool needs_quotes(char const* path)
76+
static bool needs_quotes(const char* path)
7777
{
7878
return strchr(path, ' ') != NULL;
7979
}
@@ -124,7 +124,7 @@ bool launch_agent(void)
124124

125125
if (instance_config.remote.path)
126126
{
127-
char const* probackup = PROGRAM_NAME_FULL;
127+
const char* probackup = PROGRAM_NAME_FULL;
128128
char* sep = strrchr(probackup, '/');
129129
if (sep != NULL) {
130130
probackup = sep + 1;

0 commit comments

Comments
 (0)