Skip to content

Commit 4ec64a9

Browse files
committed
[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 5a6bd01 commit 4ec64a9

File tree

5 files changed

+43
-43
lines changed

5 files changed

+43
-43
lines changed

src/utils/configuration.c

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

9090
/* Order is important, keep it in sync with utils/configuration.h:enum ProbackupSubcmd declaration */
91-
static char const * const subcmd_names[] =
91+
static const char * const subcmd_names[] =
9292
{
9393
"NO_CMD",
9494
"init",
@@ -114,7 +114,7 @@ static char const * const subcmd_names[] =
114114
};
115115

116116
ProbackupSubcmd
117-
parse_subcmd(char const * const subcmd_str)
117+
parse_subcmd(const char * const subcmd_str)
118118
{
119119
struct {
120120
ProbackupSubcmd id;
@@ -137,7 +137,7 @@ parse_subcmd(char const * const subcmd_str)
137137
return NO_CMD;
138138
}
139139

140-
char const *
140+
const char *
141141
get_subcmd_name(ProbackupSubcmd const subcmd)
142142
{
143143
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: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ fio_redirect(int in, int out, int err)
112112
}
113113

114114
void
115-
fio_error(int rc, int size, char const* file, int line)
115+
fio_error(int rc, int size, const char* file, int line)
116116
{
117117
if (remote_agent)
118118
{
@@ -192,7 +192,7 @@ pread(int fd, void* buf, size_t size, off_t off)
192192

193193
#ifdef WIN32
194194
static int
195-
remove_file_or_dir(char const* path)
195+
remove_file_or_dir(const char* path)
196196
{
197197
int rc = remove(path);
198198

@@ -287,7 +287,7 @@ fio_get_agent_version(void)
287287

288288
/* Open input stream. Remote file is fetched to the in-memory buffer and then accessed through Linux fmemopen */
289289
FILE*
290-
fio_open_stream(fio_location location, char const* path)
290+
fio_open_stream(fio_location location, const char* path)
291291
{
292292
FILE* f;
293293
if (fio_is_remote(location))
@@ -340,7 +340,7 @@ fio_close_stream(FILE* f)
340340

341341
/* Open directory */
342342
DIR*
343-
fio_opendir(fio_location location, char const* path)
343+
fio_opendir(fio_location location, const char* path)
344344
{
345345
DIR* dir;
346346
if (fio_is_remote(location))
@@ -432,7 +432,7 @@ fio_closedir(DIR *dir)
432432

433433
/* Open file */
434434
int
435-
fio_open(fio_location location, char const* path, int mode)
435+
fio_open(fio_location location, const char* path, int mode)
436436
{
437437
int fd;
438438
if (fio_is_remote(location))
@@ -500,7 +500,7 @@ fio_disconnect(void)
500500

501501
/* Open stdio file */
502502
FILE*
503-
fio_fopen(fio_location location, char const* path, char const* mode)
503+
fio_fopen(fio_location location, const char* path, const char* mode)
504504
{
505505
FILE *f = NULL;
506506

@@ -546,7 +546,7 @@ fio_fopen(fio_location location, char const* path, char const* mode)
546546

547547
/* Format output to file stream */
548548
int
549-
fio_fprintf(FILE* f, char const* format, ...)
549+
fio_fprintf(FILE* f, const char* format, ...)
550550
{
551551
int rc;
552552
va_list args;
@@ -1112,7 +1112,7 @@ fio_read(int fd, void* buf, size_t size)
11121112

11131113
/* Get information about file */
11141114
int
1115-
fio_stat(fio_location location, char const* path, struct stat* st, bool follow_symlink)
1115+
fio_stat(fio_location location, const char* path, struct stat* st, bool follow_symlink)
11161116
{
11171117
if (fio_is_remote(location))
11181118
{
@@ -1149,7 +1149,7 @@ fio_stat(fio_location location, char const* path, struct stat* st, bool follow_s
11491149
* in windows compare only filenames
11501150
*/
11511151
bool
1152-
fio_is_same_file(fio_location location, char const* filename1, char const* filename2, bool follow_symlink)
1152+
fio_is_same_file(fio_location location, const char* filename1, const char* filename2, bool follow_symlink)
11531153
{
11541154
#ifndef WIN32
11551155
struct stat stat1, stat2;
@@ -1213,7 +1213,7 @@ fio_readlink(fio_location location, const char *path, char *value, size_t valsiz
12131213

12141214
/* Check presence of the file */
12151215
int
1216-
fio_access(fio_location location, char const* path, int mode)
1216+
fio_access(fio_location location, const char* path, int mode)
12171217
{
12181218
if (fio_is_remote(location))
12191219
{
@@ -1245,7 +1245,7 @@ fio_access(fio_location location, char const* path, int mode)
12451245

12461246
/* Create symbolic link */
12471247
int
1248-
fio_symlink(fio_location location, char const* target, char const* link_path, bool overwrite)
1248+
fio_symlink(fio_location location, const char* target, const char* link_path, bool overwrite)
12491249
{
12501250
if (fio_is_remote(location))
12511251
{
@@ -1288,7 +1288,7 @@ fio_symlink_impl(int out, char *buf, bool overwrite)
12881288

12891289
/* Rename file */
12901290
int
1291-
fio_rename(fio_location location, char const* old_path, char const* new_path)
1291+
fio_rename(fio_location location, const char* old_path, const char* new_path)
12921292
{
12931293
if (fio_is_remote(location))
12941294
{
@@ -1315,7 +1315,7 @@ fio_rename(fio_location location, char const* old_path, char const* new_path)
13151315

13161316
/* Sync file to disk */
13171317
int
1318-
fio_sync(fio_location location, char const* path)
1318+
fio_sync(fio_location location, const char* path)
13191319
{
13201320
if (fio_is_remote(location))
13211321
{
@@ -1393,7 +1393,7 @@ fio_get_crc32(fio_location location, const char *file_path, bool decompress)
13931393
* if missing_ok, then ignore ENOENT error
13941394
*/
13951395
int
1396-
fio_remove(fio_location location, char const* path, bool missing_ok)
1396+
fio_remove(fio_location location, const char* path, bool missing_ok)
13971397
{
13981398
int result = 0;
13991399

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

14321432

14331433
static void
1434-
fio_remove_impl(char const* path, bool missing_ok, int out)
1434+
fio_remove_impl(const char* path, bool missing_ok, int out)
14351435
{
14361436
fio_header hdr = {
14371437
.cop = FIO_REMOVE,
@@ -1453,7 +1453,7 @@ fio_remove_impl(char const* path, bool missing_ok, int out)
14531453
* TODO: add strict flag
14541454
*/
14551455
int
1456-
fio_mkdir(fio_location location, char const* path, int mode)
1456+
fio_mkdir(fio_location location, const char* path, int mode)
14571457
{
14581458
if (fio_is_remote(location))
14591459
{
@@ -1480,7 +1480,7 @@ fio_mkdir(fio_location location, char const* path, int mode)
14801480

14811481
/* Change file mode */
14821482
int
1483-
fio_chmod(fio_location location, char const* path, int mode)
1483+
fio_chmod(fio_location location, const char* path, int mode)
14841484
{
14851485
if (fio_is_remote(location))
14861486
{
@@ -1552,7 +1552,7 @@ fio_check_error_fd_gz(gzFile f, char **errmsg)
15521552

15531553
/* On error returns NULL and errno should be checked */
15541554
gzFile
1555-
fio_gzopen(fio_location location, char const* path, char const* mode, int level)
1555+
fio_gzopen(fio_location location, const char* path, const char* mode, int level)
15561556
{
15571557
int rc;
15581558
if (fio_is_remote(location))
@@ -1819,7 +1819,7 @@ fio_gzseek(gzFile f, z_off_t offset, int whence)
18191819
* Note: it should not be used for large files.
18201820
*/
18211821
static void
1822-
fio_load_file(int out, char const* path)
1822+
fio_load_file(int out, const char* path)
18231823
{
18241824
int fd = open(path, O_RDONLY);
18251825
fio_header hdr;
@@ -2728,7 +2728,7 @@ fio_send_file(const char *from_fullpath, const char *to_fullpath, FILE* out,
27282728
*
27292729
*/
27302730
static void
2731-
fio_send_file_impl(int out, char const* path)
2731+
fio_send_file_impl(int out, const char* path)
27322732
{
27332733
FILE *fp;
27342734
fio_header hdr;

src/utils/file.h

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

9898
extern int fio_get_agent_version(void);
99-
extern void fio_error(int rc, int size, char const* file, int line);
99+
extern void fio_error(int rc, int size, const char* file, int line);
100100

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

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

119119
/* fd-style functions */
120-
extern int fio_open(fio_location location, char const* name, int mode);
120+
extern int fio_open(fio_location location, const char* name, int mode);
121121
extern ssize_t fio_write(int fd, void const* buf, size_t size);
122122
extern ssize_t fio_write_async(int fd, void const* buf, size_t size);
123123
extern int fio_check_error_fd(int fd, char **errmsg);
@@ -130,27 +130,27 @@ extern int fio_truncate(int fd, off_t size);
130130
extern int fio_close(int fd);
131131

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

137137
/* pathname-style functions */
138-
extern int fio_sync(fio_location location, char const* path);
138+
extern int fio_sync(fio_location location, const char* path);
139139
extern pg_crc32 fio_get_crc32(fio_location location, const char *file_path, bool decompress);
140140

141-
extern int fio_rename(fio_location location, char const* old_path, char const* new_path);
142-
extern int fio_symlink(fio_location location, char const* target, char const* link_path, bool overwrite);
143-
extern int fio_remove(fio_location location, char const* path, bool missing_ok);
144-
extern int fio_mkdir(fio_location location, char const* path, int mode);
145-
extern int fio_chmod(fio_location location, char const* path, int mode);
146-
extern int fio_access(fio_location location, char const* path, int mode);
147-
extern int fio_stat(fio_location location, char const* path, struct stat* st, bool follow_symlinks);
148-
extern bool fio_is_same_file(fio_location location, char const* filename1, char const* filename2, bool follow_symlink);
141+
extern int fio_rename(fio_location location, const char* old_path, const char* new_path);
142+
extern int fio_symlink(fio_location location, const char* target, const char* link_path, bool overwrite);
143+
extern int fio_remove(fio_location location, const char* path, bool missing_ok);
144+
extern int fio_mkdir(fio_location location, const char* path, int mode);
145+
extern int fio_chmod(fio_location location, const char* path, int mode);
146+
extern int fio_access(fio_location location, const char* path, int mode);
147+
extern int fio_stat(fio_location location, const char* path, struct stat* st, bool follow_symlinks);
148+
extern bool fio_is_same_file(fio_location location, const char* filename1, const char* filename2, bool follow_symlink);
149149
extern ssize_t fio_readlink(fio_location location, const char *path, char *value, size_t valsiz);
150150

151151
/* gzFile-style functions */
152152
#ifdef HAVE_LIBZ
153-
extern gzFile fio_gzopen(fio_location location, char const* path, char const* mode, int level);
153+
extern gzFile fio_gzopen(fio_location location, const char* path, const char* mode, int level);
154154
extern int fio_gzclose(gzFile file);
155155
extern int fio_gzread(gzFile f, void *buf, unsigned size);
156156
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
@@ -103,7 +103,7 @@ void launch_ssh(char* argv[])
103103
}
104104
#endif
105105

106-
static bool needs_quotes(char const* path)
106+
static bool needs_quotes(const char* path)
107107
{
108108
return strchr(path, ' ') != NULL;
109109
}
@@ -156,7 +156,7 @@ bool launch_agent(void)
156156

157157
if (instance_config.remote.path)
158158
{
159-
char const* probackup = PROGRAM_NAME_FULL;
159+
const char* probackup = PROGRAM_NAME_FULL;
160160
char* sep = strrchr(probackup, '/');
161161
if (sep != NULL) {
162162
probackup = sep + 1;

0 commit comments

Comments
 (0)