Skip to content

Commit

Permalink
improve: use nullptr instead of NULL (#3349)
Browse files Browse the repository at this point in the history
* improve: use nullptr instead of NULL

* fix

* improve: use NULL in extern "C"

* improve: use NULL if not have #pragma once
  • Loading branch information
huanghantao authored May 29, 2020
1 parent 348b5ad commit f1a6661
Show file tree
Hide file tree
Showing 91 changed files with 997 additions and 997 deletions.
20 changes: 10 additions & 10 deletions include/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -755,17 +755,17 @@ static sw_inline swString* swTaskWorker_large_unpack(swEventData *task_result)
if (tmp_file_fd < 0)
{
swSysWarn("open(%s) failed", _pkg.tmpfile);
return NULL;
return nullptr;
}
if (SwooleTG.buffer_stack->size < _pkg.length && swString_extend_align(SwooleTG.buffer_stack, _pkg.length) < 0)
{
close(tmp_file_fd);
return NULL;
return nullptr;
}
if (swoole_sync_readfile(tmp_file_fd, SwooleTG.buffer_stack->str, _pkg.length) != _pkg.length)
{
close(tmp_file_fd);
return NULL;
return nullptr;
}
close(tmp_file_fd);
if (!(swTask_type(task_result) & SW_TASK_PEEK))
Expand All @@ -792,7 +792,7 @@ static sw_inline swConnection* swServer_connection_get(swServer *serv, int fd)
{
if ((uint32_t) fd > serv->max_connection)
{
return NULL;
return nullptr;
}
return &serv->connection_list[fd];
}
Expand Down Expand Up @@ -835,7 +835,7 @@ static sw_inline swWorker* swServer_get_worker(swServer *serv, uint16_t worker_i
return &(serv->user_workers[worker_id - task_worker_max]);
}

return NULL;
return nullptr;
}

static sw_inline int swServer_worker_schedule(swServer *serv, int fd, swSendData *data)
Expand Down Expand Up @@ -866,7 +866,7 @@ static sw_inline int swServer_worker_schedule(swServer *serv, int fd, swSendData
{
swConnection *conn = swServer_connection_get(serv, fd);
//UDP
if (conn == NULL)
if (conn == nullptr)
{
key = fd;
}
Expand All @@ -890,7 +890,7 @@ static sw_inline int swServer_worker_schedule(swServer *serv, int fd, swSendData
else if (serv->dispatch_mode == SW_DISPATCH_UIDMOD)
{
swConnection *conn = swServer_connection_get(serv, fd);
if (conn == NULL || conn->uid == 0)
if (conn == nullptr || conn->uid == 0)
{
key = fd;
}
Expand Down Expand Up @@ -947,11 +947,11 @@ static sw_inline swConnection *swServer_connection_verify_no_ssl(swServer *serv,
swConnection *conn = swServer_connection_get(serv, fd);
if (!conn || conn->active == 0)
{
return NULL;
return nullptr;
}
if (session->id != session_id || conn->session_id != session_id)
{
return NULL;
return nullptr;
}
return conn;
}
Expand All @@ -963,7 +963,7 @@ static sw_inline swConnection *swServer_connection_verify(swServer *serv, int se
if (conn && conn->ssl && !conn->ssl_ready)
{
swoole_error_log(SW_LOG_NOTICE, SW_ERROR_SSL_NOT_READY, "SSL not ready");
return NULL;
return nullptr;
}
#endif
return conn;
Expand Down
2 changes: 1 addition & 1 deletion include/swoole_cxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class CallbackManager

static inline int hook_add(void **hooks, int type, swCallback func, int push_back)
{
if (hooks[type] == NULL)
if (hooks[type] == nullptr)
{
hooks[type] = new std::list<swCallback>;
}
Expand Down
2 changes: 1 addition & 1 deletion include/wrapper/server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct DataBuffer
DataBuffer()
{
length = 0;
buffer = NULL;
buffer = nullptr;
}

DataBuffer(const char *str)
Expand Down
2 changes: 1 addition & 1 deletion php_swoole_cxx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ bool zend::include(std::string file)
}
else
{
new_op_array = NULL;
new_op_array = nullptr;
zend_file_handle_dtor(&file_handle);
}
zend_string_release(opened_path);
Expand Down
4 changes: 2 additions & 2 deletions php_swoole_cxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class ArrayIterator
else
{
_index = _ptr->h;
_key = NULL;
_key = nullptr;
}
break;
}
Expand Down Expand Up @@ -354,7 +354,7 @@ namespace function
}
else
{
success = sw_zend_call_function_ex(NULL, fci_cache, argc, argv, retval) == SUCCESS;
success = sw_zend_call_function_ex(nullptr, fci_cache, argc, argv, retval) == SUCCESS;
}
/* we have no chance to return to ZendVM to check the exception */
if (UNEXPECTED(EG(exception)))
Expand Down
Loading

0 comments on commit f1a6661

Please sign in to comment.