From 90884d93a9cd4c2b3c160322dfee61572d2db270 Mon Sep 17 00:00:00 2001 From: Alexander Turenko Date: Fri, 17 Jul 2020 15:26:06 +0300 Subject: [PATCH] code health: don't mix FAILURE and -1 in get_spaceno_by_name() Technically we should return FAILURE (not -1) from the changed function in case of a failure. FAILURE is -1 in fact and it unlikely will be changed, but the only formal guarantee we have is that FAILURE is a negative value. Cited from [1]: | typedef enum { | SUCCESS = 0, | FAILURE = -1, /* this MUST stay a negative number, or it may affect functions! */ | } ZEND_RESULT_CODE; No behaviour actually changed in this commit. It is the follow up for 5647d24667a48ca3e9242c33fca86ab73b580652 ('Fix select() by space_no and index_name'), where we initially set eyes on this point. [1]: https://github.com/php/php-src/blob/4903f7c5fde11a115f659ec54a1d0ede6fd7232c/Zend/zend_types.h#L53-L56 Follows up #42. --- src/tarantool.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tarantool.c b/src/tarantool.c index 5f95845..5f8ec35 100644 --- a/src/tarantool.c +++ b/src/tarantool.c @@ -694,6 +694,7 @@ int get_spaceno_by_name(tarantool_connection *obj, zval *name) { Z_LVAL_P(name)); if (space_no == -1) { THROW_EXC("No space %d defined", Z_LVAL_P(name)); + return FAILURE; } } else { space_no = tarantool_schema_get_sid_by_string(obj->schema, @@ -701,6 +702,7 @@ int get_spaceno_by_name(tarantool_connection *obj, zval *name) { Z_STRLEN_P(name)); if (space_no == -1) { THROW_EXC("No space '%s' defined", Z_STRVAL_P(name)); + return FAILURE; } }