diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-02-16 13:56:32 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-02-16 14:06:29 +0100 |
commit | b8b45804485f7ca18f035f1eeb7a1ac0cf591cac (patch) | |
tree | c0fb75bd8d45125f436ccf0b64fcbae464b11ad9 /drivers/unix | |
parent | f5b9cbaff6f0a058d08187b3124948ae68848cd0 (diff) |
Style: Cleanup single-line blocks, semicolons, dead code
Remove currently unused implementation of TextureBasisU, could be re-added
later on if needed and ported.
Diffstat (limited to 'drivers/unix')
-rw-r--r-- | drivers/unix/dir_access_unix.cpp | 12 | ||||
-rw-r--r-- | drivers/unix/file_access_unix.cpp | 9 | ||||
-rw-r--r-- | drivers/unix/ip_unix.cpp | 29 | ||||
-rw-r--r-- | drivers/unix/net_socket_posix.cpp | 16 | ||||
-rw-r--r-- | drivers/unix/os_unix.cpp | 9 | ||||
-rw-r--r-- | drivers/unix/syslog_logger.cpp | 2 |
6 files changed, 44 insertions, 33 deletions
diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index 5fdfde4913..af47173b41 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -138,9 +138,9 @@ uint64_t DirAccessUnix::get_modified_time(String p_file) { return flags.st_mtime; } else { ERR_FAIL_V(0); - }; + } return 0; -}; +} String DirAccessUnix::get_next() { if (!dir_stream) { @@ -320,11 +320,11 @@ Error DirAccessUnix::make_dir(String p_dir) { if (success) { return OK; - }; + } if (err == EEXIST) { return ERR_ALREADY_EXISTS; - }; + } return ERR_CANT_CREATE; } @@ -474,14 +474,14 @@ uint64_t DirAccessUnix::get_space_left() { struct statvfs vfs; if (statvfs(current_dir.utf8().get_data(), &vfs) != 0) { return 0; - }; + } return (uint64_t)vfs.f_bavail * (uint64_t)vfs.f_frsize; #else // FIXME: Implement this. return 0; #endif -}; +} String DirAccessUnix::get_filesystem_type() const { return ""; //TODO this should be implemented diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp index 80ae999ac9..ea442ad8bf 100644 --- a/drivers/unix/file_access_unix.cpp +++ b/drivers/unix/file_access_unix.cpp @@ -246,7 +246,7 @@ uint64_t FileAccessUnix::get_buffer(uint8_t *p_dst, uint64_t p_length) const { uint64_t read = fread(p_dst, 1, p_length, f); check_errors(); return read; -}; +} Error FileAccessUnix::get_error() const { return last_error; @@ -285,8 +285,9 @@ bool FileAccessUnix::file_exists(const String &p_path) { return false; } #else - if (_access(filename.utf8().get_data(), 4) == -1) + if (_access(filename.utf8().get_data(), 4) == -1) { return false; + } #endif // See if this is a regular file @@ -309,7 +310,7 @@ uint64_t FileAccessUnix::_get_modified_time(const String &p_file) { } else { print_verbose("Failed to get modified time for: " + p_file + ""); return 0; - }; + } } uint32_t FileAccessUnix::_get_unix_permissions(const String &p_file) { @@ -321,7 +322,7 @@ uint32_t FileAccessUnix::_get_unix_permissions(const String &p_file) { return flags.st_mode & 0x7FF; //only permissions } else { ERR_FAIL_V_MSG(0, "Failed to get unix permissions for: " + p_file + "."); - }; + } } Error FileAccessUnix::_set_unix_permissions(const String &p_file, uint32_t p_permissions) { diff --git a/drivers/unix/ip_unix.cpp b/drivers/unix/ip_unix.cpp index d82dcb8a8d..d442e521bf 100644 --- a/drivers/unix/ip_unix.cpp +++ b/drivers/unix/ip_unix.cpp @@ -72,10 +72,10 @@ static IPAddress _sockaddr2ip(struct sockaddr *p_addr) { } else if (p_addr->sa_family == AF_INET6) { struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)p_addr; ip.set_ipv6(addr6->sin6_addr.s6_addr); - }; + } return ip; -}; +} void IPUnix::_resolve_hostname(List<IPAddress> &r_addresses, const String &p_hostname, Type p_type) const { struct addrinfo hints; @@ -90,14 +90,14 @@ void IPUnix::_resolve_hostname(List<IPAddress> &r_addresses, const String &p_hos } else { hints.ai_family = AF_UNSPEC; hints.ai_flags = AI_ADDRCONFIG; - }; + } hints.ai_flags &= ~AI_NUMERICHOST; int s = getaddrinfo(p_hostname.utf8().get_data(), nullptr, &hints, &result); if (s != 0) { ERR_PRINT("getaddrinfo failed! Cannot resolve hostname."); return; - }; + } if (result == nullptr || result->ai_addr == nullptr) { ERR_PRINT("Invalid response from getaddrinfo"); @@ -105,7 +105,7 @@ void IPUnix::_resolve_hostname(List<IPAddress> &r_addresses, const String &p_hos freeaddrinfo(result); } return; - }; + } struct addrinfo *next = result; @@ -138,8 +138,9 @@ void IPUnix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) con for (int i = 0; i < hostnames->Size; i++) { auto hostname = hostnames->GetAt(i); - if (hostname->Type != HostNameType::Ipv4 && hostname->Type != HostNameType::Ipv6) + if (hostname->Type != HostNameType::Ipv4 && hostname->Type != HostNameType::Ipv6) { continue; + } String name = hostname->RawName->Data(); Map<String, Interface_Info>::Element *E = r_interfaces->find(name); @@ -171,14 +172,14 @@ void IPUnix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) con nullptr, addrs, &buf_size); if (err == NO_ERROR) { break; - }; + } memfree(addrs); if (err == ERROR_BUFFER_OVERFLOW) { continue; // will go back and alloc the right size - }; + } ERR_FAIL_MSG("Call to GetAdaptersAddresses failed with error " + itos(err) + "."); - }; + } IP_ADAPTER_ADDRESSES *adapter = addrs; @@ -191,19 +192,21 @@ void IPUnix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) con IP_ADAPTER_UNICAST_ADDRESS *address = adapter->FirstUnicastAddress; while (address != nullptr) { int family = address->Address.lpSockaddr->sa_family; - if (family != AF_INET && family != AF_INET6) + if (family != AF_INET && family != AF_INET6) { continue; + } info.ip_addresses.push_front(_sockaddr2ip(address->Address.lpSockaddr)); address = address->Next; } adapter = adapter->Next; // Only add interface if it has at least one IP - if (info.ip_addresses.size() > 0) + if (info.ip_addresses.size() > 0) { r_interfaces->insert(info.name, info); - }; + } + } memfree(addrs); -}; +} #endif diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp index bdfd264a0c..3130d5cae2 100644 --- a/drivers/unix/net_socket_posix.cpp +++ b/drivers/unix/net_socket_posix.cpp @@ -147,7 +147,7 @@ void NetSocketPosix::_set_ip_port(struct sockaddr_storage *p_addr, IPAddress *r_ if (r_port) { *r_port = ntohs(addr6->sin6_port); } - }; + } } NetSocket *NetSocketPosix::_create_func() { @@ -325,8 +325,9 @@ Error NetSocketPosix::open(Type p_sock_type, IP::Type &ip_type) { #if defined(__OpenBSD__) // OpenBSD does not support dual stacking, fallback to IPv4 only. - if (ip_type == IP::TYPE_ANY) + if (ip_type == IP::TYPE_ANY) { ip_type = IP::TYPE_IPV4; + } #endif int family = ip_type == IP::TYPE_IPV4 ? AF_INET : AF_INET6; @@ -420,7 +421,7 @@ Error NetSocketPosix::listen(int p_max_pending) { print_verbose("Failed to listen from socket."); close(); return FAILED; - }; + } return OK; } @@ -494,8 +495,9 @@ Error NetSocketPosix::poll(PollType p_type, int p_timeout) const { return FAILED; } - if (ret == 0) + if (ret == 0) { return ERR_BUSY; + } if (FD_ISSET(_sock, &ex)) { _get_socket_error(); @@ -503,10 +505,12 @@ Error NetSocketPosix::poll(PollType p_type, int p_timeout) const { return FAILED; } - if (rdp && FD_ISSET(_sock, rdp)) + if (rdp && FD_ISSET(_sock, rdp)) { ready = true; - if (wrp && FD_ISSET(_sock, wrp)) + } + if (wrp && FD_ISSET(_sock, wrp)) { ready = true; + } return ready ? OK : ERR_BUSY; #else diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 7d57926757..088525647c 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -106,7 +106,7 @@ static void _setup_clock() { void OS_Unix::debug_break() { assert(false); -}; +} static void handle_interrupt(int sig) { if (!EngineDebugger::is_active()) { @@ -198,7 +198,7 @@ double OS_Unix::get_unix_time() const { struct timeval tv_now; gettimeofday(&tv_now, nullptr); return (double)tv_now.tv_sec + double(tv_now.tv_usec) / 1000000; -}; +} OS::Date OS_Unix::get_date(bool p_utc) const { time_t t = time(nullptr); @@ -410,7 +410,7 @@ Error OS_Unix::kill(const ProcessID &p_pid) { int OS_Unix::get_process_id() const { return getpid(); -}; +} bool OS_Unix::has_environment(const String &p_var) const { return getenv(p_var.utf8().get_data()) != nullptr; @@ -555,8 +555,9 @@ String OS_Unix::get_executable_path() const { char *resolved_path = new char[buff_size + 1]; - if (_NSGetExecutablePath(resolved_path, &buff_size) == 1) + if (_NSGetExecutablePath(resolved_path, &buff_size) == 1) { WARN_PRINT("MAXPATHLEN is too small"); + } String path(resolved_path); delete[] resolved_path; diff --git a/drivers/unix/syslog_logger.cpp b/drivers/unix/syslog_logger.cpp index 0e1a1a89a3..6189d645c6 100644 --- a/drivers/unix/syslog_logger.cpp +++ b/drivers/unix/syslog_logger.cpp @@ -31,7 +31,9 @@ #ifdef UNIX_ENABLED #include "syslog_logger.h" + #include "core/string/print_string.h" + #include <syslog.h> void SyslogLogger::logv(const char *p_format, va_list p_list, bool p_err) { |