From e3d52a3812e660608118c2d58236dd8164fc9a6b Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Mon, 22 Sep 2025 14:47:49 +0200 Subject: [PATCH 19/23] C11 anonymous unions [fd] --- src/backend/storage/file/fd.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index a4ec7959f31..c222a442a8d 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -261,7 +261,7 @@ typedef struct FILE *file; DIR *dir; int fd; - } desc; + }; } AllocateDesc; static int numAllocatedDescs = 0; @@ -2661,10 +2661,10 @@ AllocateFile(const char *name, const char *mode) AllocateDesc *desc = &allocatedDescs[numAllocatedDescs]; desc->kind = AllocateDescFile; - desc->desc.file = file; + desc->file = file; desc->create_subid = GetCurrentSubTransactionId(); numAllocatedDescs++; - return desc->desc.file; + return desc->file; } if (errno == EMFILE || errno == ENFILE) @@ -2721,7 +2721,7 @@ OpenTransientFilePerm(const char *fileName, int fileFlags, mode_t fileMode) AllocateDesc *desc = &allocatedDescs[numAllocatedDescs]; desc->kind = AllocateDescRawFD; - desc->desc.fd = fd; + desc->fd = fd; desc->create_subid = GetCurrentSubTransactionId(); numAllocatedDescs++; @@ -2772,10 +2772,10 @@ OpenPipeStream(const char *command, const char *mode) AllocateDesc *desc = &allocatedDescs[numAllocatedDescs]; desc->kind = AllocateDescPipe; - desc->desc.file = file; + desc->file = file; desc->create_subid = GetCurrentSubTransactionId(); numAllocatedDescs++; - return desc->desc.file; + return desc->file; } if (errno == EMFILE || errno == ENFILE) @@ -2805,17 +2805,17 @@ FreeDesc(AllocateDesc *desc) switch (desc->kind) { case AllocateDescFile: - result = fclose(desc->desc.file); + result = fclose(desc->file); break; case AllocateDescPipe: - result = pclose(desc->desc.file); + result = pclose(desc->file); break; case AllocateDescDir: - result = closedir(desc->desc.dir); + result = closedir(desc->dir); break; case AllocateDescRawFD: - pgaio_closing_fd(desc->desc.fd); - result = close(desc->desc.fd); + pgaio_closing_fd(desc->fd); + result = close(desc->fd); break; default: elog(ERROR, "AllocateDesc kind not recognized"); @@ -2848,7 +2848,7 @@ FreeFile(FILE *file) { AllocateDesc *desc = &allocatedDescs[i]; - if (desc->kind == AllocateDescFile && desc->desc.file == file) + if (desc->kind == AllocateDescFile && desc->file == file) return FreeDesc(desc); } @@ -2876,7 +2876,7 @@ CloseTransientFile(int fd) { AllocateDesc *desc = &allocatedDescs[i]; - if (desc->kind == AllocateDescRawFD && desc->desc.fd == fd) + if (desc->kind == AllocateDescRawFD && desc->fd == fd) return FreeDesc(desc); } @@ -2924,10 +2924,10 @@ AllocateDir(const char *dirname) AllocateDesc *desc = &allocatedDescs[numAllocatedDescs]; desc->kind = AllocateDescDir; - desc->desc.dir = dir; + desc->dir = dir; desc->create_subid = GetCurrentSubTransactionId(); numAllocatedDescs++; - return desc->desc.dir; + return desc->dir; } if (errno == EMFILE || errno == ENFILE) @@ -3034,7 +3034,7 @@ FreeDir(DIR *dir) { AllocateDesc *desc = &allocatedDescs[i]; - if (desc->kind == AllocateDescDir && desc->desc.dir == dir) + if (desc->kind == AllocateDescDir && desc->dir == dir) return FreeDesc(desc); } @@ -3060,7 +3060,7 @@ ClosePipeStream(FILE *file) { AllocateDesc *desc = &allocatedDescs[i]; - if (desc->kind == AllocateDescPipe && desc->desc.file == file) + if (desc->kind == AllocateDescPipe && desc->file == file) return FreeDesc(desc); } -- 2.51.0