0007-Fix-compilation-failures-in-previous-patche-20250228.patch
text/x-patch
Filename: 0007-Fix-compilation-failures-in-previous-patche-20250228.patch
Type: text/x-patch
Part: 7
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch 0007
Subject: Fix compilation failures in previous patches
| File | + | − |
|---|---|---|
| src/backend/port/sysv_shmem.c | 17 | 5 |
From b1f510627937398ceb472f09b9b28f368a1201ea Mon Sep 17 00:00:00 2001
From: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Date: Tue, 25 Feb 2025 17:31:05 +0530
Subject: [PATCH 07/11] Fix compilation failures in previous patches
---
src/backend/port/sysv_shmem.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/src/backend/port/sysv_shmem.c b/src/backend/port/sysv_shmem.c
index 8864866f26c..992ed849dc0 100644
--- a/src/backend/port/sysv_shmem.c
+++ b/src/backend/port/sysv_shmem.c
@@ -825,16 +825,20 @@ CreateAnonymousSegment(AnonymousMapping *mapping)
* Specify the segment file size using allocsize, which contains
* potentially modified size.
*/
- ftruncate(mapping->segment_fd, allocsize);
+ if (ftruncate(mapping->segment_fd, allocsize) < 0)
+ ereport(FATAL,
+ (errcode(ERRCODE_SYSTEM_ERROR),
+ errmsg("could not set the size of file backing shared memory %p: %m",
+ mapping->shmem)));
- ptr = mmap(probe - offset, allocsize, PROT_READ | PROT_WRITE,
+ ptr = mmap((void *)((char *) probe - offset), allocsize, PROT_READ | PROT_WRITE,
PG_MMAP_FLAGS | MAP_FIXED_NOREPLACE, mapping->segment_fd, 0);
mmap_errno = errno;
if (ptr == MAP_FAILED)
{
DebugMappings();
elog(DEBUG1, "segment[%s]: mmap(%zu) at address %p failed: %m",
- MappingName(mapping->shmem_segment), allocsize, probe - offset);
+ MappingName(mapping->shmem_segment), allocsize, ((void *) ((char *)probe - offset)));
}
}
@@ -848,7 +852,11 @@ CreateAnonymousSegment(AnonymousMapping *mapping)
allocsize = mapping->shmem_size;
/* Specify the segment file size using allocsize. */
- ftruncate(mapping->segment_fd, allocsize);
+ if (ftruncate(mapping->segment_fd, allocsize) < 0)
+ ereport(FATAL,
+ (errcode(ERRCODE_SYSTEM_ERROR),
+ errmsg("could not set the size of file backing shared memory %p: %m",
+ mapping->shmem)));
ptr = mmap(NULL, allocsize, PROT_READ | PROT_WRITE,
PG_MMAP_FLAGS, mapping->segment_fd, 0);
@@ -946,7 +954,11 @@ AnonymousShmemResize(void)
continue;
/* Resize the backing anon file. */
- ftruncate(m->segment_fd, new_size);
+ if (ftruncate(m->segment_fd, new_size) < 0)
+ ereport(FATAL,
+ (errcode(ERRCODE_SYSTEM_ERROR),
+ errmsg("could not resize file backing shared memory %p: %m",
+ m->shmem)));
/*
* Fail hard if faced any issues. In theory we could try to handle this
--
2.34.1