diff options
Diffstat (limited to 'drivers/unix')
-rw-r--r-- | drivers/unix/dir_access_unix.cpp | 14 | ||||
-rw-r--r-- | drivers/unix/file_access_unix.cpp | 12 | ||||
-rw-r--r-- | drivers/unix/ip_unix.cpp | 18 | ||||
-rw-r--r-- | drivers/unix/net_socket_posix.cpp | 16 | ||||
-rw-r--r-- | drivers/unix/os_unix.cpp | 20 | ||||
-rw-r--r-- | drivers/unix/os_unix.h | 2 | ||||
-rw-r--r-- | drivers/unix/rw_lock_posix.cpp | 2 | ||||
-rw-r--r-- | drivers/unix/thread_posix.cpp | 4 |
8 files changed, 44 insertions, 44 deletions
diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index 715bc56003..00103684c7 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -129,7 +129,7 @@ String DirAccessUnix::get_next() { dirent *entry = readdir(dir_stream); - if (entry == NULL) { + if (entry == nullptr) { list_dir_end(); return ""; } @@ -173,7 +173,7 @@ void DirAccessUnix::list_dir_end() { if (dir_stream) closedir(dir_stream); - dir_stream = 0; + dir_stream = nullptr; _cisdir = false; } @@ -207,7 +207,7 @@ static void _get_drives(List<String> *list) { char strings[4096]; while (getmntent_r(mtab, &mnt, strings, sizeof(strings))) { - if (mnt.mnt_dir != NULL && _filter_drive(&mnt)) { + if (mnt.mnt_dir != nullptr && _filter_drive(&mnt)) { // Avoid duplicates if (!list->find(mnt.mnt_dir)) { list->push_back(mnt.mnt_dir); @@ -306,7 +306,7 @@ Error DirAccessUnix::change_dir(String p_dir) { // prev_dir is the directory we are changing out of String prev_dir; char real_current_dir_name[2048]; - ERR_FAIL_COND_V(getcwd(real_current_dir_name, 2048) == NULL, ERR_BUG); + ERR_FAIL_COND_V(getcwd(real_current_dir_name, 2048) == nullptr, ERR_BUG); if (prev_dir.parse_utf8(real_current_dir_name)) prev_dir = real_current_dir_name; //no utf8, maybe latin? @@ -327,7 +327,7 @@ Error DirAccessUnix::change_dir(String p_dir) { String base = _get_root_path(); if (base != String() && !try_dir.begins_with(base)) { - ERR_FAIL_COND_V(getcwd(real_current_dir_name, 2048) == NULL, ERR_BUG); + ERR_FAIL_COND_V(getcwd(real_current_dir_name, 2048) == nullptr, ERR_BUG); String new_dir; new_dir.parse_utf8(real_current_dir_name); @@ -410,14 +410,14 @@ String DirAccessUnix::get_filesystem_type() const { DirAccessUnix::DirAccessUnix() { - dir_stream = 0; + dir_stream = nullptr; _cisdir = false; /* determine drive count */ // set current directory to an absolute path of the current directory char real_current_dir_name[2048]; - ERR_FAIL_COND(getcwd(real_current_dir_name, 2048) == NULL); + ERR_FAIL_COND(getcwd(real_current_dir_name, 2048) == nullptr); if (current_dir.parse_utf8(real_current_dir_name)) current_dir = real_current_dir_name; diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp index 91164dc3f9..4aa408a1f0 100644 --- a/drivers/unix/file_access_unix.cpp +++ b/drivers/unix/file_access_unix.cpp @@ -76,7 +76,7 @@ Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) { if (f) fclose(f); - f = NULL; + f = nullptr; path_src = p_path; path = fix_path(p_path); @@ -119,7 +119,7 @@ Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) { f = fopen(path.utf8().get_data(), mode_string); - if (f == NULL) { + if (f == nullptr) { switch (errno) { case ENOENT: { last_error = ERR_FILE_NOT_FOUND; @@ -155,7 +155,7 @@ void FileAccessUnix::close() { return; fclose(f); - f = NULL; + f = nullptr; if (close_notification_func) { close_notification_func(path, flags); @@ -175,7 +175,7 @@ void FileAccessUnix::close() { bool FileAccessUnix::is_open() const { - return (f != NULL); + return (f != nullptr); } String FileAccessUnix::get_path() const { @@ -352,10 +352,10 @@ FileAccess *FileAccessUnix::create_libc() { return memnew(FileAccessUnix); } -CloseNotificationFunc FileAccessUnix::close_notification_func = NULL; +CloseNotificationFunc FileAccessUnix::close_notification_func = nullptr; FileAccessUnix::FileAccessUnix() : - f(NULL), + f(nullptr), flags(0), last_error(OK) { } diff --git a/drivers/unix/ip_unix.cpp b/drivers/unix/ip_unix.cpp index 08c099f771..5e3dedfc2f 100644 --- a/drivers/unix/ip_unix.cpp +++ b/drivers/unix/ip_unix.cpp @@ -107,13 +107,13 @@ IP_Address IP_Unix::_resolve_hostname(const String &p_hostname, Type p_type) { }; hints.ai_flags &= ~AI_NUMERICHOST; - int s = getaddrinfo(p_hostname.utf8().get_data(), NULL, &hints, &result); + int s = getaddrinfo(p_hostname.utf8().get_data(), nullptr, &hints, &result); if (s != 0) { ERR_PRINT("getaddrinfo failed! Cannot resolve hostname."); return IP_Address(); }; - if (result == NULL || result->ai_addr == NULL) { + if (result == nullptr || result->ai_addr == nullptr) { ERR_PRINT("Invalid response from getaddrinfo"); if (result) freeaddrinfo(result); @@ -175,7 +175,7 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co addrs = (IP_ADAPTER_ADDRESSES *)memalloc(buf_size); int err = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_FRIENDLY_NAME, - NULL, addrs, &buf_size); + nullptr, addrs, &buf_size); if (err == NO_ERROR) { break; }; @@ -189,7 +189,7 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co IP_ADAPTER_ADDRESSES *adapter = addrs; - while (adapter != NULL) { + while (adapter != nullptr) { Interface_Info info; info.name = adapter->AdapterName; @@ -197,7 +197,7 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co info.index = String::num_uint64(adapter->IfIndex); IP_ADAPTER_UNICAST_ADDRESS *address = adapter->FirstUnicastAddress; - while (address != NULL) { + while (address != nullptr) { int family = address->Address.lpSockaddr->sa_family; if (family != AF_INET && family != AF_INET6) continue; @@ -219,13 +219,13 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const { - struct ifaddrs *ifAddrStruct = NULL; - struct ifaddrs *ifa = NULL; + struct ifaddrs *ifAddrStruct = nullptr; + struct ifaddrs *ifa = nullptr; int family; getifaddrs(&ifAddrStruct); - for (ifa = ifAddrStruct; ifa != NULL; ifa = ifa->ifa_next) { + for (ifa = ifAddrStruct; ifa != nullptr; ifa = ifa->ifa_next) { if (!ifa->ifa_addr) continue; @@ -248,7 +248,7 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co info.ip_addresses.push_front(_sockaddr2ip(ifa->ifa_addr)); } - if (ifAddrStruct != NULL) freeifaddrs(ifAddrStruct); + if (ifAddrStruct != nullptr) freeifaddrs(ifAddrStruct); } #endif diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp index 4adeeb1d9b..7c6543c3a2 100644 --- a/drivers/unix/net_socket_posix.cpp +++ b/drivers/unix/net_socket_posix.cpp @@ -86,7 +86,7 @@ #define SOCK_CLOSE closesocket // connect is broken on windows under certain conditions, reasons unknown: // See https://github.com/godotengine/webrtc-native/issues/6 -#define SOCK_CONNECT(p_sock, p_addr, p_addr_len) ::WSAConnect(p_sock, p_addr, p_addr_len, NULL, NULL, NULL, NULL) +#define SOCK_CONNECT(p_sock, p_addr, p_addr_len) ::WSAConnect(p_sock, p_addr, p_addr_len, nullptr, nullptr, nullptr, nullptr) // Workaround missing flag in MinGW #if defined(__MINGW32__) && !defined(SIO_UDP_NETRESET) @@ -155,7 +155,7 @@ NetSocket *NetSocketPosix::_create_func() { void NetSocketPosix::make_default() { #if defined(WINDOWS_ENABLED) - if (_create == NULL) { + if (_create == nullptr) { WSADATA data; WSAStartup(MAKEWORD(2, 2), &data); } @@ -165,10 +165,10 @@ void NetSocketPosix::make_default() { void NetSocketPosix::cleanup() { #if defined(WINDOWS_ENABLED) - if (_create != NULL) { + if (_create != nullptr) { WSACleanup(); } - _create = NULL; + _create = nullptr; #endif } @@ -446,15 +446,15 @@ Error NetSocketPosix::poll(PollType p_type, int p_timeout) const { #if defined(WINDOWS_ENABLED) bool ready = false; fd_set rd, wr, ex; - fd_set *rdp = NULL; - fd_set *wrp = NULL; + fd_set *rdp = nullptr; + fd_set *wrp = nullptr; FD_ZERO(&rd); FD_ZERO(&wr); FD_ZERO(&ex); FD_SET(_sock, &ex); struct timeval timeout = { p_timeout, 0 }; - // For blocking operation, pass NULL timeout pointer to select. - struct timeval *tp = NULL; + // For blocking operation, pass nullptr timeout pointer to select. + struct timeval *tp = nullptr; if (p_timeout >= 0) { // If timeout is non-negative, we want to specify the timeout instead. tp = &timeout; diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 76a89b2bb4..53c60951b7 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -109,7 +109,7 @@ void OS_Unix::initialize_debugging() { struct sigaction action; memset(&action, 0, sizeof(action)); action.sa_handler = handle_interrupt; - sigaction(SIGINT, &action, NULL); + sigaction(SIGINT, &action, nullptr); } } @@ -172,24 +172,24 @@ String OS_Unix::get_name() const { uint64_t OS_Unix::get_unix_time() const { - return time(NULL); + return time(nullptr); }; uint64_t OS_Unix::get_system_time_secs() const { struct timeval tv_now; - gettimeofday(&tv_now, NULL); + gettimeofday(&tv_now, nullptr); return uint64_t(tv_now.tv_sec); } uint64_t OS_Unix::get_system_time_msecs() const { struct timeval tv_now; - gettimeofday(&tv_now, NULL); + gettimeofday(&tv_now, nullptr); return uint64_t(tv_now.tv_sec) * 1000 + uint64_t(tv_now.tv_usec) / 1000; } OS::Date OS_Unix::get_date(bool utc) const { - time_t t = time(NULL); + time_t t = time(nullptr); struct tm *lt; if (utc) lt = gmtime(&t); @@ -209,7 +209,7 @@ OS::Date OS_Unix::get_date(bool utc) const { } OS::Time OS_Unix::get_time(bool utc) const { - time_t t = time(NULL); + time_t t = time(nullptr); struct tm *lt; if (utc) lt = gmtime(&t); @@ -224,7 +224,7 @@ OS::Time OS_Unix::get_time(bool utc) const { } OS::TimeZoneInfo OS_Unix::get_time_zone_info() const { - time_t t = time(NULL); + time_t t = time(nullptr); struct tm *lt = localtime(&t); char name[16]; strftime(name, 16, "%Z", lt); @@ -379,7 +379,7 @@ int OS_Unix::get_process_id() const { bool OS_Unix::has_environment(const String &p_var) const { - return getenv(p_var.utf8().get_data()) != NULL; + return getenv(p_var.utf8().get_data()) != nullptr; } String OS_Unix::get_locale() const { @@ -433,7 +433,7 @@ Error OS_Unix::get_dynamic_library_symbol_handle(void *p_library_handle, const S p_symbol_handle = dlsym(p_library_handle, p_name.utf8().get_data()); error = dlerror(); - if (error != NULL) { + if (error != nullptr) { ERR_FAIL_COND_V_MSG(!p_optional, ERR_CANT_RESOLVE, "Can't resolve symbol " + p_name + ". Error: " + error + "."); return ERR_CANT_RESOLVE; @@ -511,7 +511,7 @@ String OS_Unix::get_executable_path() const { int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; char buf[MAXPATHLEN]; size_t len = sizeof(buf); - if (sysctl(mib, 4, buf, &len, NULL, 0) != 0) { + if (sysctl(mib, 4, buf, &len, nullptr, 0) != 0) { WARN_PRINT("Couldn't get executable path from sysctl"); return OS::get_executable_path(); } diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h index c381890834..90679ddf1d 100644 --- a/drivers/unix/os_unix.h +++ b/drivers/unix/os_unix.h @@ -85,7 +85,7 @@ public: virtual void delay_usec(uint32_t p_usec) const; virtual uint64_t get_ticks_usec() const; - virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking = true, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false, Mutex *p_pipe_mutex = NULL); + virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking = true, ProcessID *r_child_id = nullptr, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr); virtual Error kill(const ProcessID &p_pid); virtual int get_process_id() const; diff --git a/drivers/unix/rw_lock_posix.cpp b/drivers/unix/rw_lock_posix.cpp index bb3eebd267..f219a0905c 100644 --- a/drivers/unix/rw_lock_posix.cpp +++ b/drivers/unix/rw_lock_posix.cpp @@ -91,7 +91,7 @@ void RWLockPosix::make_default() { RWLockPosix::RWLockPosix() { //rwlock=PTHREAD_RWLOCK_INITIALIZER; fails on OSX - pthread_rwlock_init(&rwlock, NULL); + pthread_rwlock_init(&rwlock, nullptr); } RWLockPosix::~RWLockPosix() { diff --git a/drivers/unix/thread_posix.cpp b/drivers/unix/thread_posix.cpp index 21f49a7e38..c227aec6d6 100644 --- a/drivers/unix/thread_posix.cpp +++ b/drivers/unix/thread_posix.cpp @@ -75,7 +75,7 @@ void *ThreadPosix::thread_callback(void *userdata) { ScriptServer::thread_exit(); - return NULL; + return nullptr; } Thread *ThreadPosix::create_func_posix(ThreadCreateCallback p_callback, void *p_user, const Settings &) { @@ -108,7 +108,7 @@ void ThreadPosix::wait_to_finish_func_posix(Thread *p_thread) { ERR_FAIL_COND(!tp); ERR_FAIL_COND(tp->pthread == 0); - pthread_join(tp->pthread, NULL); + pthread_join(tp->pthread, nullptr); tp->pthread = 0; } |