Skip to content

Commit abadf39

Browse files
committed
ext/opcache/zend_shared_alloc: make error_in strings const
This allows using string literals without implicitly casting away the `const`.
1 parent d1e6ad9 commit abadf39

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

ext/opcache/shared_alloc_mmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static void *find_prefered_mmap_base(size_t requested_size)
151151
}
152152
#endif
153153

154-
static int create_segments(size_t requested_size, zend_shared_segment ***shared_segments_p, int *shared_segments_count, char **error_in)
154+
static int create_segments(size_t requested_size, zend_shared_segment ***shared_segments_p, int *shared_segments_count, const char **error_in)
155155
{
156156
#ifdef MADV_HUGEPAGE
157157
/**

ext/opcache/shared_alloc_posix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ typedef struct {
3636
int shm_fd;
3737
} zend_shared_segment_posix;
3838

39-
static int create_segments(size_t requested_size, zend_shared_segment_posix ***shared_segments_p, int *shared_segments_count, char **error_in)
39+
static int create_segments(size_t requested_size, zend_shared_segment_posix ***shared_segments_p, int *shared_segments_count, const char **error_in)
4040
{
4141
zend_shared_segment_posix *shared_segment;
4242
char shared_segment_name[sizeof("/ZendAccelerator.") + 20];

ext/opcache/shared_alloc_shm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ typedef struct {
5050
int shm_id;
5151
} zend_shared_segment_shm;
5252

53-
static int create_segments(size_t requested_size, zend_shared_segment_shm ***shared_segments_p, int *shared_segments_count, char **error_in)
53+
static int create_segments(size_t requested_size, zend_shared_segment_shm ***shared_segments_p, int *shared_segments_count, const char **error_in)
5454
{
5555
int i;
5656
size_t allocate_size = 0, remaining_bytes = requested_size, seg_allocate_size;

ext/opcache/shared_alloc_win32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void zend_shared_alloc_unlock_win32(void)
112112
ReleaseMutex(memory_mutex);
113113
}
114114

115-
static int zend_shared_alloc_reattach(size_t requested_size, char **error_in)
115+
static int zend_shared_alloc_reattach(size_t requested_size, const char **error_in)
116116
{
117117
int err;
118118
void *wanted_mapping_base;
@@ -199,7 +199,7 @@ static int zend_shared_alloc_reattach(size_t requested_size, char **error_in)
199199
return SUCCESSFULLY_REATTACHED;
200200
}
201201

202-
static int create_segments(size_t requested_size, zend_shared_segment ***shared_segments_p, int *shared_segments_count, char **error_in)
202+
static int create_segments(size_t requested_size, zend_shared_segment ***shared_segments_p, int *shared_segments_count, const char **error_in)
203203
{
204204
int err = 0, ret;
205205
zend_shared_segment *shared_segment;

ext/opcache/zend_shared_alloc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ void zend_shared_alloc_create_lock(char *lockfile_path)
132132
}
133133
#endif
134134

135-
static void no_memory_bailout(size_t allocate_size, char *error)
135+
static void no_memory_bailout(size_t allocate_size, const char *error)
136136
{
137137
zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Unable to allocate shared memory segment of %zu bytes: %s: %s (%d)", allocate_size, error?error:"unknown", strerror(errno), errno );
138138
}
@@ -152,7 +152,7 @@ static void copy_shared_segments(void *to, void *from, int count, int size)
152152
}
153153
}
154154

155-
static int zend_shared_alloc_try(const zend_shared_memory_handler_entry *he, size_t requested_size, zend_shared_segment ***shared_segments_p, int *shared_segments_count, char **error_in)
155+
static int zend_shared_alloc_try(const zend_shared_memory_handler_entry *he, size_t requested_size, zend_shared_segment ***shared_segments_p, int *shared_segments_count, const char **error_in)
156156
{
157157
int res;
158158
g_shared_alloc_handler = he->handler;
@@ -186,7 +186,7 @@ int zend_shared_alloc_startup(size_t requested_size, size_t reserved_size)
186186
zend_shared_segment **tmp_shared_segments;
187187
size_t shared_segments_array_size;
188188
zend_smm_shared_globals tmp_shared_globals, *p_tmp_shared_globals;
189-
char *error_in = NULL;
189+
const char *error_in = NULL;
190190
const zend_shared_memory_handler_entry *he;
191191
int res = ALLOC_FAILURE;
192192
int i;

ext/opcache/zend_shared_alloc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ typedef struct _zend_shared_segment {
8080
void *p;
8181
} zend_shared_segment;
8282

83-
typedef int (*create_segments_t)(size_t requested_size, zend_shared_segment ***shared_segments, int *shared_segment_count, char **error_in);
83+
typedef int (*create_segments_t)(size_t requested_size, zend_shared_segment ***shared_segments, int *shared_segment_count, const char **error_in);
8484
typedef int (*detach_segment_t)(zend_shared_segment *shared_segment);
8585

8686
typedef struct {

0 commit comments

Comments
 (0)