From 0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 13:23:58 +0200 Subject: Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027. --- platform/linuxbsd/os_linuxbsd.cpp | 25 ------------------------- 1 file changed, 25 deletions(-) (limited to 'platform/linuxbsd/os_linuxbsd.cpp') diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp index 7b76f7394b..7c7a27add0 100644 --- a/platform/linuxbsd/os_linuxbsd.cpp +++ b/platform/linuxbsd/os_linuxbsd.cpp @@ -55,21 +55,18 @@ #endif void OS_LinuxBSD::initialize() { - crash_handler.initialize(); OS_Unix::initialize_core(); } void OS_LinuxBSD::initialize_joypads() { - #ifdef JOYDEV_ENABLED joypad = memnew(JoypadLinux(Input::get_singleton())); #endif } String OS_LinuxBSD::get_unique_id() const { - static String machine_id; if (machine_id.empty()) { if (FileAccess *f = FileAccess::open("/etc/machine-id", FileAccess::READ)) { @@ -84,7 +81,6 @@ String OS_LinuxBSD::get_unique_id() const { } void OS_LinuxBSD::finalize() { - if (main_loop) memdelete(main_loop); main_loop = nullptr; @@ -99,24 +95,20 @@ void OS_LinuxBSD::finalize() { } MainLoop *OS_LinuxBSD::get_main_loop() const { - return main_loop; } void OS_LinuxBSD::delete_main_loop() { - if (main_loop) memdelete(main_loop); main_loop = nullptr; } void OS_LinuxBSD::set_main_loop(MainLoop *p_main_loop) { - main_loop = p_main_loop; } String OS_LinuxBSD::get_name() const { - #ifdef __linux__ return "Linux"; #elif defined(__FreeBSD__) @@ -129,7 +121,6 @@ String OS_LinuxBSD::get_name() const { } Error OS_LinuxBSD::shell_open(String p_uri) { - Error ok; List args; args.push_back(p_uri); @@ -144,12 +135,10 @@ Error OS_LinuxBSD::shell_open(String p_uri) { } bool OS_LinuxBSD::_check_internal_feature_support(const String &p_feature) { - return p_feature == "pc"; } String OS_LinuxBSD::get_config_path() const { - if (has_environment("XDG_CONFIG_HOME")) { return get_environment("XDG_CONFIG_HOME"); } else if (has_environment("HOME")) { @@ -160,7 +149,6 @@ String OS_LinuxBSD::get_config_path() const { } String OS_LinuxBSD::get_data_path() const { - if (has_environment("XDG_DATA_HOME")) { return get_environment("XDG_DATA_HOME"); } else if (has_environment("HOME")) { @@ -171,7 +159,6 @@ String OS_LinuxBSD::get_data_path() const { } String OS_LinuxBSD::get_cache_path() const { - if (has_environment("XDG_CACHE_HOME")) { return get_environment("XDG_CACHE_HOME"); } else if (has_environment("HOME")) { @@ -182,46 +169,37 @@ String OS_LinuxBSD::get_cache_path() const { } String OS_LinuxBSD::get_system_dir(SystemDir p_dir) const { - String xdgparam; switch (p_dir) { case SYSTEM_DIR_DESKTOP: { - xdgparam = "DESKTOP"; } break; case SYSTEM_DIR_DCIM: { - xdgparam = "PICTURES"; } break; case SYSTEM_DIR_DOCUMENTS: { - xdgparam = "DOCUMENTS"; } break; case SYSTEM_DIR_DOWNLOADS: { - xdgparam = "DOWNLOAD"; } break; case SYSTEM_DIR_MOVIES: { - xdgparam = "VIDEOS"; } break; case SYSTEM_DIR_MUSIC: { - xdgparam = "MUSIC"; } break; case SYSTEM_DIR_PICTURES: { - xdgparam = "PICTURES"; } break; case SYSTEM_DIR_RINGTONES: { - xdgparam = "MUSIC"; } break; @@ -237,7 +215,6 @@ String OS_LinuxBSD::get_system_dir(SystemDir p_dir) const { } void OS_LinuxBSD::run() { - force_quit = false; if (!main_loop) @@ -251,7 +228,6 @@ void OS_LinuxBSD::run() { //uint64_t frame=0; while (!force_quit) { - DisplayServer::get_singleton()->process_events(); // get rid of pending events #ifdef JOYDEV_ENABLED joypad->process_joypads(); @@ -363,7 +339,6 @@ Error OS_LinuxBSD::move_to_trash(const String &p_path) { } OS_LinuxBSD::OS_LinuxBSD() { - main_loop = nullptr; force_quit = false; -- cgit v1.2.3 From 0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 16:41:43 +0200 Subject: Style: Enforce braces around if blocks and loops Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html --- platform/linuxbsd/os_linuxbsd.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'platform/linuxbsd/os_linuxbsd.cpp') diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp index 7c7a27add0..09a5eca914 100644 --- a/platform/linuxbsd/os_linuxbsd.cpp +++ b/platform/linuxbsd/os_linuxbsd.cpp @@ -81,8 +81,9 @@ String OS_LinuxBSD::get_unique_id() const { } void OS_LinuxBSD::finalize() { - if (main_loop) + if (main_loop) { memdelete(main_loop); + } main_loop = nullptr; #ifdef ALSAMIDI_ENABLED @@ -99,8 +100,9 @@ MainLoop *OS_LinuxBSD::get_main_loop() const { } void OS_LinuxBSD::delete_main_loop() { - if (main_loop) + if (main_loop) { memdelete(main_loop); + } main_loop = nullptr; } @@ -125,11 +127,13 @@ Error OS_LinuxBSD::shell_open(String p_uri) { List args; args.push_back(p_uri); ok = execute("xdg-open", args, false); - if (ok == OK) + if (ok == OK) { return OK; + } ok = execute("gnome-open", args, false); - if (ok == OK) + if (ok == OK) { return OK; + } ok = execute("kde-open", args, false); return ok; } @@ -209,16 +213,18 @@ String OS_LinuxBSD::get_system_dir(SystemDir p_dir) const { List arg; arg.push_back(xdgparam); Error err = const_cast(this)->execute("xdg-user-dir", arg, true, nullptr, &pipe); - if (err != OK) + if (err != OK) { return "."; + } return pipe.strip_edges(); } void OS_LinuxBSD::run() { force_quit = false; - if (!main_loop) + if (!main_loop) { return; + } main_loop->init(); @@ -232,8 +238,9 @@ void OS_LinuxBSD::run() { #ifdef JOYDEV_ENABLED joypad->process_joypads(); #endif - if (Main::iteration()) + if (Main::iteration()) { break; + } }; main_loop->finish(); -- cgit v1.2.3