Skip to content

Minimal refactoring of CLI SAPI #8519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2022
Merged

Minimal refactoring of CLI SAPI #8519

merged 1 commit into from
May 9, 2022

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented May 9, 2022

More specific types, some cleanup and voidifying functions which always return SUCCESS

@iluuu1994 iluuu1994 self-requested a review May 9, 2022 06:40
@iluuu1994
Copy link
Member

I'll review this after work, if you can wait 🙂

@@ -2398,12 +2402,12 @@ static void php_cli_server_startup_workers(void) {
php_cli_server_worker++) {
pid_t pid = fork();

if (pid == FAILURE) {
if (pid < 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


server->is_running = 1;
out:
if (retval != SUCCESS) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I like the defensive/whitelist approach of != SUCCESS, and I can't find an objective argument in favor of changing this to == FAILURE. I feel that it's mostly a matter of taste :)

I'm not against this change, but unless we have a clear coding standard regarding this, we risk changing the same lines back and forth between different styles.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main reason I do these change is if I see != SUCCESS I don't know if the call can only return zend_result or some other value, as I have already seen that in the code base where it looks like the called function only returns zend_return but does not (e.g. returns 1) so it is more a mental marker for me. But I'm not really attached to the equality.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally agree with @arnaud-lb. I don't prefer one over the other, and I'm happy making one the default. But I fear that unless we do have a standard people keep changing things like this back and forth for no good reason.

@@ -241,23 +241,23 @@ static const char php_cli_server_css[] = "<style>\n" \
/* }}} */

#ifdef PHP_WIN32
int php_cli_server_get_system_time(char *buf) {
static bool php_cli_server_get_system_time(char *buf) {
Copy link
Member

@iluuu1994 iluuu1994 May 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this isn't your code, but the definition could be shared for all architectures.


server->is_running = 1;
out:
if (retval != SUCCESS) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally agree with @arnaud-lb. I don't prefer one over the other, and I'm happy making one the default. But I fear that unless we do have a standard people keep changing things like this back and forth for no good reason.

@Girgias Girgias merged commit 9601475 into php:master May 9, 2022
@Girgias Girgias deleted the cli-sapi branch May 9, 2022 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants