Skip to content

Commit 1173705

Browse files
committed
ext/opcache/zend_file_cache: simplify iovec initializer
1 parent 11f3cdc commit 1173705

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

ext/opcache/zend_file_cache.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,9 +1011,6 @@ int zend_file_cache_script_store(zend_persistent_script *script, bool in_shm)
10111011
int fd;
10121012
char *filename;
10131013
zend_file_cache_metainfo info;
1014-
#ifdef HAVE_SYS_UIO_H
1015-
struct iovec vec[3];
1016-
#endif
10171014
void *mem, *buf;
10181015

10191016
#ifdef HAVE_JIT
@@ -1078,14 +1075,13 @@ int zend_file_cache_script_store(zend_persistent_script *script, bool in_shm)
10781075
#endif
10791076

10801077
#ifdef HAVE_SYS_UIO_H
1081-
vec[0].iov_base = (void *)&info;
1082-
vec[0].iov_len = sizeof(info);
1083-
vec[1].iov_base = buf;
1084-
vec[1].iov_len = script->size;
1085-
vec[2].iov_base = ZSTR_VAL((zend_string*)ZCG(mem));
1086-
vec[2].iov_len = info.str_size;
1087-
1088-
if (writev(fd, vec, 3) != (ssize_t)(sizeof(info) + script->size + info.str_size)) {
1078+
const struct iovec vec[] = {
1079+
{ .iov_base = (void *)&info, .iov_len = sizeof(info) },
1080+
{ .iov_base = buf, .iov_len = script->size },
1081+
{ .iov_base = ZSTR_VAL((zend_string*)ZCG(mem)), .iov_len = info.str_size },
1082+
};
1083+
1084+
if (writev(fd, vec, sizeof(vec) / sizeof(vec[0])) != (ssize_t)(sizeof(info) + script->size + info.str_size)) {
10891085
zend_accel_error(ACCEL_LOG_WARNING, "opcache cannot write to file '%s'\n", filename);
10901086
zend_string_release_ex((zend_string*)ZCG(mem), 0);
10911087
close(fd);

0 commit comments

Comments
 (0)