Skip to content

Commit 9e36dab

Browse files
kulaginmgsmolk
authored andcommitted
[refactor] remove pgut_fopen()
1 parent d9c1f99 commit 9e36dab

File tree

3 files changed

+9
-25
lines changed

3 files changed

+9
-25
lines changed

src/utils/configuration.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,14 @@ config_read_opt(const char *path, ConfigOption options[], int elevel,
546546
if (!options)
547547
return parsed_options;
548548

549-
if ((fp = pgut_fopen(path, "rt", missing_ok)) == NULL)
550-
return parsed_options;
549+
if ((fp = fio_open_stream(path, FIO_BACKUP_HOST)) == NULL)
550+
{
551+
if (missing_ok && errno == ENOENT)
552+
return parsed_options;
553+
554+
elog(ERROR, "could not open file \"%s\": %s",
555+
path, strerror(errno));
556+
}
551557

552558
while (fgets(buf, lengthof(buf), fp))
553559
{

src/utils/pgut.c

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ pgut_strndup(const char *str, size_t n)
961961
/*
962962
* Allocates new string, that contains part of filepath string minus trailing filename string
963963
* If trailing filename string not found, returns copy of filepath.
964-
* Result must be free by caller.
964+
* Result must be freed by caller.
965965
*/
966966
char *
967967
pgut_str_strip_trailing_filename(const char *filepath, const char *filename)
@@ -980,23 +980,6 @@ pgut_free(void *p)
980980
free(p);
981981
}
982982

983-
FILE *
984-
pgut_fopen(const char *path, const char *mode, bool missing_ok)
985-
{
986-
FILE *fp;
987-
988-
if ((fp = fio_open_stream(path, FIO_BACKUP_HOST)) == NULL)
989-
{
990-
if (missing_ok && errno == ENOENT)
991-
return NULL;
992-
993-
elog(ERROR, "could not open file \"%s\": %s",
994-
path, strerror(errno));
995-
}
996-
997-
return fp;
998-
}
999-
1000983
int
1001984
wait_for_socket(int sock, struct timeval *timeout)
1002985
{

src/utils/pgut.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ extern void pgut_free(void *p);
7070
#define pgut_new0(type) ((type *) pgut_malloc0(sizeof(type)))
7171
#define pgut_newarray(type, n) ((type *) pgut_malloc(sizeof(type) * (n)))
7272

73-
/*
74-
* file operations
75-
*/
76-
extern FILE *pgut_fopen(const char *path, const char *mode, bool missing_ok);
77-
7873
/*
7974
* Assert
8075
*/

0 commit comments

Comments
 (0)