From 8db0ad0cc668efbd8e06a8bfc6052c53403a6616 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 10 May 2023 23:57:08 -0500 Subject: [PATCH] Fix and enable -Wmaybe-uninitialized --- CMakeLists.txt | 2 +- src/platform/linux/misc.cpp | 12 +++++------- src/platform/macos/misc.mm | 12 +++++------- src/platform/windows/misc.cpp | 12 +++++------- src/video.cpp | 1 - 5 files changed, 16 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 74f16330..9ea49632 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,7 +140,7 @@ endif() find_package(Boost COMPONENTS locale log filesystem program_options REQUIRED) -list(APPEND SUNSHINE_COMPILE_OPTIONS -Wall -Wno-missing-braces -Wno-maybe-uninitialized -Wno-sign-compare) +list(APPEND SUNSHINE_COMPILE_OPTIONS -Wall -Wno-missing-braces -Wno-sign-compare) # enable system tray, we will disable this later if we cannot find the required package config on linux set(SUNSHINE_TRAY 1) diff --git a/src/platform/linux/misc.cpp b/src/platform/linux/misc.cpp index fe34ca50..73f6011a 100644 --- a/src/platform/linux/misc.cpp +++ b/src/platform/linux/misc.cpp @@ -103,15 +103,14 @@ namespace platf { std::string from_sockaddr(const sockaddr *const ip_addr) { - char data[INET6_ADDRSTRLEN]; + char data[INET6_ADDRSTRLEN] = {}; auto family = ip_addr->sa_family; if (family == AF_INET6) { inet_ntop(AF_INET6, &((sockaddr_in6 *) ip_addr)->sin6_addr, data, INET6_ADDRSTRLEN); } - - if (family == AF_INET) { + else if (family == AF_INET) { inet_ntop(AF_INET, &((sockaddr_in *) ip_addr)->sin_addr, data, INET_ADDRSTRLEN); } @@ -121,17 +120,16 @@ namespace platf { std::pair from_sockaddr_ex(const sockaddr *const ip_addr) { - char data[INET6_ADDRSTRLEN]; + char data[INET6_ADDRSTRLEN] = {}; auto family = ip_addr->sa_family; - std::uint16_t port; + std::uint16_t port = 0; if (family == AF_INET6) { inet_ntop(AF_INET6, &((sockaddr_in6 *) ip_addr)->sin6_addr, data, INET6_ADDRSTRLEN); port = ((sockaddr_in6 *) ip_addr)->sin6_port; } - - if (family == AF_INET) { + else if (family == AF_INET) { inet_ntop(AF_INET, &((sockaddr_in *) ip_addr)->sin_addr, data, INET_ADDRSTRLEN); port = ((sockaddr_in *) ip_addr)->sin_port; diff --git a/src/platform/macos/misc.mm b/src/platform/macos/misc.mm index b65f0a39..fb2b41b2 100644 --- a/src/platform/macos/misc.mm +++ b/src/platform/macos/misc.mm @@ -86,15 +86,14 @@ namespace platf { std::string from_sockaddr(const sockaddr *const ip_addr) { - char data[INET6_ADDRSTRLEN]; + char data[INET6_ADDRSTRLEN] = {}; auto family = ip_addr->sa_family; if (family == AF_INET6) { inet_ntop(AF_INET6, &((sockaddr_in6 *) ip_addr)->sin6_addr, data, INET6_ADDRSTRLEN); } - - if (family == AF_INET) { + else if (family == AF_INET) { inet_ntop(AF_INET, &((sockaddr_in *) ip_addr)->sin_addr, data, INET_ADDRSTRLEN); } @@ -104,17 +103,16 @@ namespace platf { std::pair from_sockaddr_ex(const sockaddr *const ip_addr) { - char data[INET6_ADDRSTRLEN]; + char data[INET6_ADDRSTRLEN] = {}; auto family = ip_addr->sa_family; - std::uint16_t port; + std::uint16_t port = 0; if (family == AF_INET6) { inet_ntop(AF_INET6, &((sockaddr_in6 *) ip_addr)->sin6_addr, data, INET6_ADDRSTRLEN); port = ((sockaddr_in6 *) ip_addr)->sin6_port; } - - if (family == AF_INET) { + else if (family == AF_INET) { inet_ntop(AF_INET, &((sockaddr_in *) ip_addr)->sin_addr, data, INET_ADDRSTRLEN); port = ((sockaddr_in *) ip_addr)->sin_port; diff --git a/src/platform/windows/misc.cpp b/src/platform/windows/misc.cpp index 428bbdd9..d16c1d6b 100644 --- a/src/platform/windows/misc.cpp +++ b/src/platform/windows/misc.cpp @@ -81,14 +81,13 @@ namespace platf { std::string from_sockaddr(const sockaddr *const socket_address) { - char data[INET6_ADDRSTRLEN]; + char data[INET6_ADDRSTRLEN] = {}; auto family = socket_address->sa_family; if (family == AF_INET6) { inet_ntop(AF_INET6, &((sockaddr_in6 *) socket_address)->sin6_addr, data, INET6_ADDRSTRLEN); } - - if (family == AF_INET) { + else if (family == AF_INET) { inet_ntop(AF_INET, &((sockaddr_in *) socket_address)->sin_addr, data, INET_ADDRSTRLEN); } @@ -97,16 +96,15 @@ namespace platf { std::pair from_sockaddr_ex(const sockaddr *const ip_addr) { - char data[INET6_ADDRSTRLEN]; + char data[INET6_ADDRSTRLEN] = {}; auto family = ip_addr->sa_family; - std::uint16_t port; + std::uint16_t port = 0; if (family == AF_INET6) { inet_ntop(AF_INET6, &((sockaddr_in6 *) ip_addr)->sin6_addr, data, INET6_ADDRSTRLEN); port = ((sockaddr_in6 *) ip_addr)->sin6_port; } - - if (family == AF_INET) { + else if (family == AF_INET) { inet_ntop(AF_INET, &((sockaddr_in *) ip_addr)->sin_addr, data, INET_ADDRSTRLEN); port = ((sockaddr_in *) ip_addr)->sin_port; } diff --git a/src/video.cpp b/src/video.cpp index ad68c923..593e9f4f 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -396,7 +396,6 @@ namespace video { struct sync_session_t { sync_session_ctx_t *ctx; - platf::img_t *img_tmp; session_t session; };