Skip to content
Open
Changes from all commits
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
13 changes: 9 additions & 4 deletions src/bin/initdb/initdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2024,6 +2024,7 @@ setup_cdb_schema(FILE *cmdfd)

/* Collect all files with .sql suffix in array. */
nscripts = 0;
errno = 0;
while ((file = readdir(dir)) != NULL)
{
int namelen = strlen(file->d_name);
Expand Down Expand Up @@ -2054,12 +2055,16 @@ setup_cdb_schema(FILE *cmdfd)
errno = 0;
#endif

closedir(dir);

if (errno != 0)
if (errno)
{
/* some kind of I/O error? */
pg_log_error("error while reading cdb_init.d directory: %m");
closedir(dir);
exit(1);
}

if (closedir(dir))
{
pg_log_error("error while closing cdb_init.d directory: %m");
Comment on lines +2065 to +2067
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

closedir() rarely fails in practice — we have plenty of code that doesn't check its return value — but it's fine to keep the check here, no objection.

exit(1);
}

Expand Down
Loading