Skip to content

Commit 7c20812

Browse files
committed
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 5647d24 ('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.
1 parent 5647d24 commit 7c20812

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/tarantool.c

+2
Original file line numberDiff line numberDiff line change
@@ -694,13 +694,15 @@ int get_spaceno_by_name(tarantool_connection *obj, zval *name) {
694694
Z_LVAL_P(name));
695695
if (space_no == -1) {
696696
THROW_EXC("No space %d defined", Z_LVAL_P(name));
697+
return FAILURE;
697698
}
698699
} else {
699700
space_no = tarantool_schema_get_sid_by_string(obj->schema,
700701
Z_STRVAL_P(name),
701702
Z_STRLEN_P(name));
702703
if (space_no == -1) {
703704
THROW_EXC("No space '%s' defined", Z_STRVAL_P(name));
705+
return FAILURE;
704706
}
705707
}
706708

0 commit comments

Comments
 (0)