From a95c132cad71fa6ab52fa5b4062b8dba7a17458b Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 28 Jun 2018 14:43:21 +0200 Subject: [PATCH 1/3] fix for PHP 7.3 --- yac.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/yac.c b/yac.c index 807d349..c234daf 100644 --- a/yac.c +++ b/yac.c @@ -147,7 +147,9 @@ static int yac_add_impl(zend_string *prefix, zend_string *key, zval *value, int ret = yac_storage_update(ZSTR_VAL(key), ZSTR_LEN(key), (char *)&Z_DVAL_P(value), sizeof(double), flag, ttl, add, tv); break; case IS_STRING: +#if PHP_VERSION_ID < 70300 case IS_CONSTANT: +#endif { if (Z_STRLEN_P(value) > YAC_G(compress_threshold) || Z_STRLEN_P(value) > YAC_STORAGE_MAX_ENTRY_LEN) { int compressed_len; @@ -347,7 +349,9 @@ static zval * yac_get_impl(zend_string *prefix, zend_string *key, uint32_t *cas, efree(data); break; case IS_STRING: +#if PHP_VERSION_ID < 70300 case IS_CONSTANT: +#endif { if ((flag & YAC_ENTRY_COMPRESSED)) { size_t orig_len = ((uint32_t)flag >> YAC_ENTRY_ORIG_LEN_SHIT); From 6d067e07b31b6b805210c29894c73c21207dd70d Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 28 Jun 2018 14:54:52 +0200 Subject: [PATCH 2/3] fix [-Wformat] warnings --- yac.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/yac.c b/yac.c index c234daf..141833c 100644 --- a/yac.c +++ b/yac.c @@ -157,7 +157,7 @@ static int yac_add_impl(zend_string *prefix, zend_string *key, zval *value, int /* if longer than this, then we can not stored the length in flag */ if (Z_STRLEN_P(value) > YAC_ENTRY_MAX_ORIG_LEN) { - php_error_docref(NULL, E_WARNING, "Value is too long(%d bytes) to be stored", Z_STRLEN_P(value)); + php_error_docref(NULL, E_WARNING, "Value is too long(%ld bytes) to be stored", Z_STRLEN_P(value)); if (prefix->len) { zend_string_release(prefix_key); } @@ -176,7 +176,7 @@ static int yac_add_impl(zend_string *prefix, zend_string *key, zval *value, int } if (compressed_len > YAC_STORAGE_MAX_ENTRY_LEN) { - php_error_docref(NULL, E_WARNING, "Value is too long(%d bytes) to be stored", Z_STRLEN_P(value)); + php_error_docref(NULL, E_WARNING, "Value is too long(%ld bytes) to be stored", Z_STRLEN_P(value)); efree(compressed); if (prefix->len) { zend_string_release(prefix_key); @@ -1015,13 +1015,13 @@ PHP_MINFO_FUNCTION(yac) php_info_print_table_row(2, "Total Shared Memory Usage for keys(keys_memory_size)", buf); snprintf(buf, sizeof(buf), "%ld", inf->v_msize); php_info_print_table_row(2, "Total Shared Memory Usage for values(values_memory_size)", buf); - snprintf(buf, sizeof(buf), "%ld", inf->segment_size); + snprintf(buf, sizeof(buf), "%d", inf->segment_size); php_info_print_table_row(2, "Size of Shared Memory Segment(segment_size)", buf); - snprintf(buf, sizeof(buf), "%ld", inf->segments_num); + snprintf(buf, sizeof(buf), "%d", inf->segments_num); php_info_print_table_row(2, "Number of Segments (segment_num)", buf); - snprintf(buf, sizeof(buf), "%ld", inf->slots_size); + snprintf(buf, sizeof(buf), "%d", inf->slots_size); php_info_print_table_row(2, "Total Slots Number(slots_size)", buf); - snprintf(buf, sizeof(buf), "%ld", inf->slots_num); + snprintf(buf, sizeof(buf), "%d", inf->slots_num); php_info_print_table_row(2, "Total Used Slots(slots_num)", buf); php_info_print_table_end(); From 7fe254cb17a9b2f17bebd3b032f1d12870c2e4ab Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 28 Jun 2018 14:57:57 +0200 Subject: [PATCH 3/3] fix warnings to make gcc happy [-Wmaybe-uninitialized] and [-Wunused-variable] --- storage/allocator/yac_allocator.c | 3 --- yac.c | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/storage/allocator/yac_allocator.c b/storage/allocator/yac_allocator.c index 610616f..6f2024c 100644 --- a/storage/allocator/yac_allocator.c +++ b/storage/allocator/yac_allocator.c @@ -24,9 +24,6 @@ #include "storage/yac_storage.h" #include "yac_allocator.h" -static const yac_shared_memory_handlers *shared_memory_handler = NULL; -static const char *shared_model; - int yac_allocator_startup(unsigned long k_size, unsigned long size, char **msg) /* {{{ */ { char *p; yac_shared_segment *segments = NULL; diff --git a/yac.c b/yac.c index 141833c..56bbc4e 100644 --- a/yac.c +++ b/yac.c @@ -120,7 +120,7 @@ static int yac_add_impl(zend_string *prefix, zend_string *key, zval *value, int int ret = 0, flag = Z_TYPE_P(value); char *msg; time_t tv; - zend_string *prefix_key; + zend_string *prefix_key = NULL; if ((ZSTR_LEN(key) + prefix->len) > YAC_STORAGE_MAX_KEY_LEN) { php_error_docref(NULL, E_WARNING, "Key%s can not be longer than %d bytes", @@ -302,7 +302,7 @@ static zval * yac_get_impl(zend_string *prefix, zend_string *key, uint32_t *cas, uint32_t flag, size = 0; char *data, *msg; time_t tv; - zend_string *prefix_key; + zend_string *prefix_key = NULL; if ((ZSTR_LEN(key) + prefix->len) > YAC_STORAGE_MAX_KEY_LEN) { php_error_docref(NULL, E_WARNING, "Key%s can not be longer than %d bytes",