diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/alsa/audio_driver_alsa.cpp | 15 | ||||
-rw-r--r-- | drivers/alsamidi/midi_driver_alsamidi.cpp | 6 | ||||
-rw-r--r-- | drivers/png/png_driver_common.cpp | 3 | ||||
-rw-r--r-- | drivers/pulseaudio/audio_driver_pulseaudio.cpp | 9 | ||||
-rw-r--r-- | drivers/register_driver_types.cpp | 3 | ||||
-rw-r--r-- | drivers/unix/dir_access_unix.cpp | 49 | ||||
-rw-r--r-- | drivers/unix/file_access_unix.cpp | 29 | ||||
-rw-r--r-- | drivers/unix/ip_unix.cpp | 12 | ||||
-rw-r--r-- | drivers/unix/net_socket_posix.cpp | 50 | ||||
-rw-r--r-- | drivers/unix/os_unix.cpp | 50 | ||||
-rw-r--r-- | drivers/unix/syslog_logger.cpp | 5 | ||||
-rw-r--r-- | drivers/unix/thread_posix.cpp | 3 |
12 files changed, 152 insertions, 82 deletions
diff --git a/drivers/alsa/audio_driver_alsa.cpp b/drivers/alsa/audio_driver_alsa.cpp index 895a746b20..414b0c28e0 100644 --- a/drivers/alsa/audio_driver_alsa.cpp +++ b/drivers/alsa/audio_driver_alsa.cpp @@ -252,8 +252,9 @@ Array AudioDriverALSA::get_device_list() { void **hints; - if (snd_device_name_hint(-1, "pcm", &hints) < 0) + if (snd_device_name_hint(-1, "pcm", &hints) < 0) { return list; + } for (void **n = hints; *n != nullptr; n++) { char *name = snd_device_name_get_hint(*n, "NAME"); @@ -267,10 +268,12 @@ Array AudioDriverALSA::get_device_list() { } } - if (desc != nullptr) + if (desc != nullptr) { free(desc); - if (name != nullptr) + } + if (name != nullptr) { free(name); + } } snd_device_name_free_hint(hints); @@ -288,14 +291,16 @@ void AudioDriverALSA::set_device(String device) { } void AudioDriverALSA::lock() { - if (!thread) + if (!thread) { return; + } mutex.lock(); } void AudioDriverALSA::unlock() { - if (!thread) + if (!thread) { return; + } mutex.unlock(); } diff --git a/drivers/alsamidi/midi_driver_alsamidi.cpp b/drivers/alsamidi/midi_driver_alsamidi.cpp index a4c9fbece8..69a6956c2b 100644 --- a/drivers/alsamidi/midi_driver_alsamidi.cpp +++ b/drivers/alsamidi/midi_driver_alsamidi.cpp @@ -127,8 +127,9 @@ void MIDIDriverALSAMidi::thread_func(void *p_udata) { Error MIDIDriverALSAMidi::open() { void **hints; - if (snd_device_name_hint(-1, "rawmidi", &hints) < 0) + if (snd_device_name_hint(-1, "rawmidi", &hints) < 0) { return ERR_CANT_OPEN; + } int i = 0; for (void **n = hints; *n != nullptr; n++) { @@ -142,8 +143,9 @@ Error MIDIDriverALSAMidi::open() { } } - if (name != nullptr) + if (name != nullptr) { free(name); + } } snd_device_name_free_hint(hints); diff --git a/drivers/png/png_driver_common.cpp b/drivers/png/png_driver_common.cpp index 68faff30fc..77d5e68826 100644 --- a/drivers/png/png_driver_common.cpp +++ b/drivers/png/png_driver_common.cpp @@ -122,8 +122,9 @@ Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image) { Error image_to_png(const Ref<Image> &p_image, Vector<uint8_t> &p_buffer) { Ref<Image> source_image = p_image->duplicate(); - if (source_image->is_compressed()) + if (source_image->is_compressed()) { source_image->decompress(); + } ERR_FAIL_COND_V(source_image->is_compressed(), FAILED); diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp index 8d704dae7b..ce0b8ade95 100644 --- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp +++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp @@ -581,14 +581,16 @@ void AudioDriverPulseAudio::set_device(String device) { } void AudioDriverPulseAudio::lock() { - if (!thread) + if (!thread) { return; + } mutex.lock(); } void AudioDriverPulseAudio::unlock() { - if (!thread) + if (!thread) { return; + } mutex.unlock(); } @@ -601,8 +603,9 @@ void AudioDriverPulseAudio::finish_device() { } void AudioDriverPulseAudio::finish() { - if (!thread) + if (!thread) { return; + } exit_thread = true; Thread::wait_to_finish(thread); diff --git a/drivers/register_driver_types.cpp b/drivers/register_driver_types.cpp index 6c1f50d8c2..f0deabec21 100644 --- a/drivers/register_driver_types.cpp +++ b/drivers/register_driver_types.cpp @@ -45,8 +45,9 @@ void register_core_driver_types() { } void unregister_core_driver_types() { - if (image_loader_png) + if (image_loader_png) { memdelete(image_loader_png); + } ResourceSaver::remove_resource_format_saver(resource_saver_png); resource_saver_png.unref(); diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index 5d435d5176..325a88b573 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -61,8 +61,9 @@ Error DirAccessUnix::list_dir_begin() { //chdir(current_path.utf8().get_data()); dir_stream = opendir(current_dir.utf8().get_data()); //chdir(real_current_dir_name); - if (!dir_stream) + if (!dir_stream) { return ERR_CANT_OPEN; //error! + } return OK; } @@ -70,8 +71,9 @@ Error DirAccessUnix::list_dir_begin() { bool DirAccessUnix::file_exists(String p_file) { GLOBAL_LOCK_FUNCTION - if (p_file.is_rel_path()) + if (p_file.is_rel_path()) { p_file = current_dir.plus_file(p_file); + } p_file = fix_path(p_file); @@ -88,8 +90,9 @@ bool DirAccessUnix::file_exists(String p_file) { bool DirAccessUnix::dir_exists(String p_dir) { GLOBAL_LOCK_FUNCTION - if (p_dir.is_rel_path()) + if (p_dir.is_rel_path()) { p_dir = get_current_dir().plus_file(p_dir); + } p_dir = fix_path(p_dir); @@ -100,8 +103,9 @@ bool DirAccessUnix::dir_exists(String p_dir) { } uint64_t DirAccessUnix::get_modified_time(String p_file) { - if (p_file.is_rel_path()) + if (p_file.is_rel_path()) { p_file = current_dir.plus_file(p_file); + } p_file = fix_path(p_file); @@ -117,8 +121,9 @@ uint64_t DirAccessUnix::get_modified_time(String p_file) { }; String DirAccessUnix::get_next() { - if (!dir_stream) + if (!dir_stream) { return ""; + } dirent *entry = readdir(dir_stream); @@ -161,8 +166,9 @@ bool DirAccessUnix::current_is_hidden() const { } void DirAccessUnix::list_dir_end() { - if (dir_stream) + if (dir_stream) { closedir(dir_stream); + } dir_stream = nullptr; _cisdir = false; } @@ -263,8 +269,9 @@ bool DirAccessUnix::drives_are_shortcuts() { Error DirAccessUnix::make_dir(String p_dir) { GLOBAL_LOCK_FUNCTION - if (p_dir.is_rel_path()) + if (p_dir.is_rel_path()) { p_dir = get_current_dir().plus_file(p_dir); + } p_dir = fix_path(p_dir); @@ -291,8 +298,9 @@ Error DirAccessUnix::change_dir(String p_dir) { String prev_dir; char real_current_dir_name[2048]; ERR_FAIL_COND_V(getcwd(real_current_dir_name, 2048) == nullptr, ERR_BUG); - if (prev_dir.parse_utf8(real_current_dir_name)) + if (prev_dir.parse_utf8(real_current_dir_name)) { prev_dir = real_current_dir_name; //no utf8, maybe latin? + } // try_dir is the directory we are trying to change into String try_dir = ""; @@ -330,22 +338,25 @@ String DirAccessUnix::get_current_dir(bool p_include_drive) { String base = _get_root_path(); if (base != "") { String bd = current_dir.replace_first(base, ""); - if (bd.begins_with("/")) + if (bd.begins_with("/")) { return _get_root_string() + bd.substr(1, bd.length()); - else + } else { return _get_root_string() + bd; + } } return current_dir; } Error DirAccessUnix::rename(String p_path, String p_new_path) { - if (p_path.is_rel_path()) + if (p_path.is_rel_path()) { p_path = get_current_dir().plus_file(p_path); + } p_path = fix_path(p_path); - if (p_new_path.is_rel_path()) + if (p_new_path.is_rel_path()) { p_new_path = get_current_dir().plus_file(p_new_path); + } p_new_path = fix_path(p_new_path); @@ -353,19 +364,22 @@ Error DirAccessUnix::rename(String p_path, String p_new_path) { } Error DirAccessUnix::remove(String p_path) { - if (p_path.is_rel_path()) + if (p_path.is_rel_path()) { p_path = get_current_dir().plus_file(p_path); + } p_path = fix_path(p_path); struct stat flags; - if ((stat(p_path.utf8().get_data(), &flags) != 0)) + if ((stat(p_path.utf8().get_data(), &flags) != 0)) { return FAILED; + } - if (S_ISDIR(flags.st_mode)) + if (S_ISDIR(flags.st_mode)) { return ::rmdir(p_path.utf8().get_data()) == 0 ? OK : FAILED; - else + } else { return ::unlink(p_path.utf8().get_data()) == 0 ? OK : FAILED; + } } size_t DirAccessUnix::get_space_left() { @@ -395,8 +409,9 @@ DirAccessUnix::DirAccessUnix() { // 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) == nullptr); - if (current_dir.parse_utf8(real_current_dir_name)) + if (current_dir.parse_utf8(real_current_dir_name)) { current_dir = real_current_dir_name; + } change_dir(current_dir); } diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp index 7edafce9e5..06bad9f385 100644 --- a/drivers/unix/file_access_unix.cpp +++ b/drivers/unix/file_access_unix.cpp @@ -71,8 +71,9 @@ void FileAccessUnix::check_errors() const { } Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) { - if (f) + if (f) { fclose(f); + } f = nullptr; path_src = p_path; @@ -82,16 +83,17 @@ Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) { ERR_FAIL_COND_V_MSG(f, ERR_ALREADY_IN_USE, "File is already in use."); const char *mode_string; - if (p_mode_flags == READ) + if (p_mode_flags == READ) { mode_string = "rb"; - else if (p_mode_flags == WRITE) + } else if (p_mode_flags == WRITE) { mode_string = "wb"; - else if (p_mode_flags == READ_WRITE) + } else if (p_mode_flags == READ_WRITE) { mode_string = "rb+"; - else if (p_mode_flags == WRITE_READ) + } else if (p_mode_flags == WRITE_READ) { mode_string = "wb+"; - else + } else { return ERR_INVALID_PARAMETER; + } /* pretty much every implementation that uses fopen as primary backend (unix-compatible mostly) supports utf8 encoding */ @@ -147,8 +149,9 @@ Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) { } void FileAccessUnix::close() { - if (!f) + if (!f) { return; + } fclose(f); f = nullptr; @@ -185,15 +188,17 @@ void FileAccessUnix::seek(size_t p_position) { ERR_FAIL_COND_MSG(!f, "File must be opened before use."); last_error = OK; - if (fseek(f, p_position, SEEK_SET)) + if (fseek(f, p_position, SEEK_SET)) { check_errors(); + } } void FileAccessUnix::seek_end(int64_t p_position) { ERR_FAIL_COND_MSG(!f, "File must be opened before use."); - if (fseek(f, p_position, SEEK_END)) + if (fseek(f, p_position, SEEK_END)) { check_errors(); + } } size_t FileAccessUnix::get_position() const { @@ -268,13 +273,15 @@ bool FileAccessUnix::file_exists(const String &p_path) { // Does the name exist at all? err = stat(filename.utf8().get_data(), &st); - if (err) + if (err) { return false; + } #ifdef UNIX_ENABLED // See if we have access to the file - if (access(filename.utf8().get_data(), F_OK)) + if (access(filename.utf8().get_data(), F_OK)) { return false; + } #else if (_access(filename.utf8().get_data(), 4) == -1) return false; diff --git a/drivers/unix/ip_unix.cpp b/drivers/unix/ip_unix.cpp index 2015a4041d..05eedccc1d 100644 --- a/drivers/unix/ip_unix.cpp +++ b/drivers/unix/ip_unix.cpp @@ -113,8 +113,9 @@ IP_Address IP_Unix::_resolve_hostname(const String &p_hostname, Type p_type) { if (result == nullptr || result->ai_addr == nullptr) { ERR_PRINT("Invalid response from getaddrinfo"); - if (result) + if (result) { freeaddrinfo(result); + } return IP_Address(); }; @@ -218,13 +219,15 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co getifaddrs(&ifAddrStruct); for (ifa = ifAddrStruct; ifa != nullptr; ifa = ifa->ifa_next) { - if (!ifa->ifa_addr) + if (!ifa->ifa_addr) { continue; + } family = ifa->ifa_addr->sa_family; - if (family != AF_INET && family != AF_INET6) + if (family != AF_INET && family != AF_INET6) { continue; + } Map<String, Interface_Info>::Element *E = r_interfaces->find(ifa->ifa_name); if (!E) { @@ -240,8 +243,9 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co info.ip_addresses.push_front(_sockaddr2ip(ifa->ifa_addr)); } - if (ifAddrStruct != nullptr) + if (ifAddrStruct != nullptr) { freeifaddrs(ifAddrStruct); + } } #endif diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp index 957a00703b..15ad187ab4 100644 --- a/drivers/unix/net_socket_posix.cpp +++ b/drivers/unix/net_socket_posix.cpp @@ -196,12 +196,15 @@ NetSocketPosix::NetError NetSocketPosix::_get_socket_error() const { print_verbose("Socket error: " + itos(err)); return ERR_NET_OTHER; #else - if (errno == EISCONN) + if (errno == EISCONN) { return ERR_NET_IS_CONNECTED; - if (errno == EINPROGRESS || errno == EALREADY) + } + if (errno == EINPROGRESS || errno == EALREADY) { return ERR_NET_IN_PROGRESS; - if (errno == EAGAIN || errno == EWOULDBLOCK) + } + if (errno == EAGAIN || errno == EWOULDBLOCK) { return ERR_NET_WOULD_BLOCK; + } print_verbose("Socket error: " + itos(errno)); return ERR_NET_OTHER; #endif @@ -238,16 +241,19 @@ _FORCE_INLINE_ Error NetSocketPosix::_change_multicast_group(IP_Address p_ip, St IP::get_singleton()->get_local_interfaces(&if_info); for (Map<String, IP::Interface_Info>::Element *E = if_info.front(); E; E = E->next()) { IP::Interface_Info &c = E->get(); - if (c.name != p_if_name) + if (c.name != p_if_name) { continue; + } if_v6id = (uint32_t)c.index.to_int64(); - if (type == IP::TYPE_IPV6) + if (type == IP::TYPE_IPV6) { break; // IPv6 uses index. + } for (List<IP_Address>::Element *F = c.ip_addresses.front(); F; F = F->next()) { - if (!F->get().is_ipv4()) + if (!F->get().is_ipv4()) { continue; // Wrong IP type + } if_ip = F->get(); break; } @@ -361,8 +367,9 @@ Error NetSocketPosix::open(Type p_sock_type, IP::Type &ip_type) { } void NetSocketPosix::close() { - if (_sock != SOCK_EMPTY) + if (_sock != SOCK_EMPTY) { SOCK_CLOSE(_sock); + } _sock = SOCK_EMPTY; _ip_type = IP::TYPE_NONE; @@ -508,8 +515,9 @@ Error NetSocketPosix::poll(PollType p_type, int p_timeout) const { return FAILED; } - if (ret == 0) + if (ret == 0) { return ERR_BUSY; + } return OK; #endif @@ -522,8 +530,9 @@ Error NetSocketPosix::recv(uint8_t *p_buffer, int p_len, int &r_read) { if (r_read < 0) { NetError err = _get_socket_error(); - if (err == ERR_NET_WOULD_BLOCK) + if (err == ERR_NET_WOULD_BLOCK) { return ERR_BUSY; + } return FAILED; } @@ -542,8 +551,9 @@ Error NetSocketPosix::recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Add if (r_read < 0) { NetError err = _get_socket_error(); - if (err == ERR_NET_WOULD_BLOCK) + if (err == ERR_NET_WOULD_BLOCK) { return ERR_BUSY; + } return FAILED; } @@ -569,15 +579,17 @@ Error NetSocketPosix::send(const uint8_t *p_buffer, int p_len, int &r_sent) { int flags = 0; #ifdef MSG_NOSIGNAL - if (_is_stream) + if (_is_stream) { flags = MSG_NOSIGNAL; + } #endif r_sent = ::send(_sock, SOCK_CBUF(p_buffer), p_len, flags); if (r_sent < 0) { NetError err = _get_socket_error(); - if (err == ERR_NET_WOULD_BLOCK) + if (err == ERR_NET_WOULD_BLOCK) { return ERR_BUSY; + } return FAILED; } @@ -594,8 +606,9 @@ Error NetSocketPosix::sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP if (r_sent < 0) { NetError err = _get_socket_error(); - if (err == ERR_NET_WOULD_BLOCK) + if (err == ERR_NET_WOULD_BLOCK) { return ERR_BUSY; + } return FAILED; } @@ -606,8 +619,9 @@ Error NetSocketPosix::sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP Error NetSocketPosix::set_broadcasting_enabled(bool p_enabled) { ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED); // IPv6 has no broadcast support. - if (_ip_type == IP::TYPE_IPV6) + if (_ip_type == IP::TYPE_IPV6) { return ERR_UNAVAILABLE; + } int par = p_enabled ? 1 : 0; if (setsockopt(_sock, SOL_SOCKET, SO_BROADCAST, SOCK_CBUF(&par), sizeof(int)) != 0) { @@ -626,14 +640,16 @@ void NetSocketPosix::set_blocking_enabled(bool p_enabled) { ret = SOCK_IOCTL(_sock, FIONBIO, &par); #else int opts = fcntl(_sock, F_GETFL); - if (p_enabled) + if (p_enabled) { ret = fcntl(_sock, F_SETFL, opts & ~O_NONBLOCK); - else + } else { ret = fcntl(_sock, F_SETFL, opts | O_NONBLOCK); + } #endif - if (ret != 0) + if (ret != 0) { WARN_PRINT("Unable to change non-block mode"); + } } void NetSocketPosix::set_ipv6_only_enabled(bool p_enabled) { diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 3ba667b2f7..083cd64116 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -95,8 +95,9 @@ void OS_Unix::debug_break() { }; static void handle_interrupt(int sig) { - if (!EngineDebugger::is_active()) + if (!EngineDebugger::is_active()) { return; + } EngineDebugger::get_script_debugger()->set_depth(-1); EngineDebugger::get_script_debugger()->set_lines_left(1); @@ -181,10 +182,11 @@ uint64_t OS_Unix::get_system_time_msecs() const { OS::Date OS_Unix::get_date(bool utc) const { time_t t = time(nullptr); struct tm *lt; - if (utc) + if (utc) { lt = gmtime(&t); - else + } else { lt = localtime(&t); + } Date ret; ret.year = 1900 + lt->tm_year; // Index starting at 1 to match OS_Unix::get_date @@ -201,10 +203,11 @@ OS::Date OS_Unix::get_date(bool utc) const { OS::Time OS_Unix::get_time(bool utc) const { time_t t = time(nullptr); struct tm *lt; - if (utc) + if (utc) { lt = gmtime(&t); - else + } else { lt = localtime(&t); + } Time ret; ret.hour = lt->tm_hour; ret.min = lt->tm_min; @@ -231,10 +234,11 @@ OS::TimeZoneInfo OS_Unix::get_time_zone_info() const { // convert from ISO 8601 (1 minute=1, 1 hour=100) to minutes int hour = (int)bias / 100; int minutes = bias % 100; - if (bias < 0) + if (bias < 0) { ret.bias = hour * 60 - minutes; - else + } else { ret.bias = hour * 60 + minutes; + } return ret; } @@ -295,8 +299,9 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo } } int rv = pclose(f); - if (r_exitcode) + if (r_exitcode) { *r_exitcode = WEXITSTATUS(rv); + } return OK; } @@ -315,12 +320,14 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo Vector<CharString> cs; cs.push_back(p_path.utf8()); - for (int i = 0; i < p_arguments.size(); i++) + for (int i = 0; i < p_arguments.size(); i++) { cs.push_back(p_arguments[i].utf8()); + } Vector<char *> args; - for (int i = 0; i < cs.size(); i++) + for (int i = 0; i < cs.size(); i++) { args.push_back((char *)cs[i].get_data()); + } args.push_back(0); execvp(p_path.utf8().get_data(), &args[0]); @@ -332,12 +339,14 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo if (p_blocking) { int status; waitpid(pid, &status, 0); - if (r_exitcode) + if (r_exitcode) { *r_exitcode = WEXITSTATUS(status); + } } else { - if (r_child_id) + if (r_child_id) { *r_child_id = pid; + } } return OK; @@ -363,13 +372,15 @@ bool OS_Unix::has_environment(const String &p_var) const { } String OS_Unix::get_locale() const { - if (!has_environment("LANG")) + if (!has_environment("LANG")) { return "en"; + } String locale = get_environment("LANG"); int tp = locale.find("."); - if (tp != -1) + if (tp != -1) { locale = locale.substr(0, tp); + } return locale; } @@ -420,15 +431,17 @@ Error OS_Unix::get_dynamic_library_symbol_handle(void *p_library_handle, const S } Error OS_Unix::set_cwd(const String &p_cwd) { - if (chdir(p_cwd.utf8().get_data()) != 0) + if (chdir(p_cwd.utf8().get_data()) != 0) { return ERR_CANT_OPEN; + } return OK; } String OS_Unix::get_environment(const String &p_var) const { - if (getenv(p_var.utf8().get_data())) + if (getenv(p_var.utf8().get_data())) { return getenv(p_var.utf8().get_data()); + } return ""; } @@ -516,10 +529,11 @@ void UnixTerminalLogger::log_error(const char *p_function, const char *p_file, i } const char *err_details; - if (p_rationale && p_rationale[0]) + if (p_rationale && p_rationale[0]) { err_details = p_rationale; - else + } else { err_details = p_code; + } // Disable color codes if stdout is not a TTY. // This prevents Godot from writing ANSI escape codes when redirecting diff --git a/drivers/unix/syslog_logger.cpp b/drivers/unix/syslog_logger.cpp index 8296d6ce30..a4c7070f0e 100644 --- a/drivers/unix/syslog_logger.cpp +++ b/drivers/unix/syslog_logger.cpp @@ -67,10 +67,11 @@ void SyslogLogger::print_error(const char *p_function, const char *p_file, int p } const char *err_details; - if (p_rationale && *p_rationale) + if (p_rationale && *p_rationale) { err_details = p_rationale; - else + } else { err_details = p_code; + } syslog(p_type == ERR_WARNING ? LOG_WARNING : LOG_ERR, "%s: %s\n At: %s:%i:%s() - %s", err_type, err_details, p_file, p_line, p_function, p_code); } diff --git a/drivers/unix/thread_posix.cpp b/drivers/unix/thread_posix.cpp index 16897883e8..aa1b5019ca 100644 --- a/drivers/unix/thread_posix.cpp +++ b/drivers/unix/thread_posix.cpp @@ -91,8 +91,9 @@ Thread *ThreadPosix::create_func_posix(ThreadCreateCallback p_callback, void *p_ Thread::ID ThreadPosix::get_thread_id_func_posix() { void *value = pthread_getspecific(thread_id_key); - if (value) + if (value) { return *static_cast<ID *>(value); + } ID new_id = atomic_increment(&next_thread_id); pthread_setspecific(thread_id_key, (void *)memnew(ID(new_id))); |