Skip to content

Commit 2f31f40

Browse files
committed
Constify the arguments of copydir.h functions
This makes sure that the internal logic of these functions does not attempt to change the value of the arguments constified, and it removes one unconstify() in basic_archive.c. Author: Nathan Bossart Reviewed-by: Andrew Dunstan, Peter Eisentraut Discussion: https://postgr.es/m/20230114231126.GA2580330@nathanxps13
1 parent 09d465c commit 2f31f40

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

contrib/basic_archive/basic_archive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ basic_archive_file_internal(const char *file, const char *path)
275275
* Copy the file to its temporary destination. Note that this will fail
276276
* if temp already exists.
277277
*/
278-
copy_file(unconstify(char *, path), temp);
278+
copy_file(path, temp);
279279

280280
/*
281281
* Sync the temporary file to disk and move it to its final destination.

src/backend/storage/file/copydir.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* a directory or a regular file is ignored.
3535
*/
3636
void
37-
copydir(char *fromdir, char *todir, bool recurse)
37+
copydir(const char *fromdir, const char *todir, bool recurse)
3838
{
3939
DIR *xldir;
4040
struct dirent *xlde;
@@ -114,7 +114,7 @@ copydir(char *fromdir, char *todir, bool recurse)
114114
* copy one file
115115
*/
116116
void
117-
copy_file(char *fromfile, char *tofile)
117+
copy_file(const char *fromfile, const char *tofile)
118118
{
119119
char *buffer;
120120
int srcfd;

src/include/storage/copydir.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#ifndef COPYDIR_H
1414
#define COPYDIR_H
1515

16-
extern void copydir(char *fromdir, char *todir, bool recurse);
17-
extern void copy_file(char *fromfile, char *tofile);
16+
extern void copydir(const char *fromdir, const char *todir, bool recurse);
17+
extern void copy_file(const char *fromfile, const char *tofile);
1818

1919
#endif /* COPYDIR_H */

0 commit comments

Comments
 (0)