Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[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
  • Loading branch information
kulaginm committed Jan 7, 2022
commit 83c45e81c923e08c0abf79daa7292ca920ba8ab9
6 changes: 3 additions & 3 deletions src/utils/configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static const unit_conversion time_unit_conversion_table[] =
};

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

ProbackupSubcmd
parse_subcmd(char const * const subcmd_str)
parse_subcmd(const char * const subcmd_str)
{
struct {
ProbackupSubcmd id;
Expand All @@ -137,7 +137,7 @@ parse_subcmd(char const * const subcmd_str)
return NO_CMD;
}

char const *
const char *
get_subcmd_name(ProbackupSubcmd const subcmd)
{
Assert((int)subcmd < sizeof(subcmd_names) / sizeof(subcmd_names[0]));
Expand Down
4 changes: 2 additions & 2 deletions src/utils/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ struct ConfigOption

#define OPTION_UNIT (OPTION_UNIT_MEMORY | OPTION_UNIT_TIME)

extern ProbackupSubcmd parse_subcmd(char const * const subcmd_str);
extern char const *get_subcmd_name(ProbackupSubcmd const subcmd);
extern ProbackupSubcmd parse_subcmd(const char * const subcmd_str);
extern const char *get_subcmd_name(ProbackupSubcmd const subcmd);
extern int config_get_opt(int argc, char **argv, ConfigOption cmd_options[],
ConfigOption options[]);
extern int config_read_opt(const char *path, ConfigOption options[], int elevel,
Expand Down
40 changes: 20 additions & 20 deletions src/utils/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ fio_redirect(int in, int out, int err)
}

void
fio_error(int rc, int size, char const* file, int line)
fio_error(int rc, int size, const char* file, int line)
{
if (remote_agent)
{
Expand Down Expand Up @@ -192,7 +192,7 @@ pread(int fd, void* buf, size_t size, off_t off)

#ifdef WIN32
static int
remove_file_or_dir(char const* path)
remove_file_or_dir(const char* path)
{
int rc = remove(path);

Expand Down Expand Up @@ -287,7 +287,7 @@ fio_get_agent_version(void)

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

/* Open directory */
DIR*
fio_opendir(fio_location location, char const* path)
fio_opendir(fio_location location, const char* path)
{
DIR* dir;
if (fio_is_remote(location))
Expand Down Expand Up @@ -432,7 +432,7 @@ fio_closedir(DIR *dir)

/* Open file */
int
fio_open(fio_location location, char const* path, int mode)
fio_open(fio_location location, const char* path, int mode)
{
int fd;
if (fio_is_remote(location))
Expand Down Expand Up @@ -500,7 +500,7 @@ fio_disconnect(void)

/* Open stdio file */
FILE*
fio_fopen(fio_location location, char const* path, char const* mode)
fio_fopen(fio_location location, const char* path, const char* mode)
{
FILE *f = NULL;

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

/* Format output to file stream */
int
fio_fprintf(FILE* f, char const* format, ...)
fio_fprintf(FILE* f, const char* format, ...)
{
int rc;
va_list args;
Expand Down Expand Up @@ -1112,7 +1112,7 @@ fio_read(int fd, void* buf, size_t size)

/* Get information about file */
int
fio_stat(fio_location location, char const* path, struct stat* st, bool follow_symlink)
fio_stat(fio_location location, const char* path, struct stat* st, bool follow_symlink)
{
if (fio_is_remote(location))
{
Expand Down Expand Up @@ -1149,7 +1149,7 @@ fio_stat(fio_location location, char const* path, struct stat* st, bool follow_s
* in windows compare only filenames
*/
bool
fio_is_same_file(fio_location location, char const* filename1, char const* filename2, bool follow_symlink)
fio_is_same_file(fio_location location, const char* filename1, const char* filename2, bool follow_symlink)
{
#ifndef WIN32
struct stat stat1, stat2;
Expand Down Expand Up @@ -1213,7 +1213,7 @@ fio_readlink(fio_location location, const char *path, char *value, size_t valsiz

/* Check presence of the file */
int
fio_access(fio_location location, char const* path, int mode)
fio_access(fio_location location, const char* path, int mode)
{
if (fio_is_remote(location))
{
Expand Down Expand Up @@ -1245,7 +1245,7 @@ fio_access(fio_location location, char const* path, int mode)

/* Create symbolic link */
int
fio_symlink(fio_location location, char const* target, char const* link_path, bool overwrite)
fio_symlink(fio_location location, const char* target, const char* link_path, bool overwrite)
{
if (fio_is_remote(location))
{
Expand Down Expand Up @@ -1288,7 +1288,7 @@ fio_symlink_impl(int out, char *buf, bool overwrite)

/* Rename file */
int
fio_rename(fio_location location, char const* old_path, char const* new_path)
fio_rename(fio_location location, const char* old_path, const char* new_path)
{
if (fio_is_remote(location))
{
Expand All @@ -1315,7 +1315,7 @@ fio_rename(fio_location location, char const* old_path, char const* new_path)

/* Sync file to disk */
int
fio_sync(fio_location location, char const* path)
fio_sync(fio_location location, const char* path)
{
if (fio_is_remote(location))
{
Expand Down Expand Up @@ -1393,7 +1393,7 @@ fio_get_crc32(fio_location location, const char *file_path, bool decompress)
* if missing_ok, then ignore ENOENT error
*/
int
fio_remove(fio_location location, char const* path, bool missing_ok)
fio_remove(fio_location location, const char* path, bool missing_ok)
{
int result = 0;

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


static void
fio_remove_impl(char const* path, bool missing_ok, int out)
fio_remove_impl(const char* path, bool missing_ok, int out)
{
fio_header hdr = {
.cop = FIO_REMOVE,
Expand All @@ -1453,7 +1453,7 @@ fio_remove_impl(char const* path, bool missing_ok, int out)
* TODO: add strict flag
*/
int
fio_mkdir(fio_location location, char const* path, int mode)
fio_mkdir(fio_location location, const char* path, int mode)
{
if (fio_is_remote(location))
{
Expand All @@ -1480,7 +1480,7 @@ fio_mkdir(fio_location location, char const* path, int mode)

/* Change file mode */
int
fio_chmod(fio_location location, char const* path, int mode)
fio_chmod(fio_location location, const char* path, int mode)
{
if (fio_is_remote(location))
{
Expand Down Expand Up @@ -1552,7 +1552,7 @@ fio_check_error_fd_gz(gzFile f, char **errmsg)

/* On error returns NULL and errno should be checked */
gzFile
fio_gzopen(fio_location location, char const* path, char const* mode, int level)
fio_gzopen(fio_location location, const char* path, const char* mode, int level)
{
int rc;
if (fio_is_remote(location))
Expand Down Expand Up @@ -1819,7 +1819,7 @@ fio_gzseek(gzFile f, z_off_t offset, int whence)
* Note: it should not be used for large files.
*/
static void
fio_load_file(int out, char const* path)
fio_load_file(int out, const char* path)
{
int fd = open(path, O_RDONLY);
fio_header hdr;
Expand Down Expand Up @@ -2728,7 +2728,7 @@ fio_send_file(const char *from_fullpath, const char *to_fullpath, FILE* out,
*
*/
static void
fio_send_file_impl(int out, char const* path)
fio_send_file_impl(int out, const char* path)
{
FILE *fp;
fio_header hdr;
Expand Down
32 changes: 16 additions & 16 deletions src/utils/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,28 +96,28 @@ extern void fio_communicate(int in, int out);
extern void fio_disconnect(void);

extern int fio_get_agent_version(void);
extern void fio_error(int rc, int size, char const* file, int line);
extern void fio_error(int rc, int size, const char* file, int line);

/* FILE-style functions */
extern FILE* fio_fopen(fio_location location, char const* name, char const* mode);
extern FILE* fio_fopen(fio_location location, const char* name, const char* mode);
extern size_t fio_fwrite(FILE* f, void const* buf, size_t size);
extern ssize_t fio_fwrite_async_compressed(FILE* f, void const* buf, size_t size, int compress_alg);
extern size_t fio_fwrite_async(FILE* f, void const* buf, size_t size);
extern int fio_check_error_file(FILE* f, char **errmsg);
extern ssize_t fio_fread(FILE* f, void* buf, size_t size);
extern int fio_pread(FILE* f, void* buf, off_t offs);
extern int fio_fprintf(FILE* f, char const* arg, ...) pg_attribute_printf(2, 3);
extern int fio_fprintf(FILE* f, const char* arg, ...) pg_attribute_printf(2, 3);
extern int fio_fflush(FILE* f);
extern int fio_fseek(FILE* f, off_t offs);
extern int fio_ftruncate(FILE* f, off_t size);
extern int fio_fclose(FILE* f);
extern int fio_ffstat(FILE* f, struct stat* st);

extern FILE* fio_open_stream(fio_location location, char const* name);
extern FILE* fio_open_stream(fio_location location, const char* name);
extern int fio_close_stream(FILE* f);

/* fd-style functions */
extern int fio_open(fio_location location, char const* name, int mode);
extern int fio_open(fio_location location, const char* name, int mode);
extern ssize_t fio_write(int fd, void const* buf, size_t size);
extern ssize_t fio_write_async(int fd, void const* buf, size_t size);
extern int fio_check_error_fd(int fd, char **errmsg);
Expand All @@ -130,27 +130,27 @@ extern int fio_truncate(int fd, off_t size);
extern int fio_close(int fd);

/* DIR-style functions */
extern DIR* fio_opendir(fio_location location, char const* path);
extern DIR* fio_opendir(fio_location location, const char* path);
extern struct dirent * fio_readdir(DIR *dirp);
extern int fio_closedir(DIR *dirp);

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

extern int fio_rename(fio_location location, char const* old_path, char const* new_path);
extern int fio_symlink(fio_location location, char const* target, char const* link_path, bool overwrite);
extern int fio_remove(fio_location location, char const* path, bool missing_ok);
extern int fio_mkdir(fio_location location, char const* path, int mode);
extern int fio_chmod(fio_location location, char const* path, int mode);
extern int fio_access(fio_location location, char const* path, int mode);
extern int fio_stat(fio_location location, char const* path, struct stat* st, bool follow_symlinks);
extern bool fio_is_same_file(fio_location location, char const* filename1, char const* filename2, bool follow_symlink);
extern int fio_rename(fio_location location, const char* old_path, const char* new_path);
extern int fio_symlink(fio_location location, const char* target, const char* link_path, bool overwrite);
extern int fio_remove(fio_location location, const char* path, bool missing_ok);
extern int fio_mkdir(fio_location location, const char* path, int mode);
extern int fio_chmod(fio_location location, const char* path, int mode);
extern int fio_access(fio_location location, const char* path, int mode);
extern int fio_stat(fio_location location, const char* path, struct stat* st, bool follow_symlinks);
extern bool fio_is_same_file(fio_location location, const char* filename1, const char* filename2, bool follow_symlink);
extern ssize_t fio_readlink(fio_location location, const char *path, char *value, size_t valsiz);

/* gzFile-style functions */
#ifdef HAVE_LIBZ
extern gzFile fio_gzopen(fio_location location, char const* path, char const* mode, int level);
extern gzFile fio_gzopen(fio_location location, const char* path, const char* mode, int level);
extern int fio_gzclose(gzFile file);
extern int fio_gzread(gzFile f, void *buf, unsigned size);
extern int fio_gzwrite(gzFile f, void const* buf, unsigned size);
Expand Down
4 changes: 2 additions & 2 deletions src/utils/remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void launch_ssh(char* argv[])
}
#endif

static bool needs_quotes(char const* path)
static bool needs_quotes(const char* path)
{
return strchr(path, ' ') != NULL;
}
Expand Down Expand Up @@ -156,7 +156,7 @@ bool launch_agent(void)

if (instance_config.remote.path)
{
char const* probackup = PROGRAM_NAME_FULL;
const char* probackup = PROGRAM_NAME_FULL;
char* sep = strrchr(probackup, '/');
if (sep != NULL) {
probackup = sep + 1;
Expand Down