diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-04-04 15:06:57 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-04-04 19:49:50 +0200 |
commit | f8ab79e68af20e18e1d868b64d6dfd0c429bc554 (patch) | |
tree | a9d2df2e2df939c189135b1c36a01e06b37b80b2 /platform | |
parent | 53317bbe146dd19a919685df8d846c55568daba1 (diff) |
Zero initialize all pointer class and struct members
This prevents the pitfall of UB when checking if they have been
assigned something valid by comparing to nullptr.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/os_android.h | 8 | ||||
-rw-r--r-- | platform/iphone/os_iphone.h | 6 | ||||
-rw-r--r-- | platform/linuxbsd/display_server_x11.h | 6 | ||||
-rw-r--r-- | platform/linuxbsd/gl_manager_x11.h | 4 | ||||
-rw-r--r-- | platform/linuxbsd/os_linuxbsd.h | 2 | ||||
-rw-r--r-- | platform/osx/joypad_osx.h | 2 | ||||
-rw-r--r-- | platform/uwp/joypad_uwp.h | 2 | ||||
-rw-r--r-- | platform/uwp/os_uwp.h | 10 | ||||
-rw-r--r-- | platform/windows/display_server_windows.h | 2 | ||||
-rw-r--r-- | platform/windows/gl_manager_windows.h | 2 | ||||
-rw-r--r-- | platform/windows/joypad_windows.h | 4 | ||||
-rw-r--r-- | platform/windows/os_windows.h | 4 |
12 files changed, 26 insertions, 26 deletions
diff --git a/platform/android/os_android.h b/platform/android/os_android.h index 48239b3f84..a40e17dc2c 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -52,7 +52,7 @@ private: #endif #if defined(VULKAN_ENABLED) - ANativeWindow *native_window; + ANativeWindow *native_window = nullptr; #endif mutable String data_dir_cache; @@ -60,10 +60,10 @@ private: AudioDriverOpenSL audio_driver_android; - MainLoop *main_loop; + MainLoop *main_loop = nullptr; - GodotJavaWrapper *godot_java; - GodotIOJavaWrapper *godot_io_java; + GodotJavaWrapper *godot_java = nullptr; + GodotIOJavaWrapper *godot_io_java = nullptr; public: static const char *ANDROID_EXEC_PATH; diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h index 3281ff0cdb..6a61f3a910 100644 --- a/platform/iphone/os_iphone.h +++ b/platform/iphone/os_iphone.h @@ -52,11 +52,11 @@ private: AudioDriverCoreAudio audio_driver; - iOS *ios; + iOS *ios = nullptr; - JoypadIPhone *joypad_iphone; + JoypadIPhone *joypad_iphone = nullptr; - MainLoop *main_loop; + MainLoop *main_loop = nullptr; virtual void initialize_core() override; virtual void initialize() override; diff --git a/platform/linuxbsd/display_server_x11.h b/platform/linuxbsd/display_server_x11.h index 0f44aa4b11..cd673d94d9 100644 --- a/platform/linuxbsd/display_server_x11.h +++ b/platform/linuxbsd/display_server_x11.h @@ -108,7 +108,7 @@ class DisplayServerX11 : public DisplayServer { #endif #if defined(DBUS_ENABLED) - FreeDesktopScreenSaver *screensaver; + FreeDesktopScreenSaver *screensaver = nullptr; bool keep_screen_on = false; #endif @@ -168,7 +168,7 @@ class DisplayServerX11 : public DisplayServer { String internal_clipboard_primary; Window xdnd_source_window; ::Display *x11_display; - char *xmbstring; + char *xmbstring = nullptr; int xmblen; unsigned long last_timestamp; ::Time last_keyrelease_time; @@ -249,7 +249,7 @@ class DisplayServerX11 : public DisplayServer { typedef void (*xrr_free_monitors_t)(xrr_monitor_info *monitors); xrr_get_monitors_t xrr_get_monitors; xrr_free_monitors_t xrr_free_monitors; - void *xrandr_handle; + void *xrandr_handle = nullptr; Bool xrandr_ext_ok; struct Property { diff --git a/platform/linuxbsd/gl_manager_x11.h b/platform/linuxbsd/gl_manager_x11.h index 0bb0a446ab..e89caf3b30 100644 --- a/platform/linuxbsd/gl_manager_x11.h +++ b/platform/linuxbsd/gl_manager_x11.h @@ -66,7 +66,7 @@ private: struct GLDisplay { GLDisplay() { context = nullptr; } ~GLDisplay(); - GLManager_X11_Private *context; + GLManager_X11_Private *context = nullptr; ::Display *x11_display; XVisualInfo x_vi; XSetWindowAttributes x_swa; @@ -82,7 +82,7 @@ private: LocalVector<GLWindow> _windows; LocalVector<GLDisplay> _displays; - GLWindow *_current_window; + GLWindow *_current_window = nullptr; void _internal_set_current_window(GLWindow *p_win); diff --git a/platform/linuxbsd/os_linuxbsd.h b/platform/linuxbsd/os_linuxbsd.h index d3857e85f8..7b912ddee3 100644 --- a/platform/linuxbsd/os_linuxbsd.h +++ b/platform/linuxbsd/os_linuxbsd.h @@ -63,7 +63,7 @@ class OS_LinuxBSD : public OS_Unix { CrashHandler crash_handler; - MainLoop *main_loop; + MainLoop *main_loop = nullptr; protected: virtual void initialize() override; diff --git a/platform/osx/joypad_osx.h b/platform/osx/joypad_osx.h index 4ca7fb1698..b09d5ce34a 100644 --- a/platform/osx/joypad_osx.h +++ b/platform/osx/joypad_osx.h @@ -94,7 +94,7 @@ class JoypadOSX { }; private: - Input *input; + Input *input = nullptr; IOHIDManagerRef hid_manager; Vector<joypad> device_list; diff --git a/platform/uwp/joypad_uwp.h b/platform/uwp/joypad_uwp.h index 29f5109056..0869f1961d 100644 --- a/platform/uwp/joypad_uwp.h +++ b/platform/uwp/joypad_uwp.h @@ -68,7 +68,7 @@ private: ControllerDevice controllers[MAX_CONTROLLERS]; - InputDefault *input; + InputDefault *input = nullptr; void OnGamepadAdded(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value); void OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value); diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h index 573d86af7c..f955be1da9 100644 --- a/platform/uwp/os_uwp.h +++ b/platform/uwp/os_uwp.h @@ -74,7 +74,7 @@ private: KEY_EVENT_BUFFER_SIZE = 512 }; - FILE *stdo; + FILE *stdo = nullptr; KeyEvent key_event_buffer[KEY_EVENT_BUFFER_SIZE]; int key_event_pos; @@ -87,16 +87,16 @@ private: bool outside; int old_x, old_y; Point2i center; - RenderingServer *rendering_server; + RenderingServer *rendering_server = nullptr; int pressrc; - ContextEGL_UWP *gl_context; + ContextEGL_UWP *gl_context = nullptr; Windows::UI::Core::CoreWindow ^ window; VideoMode video_mode; int video_driver_index; - MainLoop *main_loop; + MainLoop *main_loop = nullptr; AudioDriverXAudio2 audio_driver; @@ -111,7 +111,7 @@ private: CursorShape cursor_shape; - InputDefault *input; + InputDefault *input = nullptr; JoypadUWP ^ joypad; diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h index 71fedf2bca..fcf4b5a728 100644 --- a/platform/windows/display_server_windows.h +++ b/platform/windows/display_server_windows.h @@ -392,7 +392,7 @@ class DisplayServerWindows : public DisplayServer { Rect2i parent_safe_rect; }; - JoypadWindows *joypad; + JoypadWindows *joypad = nullptr; HHOOK mouse_monitor = nullptr; List<WindowID> popup_list; uint64_t time_since_popup = 0; diff --git a/platform/windows/gl_manager_windows.h b/platform/windows/gl_manager_windows.h index 6423c54855..f789cba327 100644 --- a/platform/windows/gl_manager_windows.h +++ b/platform/windows/gl_manager_windows.h @@ -75,7 +75,7 @@ private: LocalVector<GLWindow> _windows; LocalVector<GLDisplay> _displays; - GLWindow *_current_window; + GLWindow *_current_window = nullptr; PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT; PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT; diff --git a/platform/windows/joypad_windows.h b/platform/windows/joypad_windows.h index 4f15bcf080..d239471a5c 100644 --- a/platform/windows/joypad_windows.h +++ b/platform/windows/joypad_windows.h @@ -105,10 +105,10 @@ private: typedef DWORD(WINAPI *XInputGetState_t)(DWORD dwUserIndex, XINPUT_STATE *pState); typedef DWORD(WINAPI *XInputSetState_t)(DWORD dwUserIndex, XINPUT_VIBRATION *pVibration); - HWND *hWnd; + HWND *hWnd = nullptr; HANDLE xinput_dll; LPDIRECTINPUT8 dinput; - Input *input; + Input *input = nullptr; int id_to_change; int slider_count; diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 5bfd24327e..adeecf37c5 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -60,14 +60,14 @@ class JoypadWindows; class OS_Windows : public OS { #ifdef STDOUT_FILE - FILE *stdo; + FILE *stdo = nullptr; #endif uint64_t ticks_start; uint64_t ticks_per_second; HINSTANCE hInstance; - MainLoop *main_loop; + MainLoop *main_loop = nullptr; #ifdef WASAPI_ENABLED AudioDriverWASAPI driver_wasapi; |