mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Ensure struct data members are given an initial value
While I don't suspect there are any uninitialize variable bugs present, it's still good to err on the side of safety and provide an initial value nonetheless.
This commit is contained in:
parent
95a23c2d05
commit
d6e1961112
@ -37,8 +37,8 @@ const unsigned int blockCount = 32;
|
|||||||
|
|
||||||
struct WorkItem
|
struct WorkItem
|
||||||
{
|
{
|
||||||
sf::Vertex* targetBuffer;
|
sf::Vertex* targetBuffer{};
|
||||||
unsigned int index;
|
unsigned int index{};
|
||||||
};
|
};
|
||||||
|
|
||||||
std::deque<WorkItem> workQueue;
|
std::deque<WorkItem> workQueue;
|
||||||
@ -50,8 +50,8 @@ std::recursive_mutex workQueueMutex;
|
|||||||
|
|
||||||
struct Setting
|
struct Setting
|
||||||
{
|
{
|
||||||
const char* name;
|
const char* name{};
|
||||||
float* value;
|
float* value{};
|
||||||
};
|
};
|
||||||
|
|
||||||
// Terrain noise parameters
|
// Terrain noise parameters
|
||||||
|
@ -74,5 +74,5 @@ private:
|
|||||||
bool m_isLoaded{};
|
bool m_isLoaded{};
|
||||||
|
|
||||||
// NOLINTNEXTLINE(readability-identifier-naming)
|
// NOLINTNEXTLINE(readability-identifier-naming)
|
||||||
static const sf::Font* s_font;
|
static inline const sf::Font* s_font{};
|
||||||
};
|
};
|
||||||
|
@ -21,8 +21,6 @@ std::random_device rd;
|
|||||||
std::mt19937 rng(rd());
|
std::mt19937 rng(rd());
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
const sf::Font* Effect::s_font = nullptr;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// "Pixelate" fragment shader
|
// "Pixelate" fragment shader
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -55,8 +55,8 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
struct Chunk
|
struct Chunk
|
||||||
{
|
{
|
||||||
const std::int16_t* samples; //!< Pointer to the audio samples
|
const std::int16_t* samples{}; //!< Pointer to the audio samples
|
||||||
std::size_t sampleCount; //!< Number of samples pointed by Samples
|
std::size_t sampleCount{}; //!< Number of samples pointed by Samples
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -547,18 +547,18 @@ private:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
struct StatesCache
|
struct StatesCache
|
||||||
{
|
{
|
||||||
bool enable; //!< Is the cache enabled?
|
bool enable{}; //!< Is the cache enabled?
|
||||||
bool glStatesSet{}; //!< Are our internal GL states set yet?
|
bool glStatesSet{}; //!< Are our internal GL states set yet?
|
||||||
bool viewChanged; //!< Has the current view changed since last draw?
|
bool viewChanged{}; //!< Has the current view changed since last draw?
|
||||||
bool scissorEnabled; //!< Is scissor testing enabled?
|
bool scissorEnabled{}; //!< Is scissor testing enabled?
|
||||||
bool stencilEnabled; //!< Is stencil testing enabled?
|
bool stencilEnabled{}; //!< Is stencil testing enabled?
|
||||||
BlendMode lastBlendMode; //!< Cached blending mode
|
BlendMode lastBlendMode; //!< Cached blending mode
|
||||||
StencilMode lastStencilMode; //!< Cached stencil
|
StencilMode lastStencilMode; //!< Cached stencil
|
||||||
std::uint64_t lastTextureId; //!< Cached texture
|
std::uint64_t lastTextureId{}; //!< Cached texture
|
||||||
CoordinateType lastCoordinateType; //!< Texture coordinate type
|
CoordinateType lastCoordinateType{}; //!< Texture coordinate type
|
||||||
bool texCoordsArrayEnabled; //!< Is GL_TEXTURE_COORD_ARRAY client state enabled?
|
bool texCoordsArrayEnabled{}; //!< Is GL_TEXTURE_COORD_ARRAY client state enabled?
|
||||||
bool useVertexCache; //!< Did we previously use the vertex cache?
|
bool useVertexCache{}; //!< Did we previously use the vertex cache?
|
||||||
std::array<Vertex, 4> vertexCache; //!< Pre-transformed vertices cache
|
std::array<Vertex, 4> vertexCache{}; //!< Pre-transformed vertices cache
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -96,7 +96,7 @@ struct SFML_GRAPHICS_API StencilValue
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
StencilValue(T) = delete;
|
StencilValue(T) = delete;
|
||||||
|
|
||||||
unsigned int value = 0u; //!< The stored stencil value
|
unsigned int value{}; //!< The stored stencil value
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -497,8 +497,8 @@ private:
|
|||||||
/// \code
|
/// \code
|
||||||
/// struct MyStruct
|
/// struct MyStruct
|
||||||
/// {
|
/// {
|
||||||
/// float number;
|
/// float number{};
|
||||||
/// std::int8_t integer;
|
/// std::int8_t integer{};
|
||||||
/// std::string str;
|
/// std::string str;
|
||||||
/// };
|
/// };
|
||||||
///
|
///
|
||||||
|
@ -45,10 +45,10 @@ namespace sf
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
struct SocketSelector::SocketSelectorImpl
|
struct SocketSelector::SocketSelectorImpl
|
||||||
{
|
{
|
||||||
fd_set allSockets; //!< Set containing all the sockets handles
|
fd_set allSockets{}; //!< Set containing all the sockets handles
|
||||||
fd_set socketsReady; //!< Set containing handles of the sockets that are ready
|
fd_set socketsReady{}; //!< Set containing handles of the sockets that are ready
|
||||||
int maxSocket; //!< Maximum socket handle
|
int maxSocket{}; //!< Maximum socket handle
|
||||||
int socketCount; //!< Number of socket handles
|
int socketCount{}; //!< Number of socket handles
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,14 +53,14 @@ namespace
|
|||||||
{
|
{
|
||||||
struct DrmFb
|
struct DrmFb
|
||||||
{
|
{
|
||||||
gbm_bo* bo;
|
gbm_bo* bo{};
|
||||||
std::uint32_t fbId;
|
std::uint32_t fbId{};
|
||||||
};
|
};
|
||||||
|
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
sf::priv::Drm drmNode;
|
sf::priv::Drm drmNode;
|
||||||
drmEventContext drmEventCtx;
|
drmEventContext drmEventCtx{};
|
||||||
pollfd pollFD;
|
pollfd pollFD{};
|
||||||
gbm_device* gbmDevice = nullptr;
|
gbm_device* gbmDevice = nullptr;
|
||||||
int contextCount = 0;
|
int contextCount = 0;
|
||||||
EGLDisplay display = EGL_NO_DISPLAY;
|
EGLDisplay display = EGL_NO_DISPLAY;
|
||||||
|
@ -43,16 +43,16 @@ namespace sf::priv
|
|||||||
{
|
{
|
||||||
struct Drm
|
struct Drm
|
||||||
{
|
{
|
||||||
int fileDescriptor;
|
int fileDescriptor{};
|
||||||
|
|
||||||
drmModeModeInfoPtr mode;
|
drmModeModeInfoPtr mode{};
|
||||||
std::uint32_t crtcId;
|
std::uint32_t crtcId{};
|
||||||
std::uint32_t connectorId;
|
std::uint32_t connectorId{};
|
||||||
|
|
||||||
drmModeCrtcPtr originalCrtc;
|
drmModeCrtcPtr originalCrtc{};
|
||||||
|
|
||||||
drmModeConnectorPtr savedConnector;
|
drmModeConnectorPtr savedConnector{};
|
||||||
drmModeEncoderPtr savedEncoder;
|
drmModeEncoderPtr savedEncoder{};
|
||||||
};
|
};
|
||||||
|
|
||||||
class WindowImplDRM;
|
class WindowImplDRM;
|
||||||
|
@ -425,7 +425,7 @@ struct GlContext::Impl
|
|||||||
// Structure to track which unshared object belongs to which context
|
// Structure to track which unshared object belongs to which context
|
||||||
struct UnsharedGlObject
|
struct UnsharedGlObject
|
||||||
{
|
{
|
||||||
std::uint64_t contextId;
|
std::uint64_t contextId{};
|
||||||
std::shared_ptr<void> object;
|
std::shared_ptr<void> object;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -564,17 +564,12 @@ m_cursorGrabbed(m_fullscreen)
|
|||||||
|
|
||||||
struct WMHints
|
struct WMHints
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags{MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS};
|
||||||
unsigned long functions;
|
unsigned long functions{};
|
||||||
unsigned long decorations;
|
unsigned long decorations{};
|
||||||
long inputMode;
|
long inputMode{};
|
||||||
unsigned long state;
|
unsigned long state{};
|
||||||
};
|
} hints;
|
||||||
|
|
||||||
auto hints = WMHints();
|
|
||||||
hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
|
|
||||||
hints.decorations = 0;
|
|
||||||
hints.functions = 0;
|
|
||||||
|
|
||||||
if (style & Style::Titlebar)
|
if (style & Style::Titlebar)
|
||||||
{
|
{
|
||||||
|
@ -79,9 +79,9 @@ IDirectInput8W* directInput = nullptr;
|
|||||||
|
|
||||||
struct JoystickRecord
|
struct JoystickRecord
|
||||||
{
|
{
|
||||||
GUID guid;
|
GUID guid{};
|
||||||
unsigned int index;
|
unsigned int index{};
|
||||||
bool plugged;
|
bool plugged{};
|
||||||
};
|
};
|
||||||
|
|
||||||
using JoystickList = std::vector<JoystickRecord>;
|
using JoystickList = std::vector<JoystickRecord>;
|
||||||
@ -89,8 +89,8 @@ JoystickList joystickList;
|
|||||||
|
|
||||||
struct JoystickBlacklistEntry
|
struct JoystickBlacklistEntry
|
||||||
{
|
{
|
||||||
unsigned int vendorId;
|
unsigned int vendorId{};
|
||||||
unsigned int productId;
|
unsigned int productId{};
|
||||||
};
|
};
|
||||||
|
|
||||||
using JoystickBlacklist = std::vector<JoystickBlacklistEntry>;
|
using JoystickBlacklist = std::vector<JoystickBlacklistEntry>;
|
||||||
|
@ -286,12 +286,12 @@ int WglContext::selectBestPixelFormat(HDC deviceContext, unsigned int bitsPerPix
|
|||||||
// we can cache the result of the lookup instead of having to perform it multiple times for the same inputs
|
// we can cache the result of the lookup instead of having to perform it multiple times for the same inputs
|
||||||
struct PixelFormatCacheEntry
|
struct PixelFormatCacheEntry
|
||||||
{
|
{
|
||||||
unsigned int bitsPerPixel;
|
unsigned int bitsPerPixel{};
|
||||||
unsigned int depthBits;
|
unsigned int depthBits{};
|
||||||
unsigned int stencilBits;
|
unsigned int stencilBits{};
|
||||||
unsigned int antialiasingLevel;
|
unsigned int antialiasingLevel{};
|
||||||
bool pbuffer;
|
bool pbuffer{};
|
||||||
int bestFormat;
|
int bestFormat{};
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::mutex cacheMutex;
|
static std::mutex cacheMutex;
|
||||||
|
@ -96,9 +96,10 @@ namespace sf::priv
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
struct WindowImpl::JoystickStatesImpl
|
struct WindowImpl::JoystickStatesImpl
|
||||||
{
|
{
|
||||||
JoystickState states[Joystick::Count]; //!< Previous state of the joysticks
|
JoystickState states[Joystick::Count]{}; //!< Previous state of the joysticks
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
std::unique_ptr<WindowImpl> WindowImpl::create(
|
std::unique_ptr<WindowImpl> WindowImpl::create(
|
||||||
VideoMode mode,
|
VideoMode mode,
|
||||||
|
@ -54,15 +54,15 @@
|
|||||||
/// Modifiers states
|
/// Modifiers states
|
||||||
struct ModifiersState
|
struct ModifiersState
|
||||||
{
|
{
|
||||||
BOOL rightShiftWasDown;
|
BOOL rightShiftWasDown{};
|
||||||
BOOL leftShiftWasDown;
|
BOOL leftShiftWasDown{};
|
||||||
BOOL rightCommandWasDown;
|
BOOL rightCommandWasDown{};
|
||||||
BOOL leftCommandWasDown;
|
BOOL leftCommandWasDown{};
|
||||||
BOOL rightAlternateWasDown;
|
BOOL rightAlternateWasDown{};
|
||||||
BOOL leftAlternateWasDown;
|
BOOL leftAlternateWasDown{};
|
||||||
BOOL leftControlWasDown;
|
BOOL leftControlWasDown{};
|
||||||
BOOL rightControlWasDown;
|
BOOL rightControlWasDown{};
|
||||||
BOOL capsLockWasOn;
|
BOOL capsLockWasOn{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,9 +1,24 @@
|
|||||||
#include <SFML/Audio/SoundStream.hpp>
|
#include <SFML/Audio/SoundStream.hpp>
|
||||||
|
|
||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
static_assert(!std::is_constructible_v<sf::SoundStream>);
|
TEST_CASE("[Audio] sf::SoundStream")
|
||||||
static_assert(!std::is_copy_constructible_v<sf::SoundStream>);
|
{
|
||||||
static_assert(!std::is_copy_assignable_v<sf::SoundStream>);
|
SECTION("Type traits")
|
||||||
static_assert(!std::is_nothrow_move_constructible_v<sf::SoundStream>);
|
{
|
||||||
static_assert(!std::is_nothrow_move_assignable_v<sf::SoundStream>);
|
STATIC_CHECK(!std::is_constructible_v<sf::SoundStream>);
|
||||||
|
STATIC_CHECK(!std::is_copy_constructible_v<sf::SoundStream>);
|
||||||
|
STATIC_CHECK(!std::is_copy_assignable_v<sf::SoundStream>);
|
||||||
|
STATIC_CHECK(!std::is_nothrow_move_constructible_v<sf::SoundStream>);
|
||||||
|
STATIC_CHECK(!std::is_nothrow_move_assignable_v<sf::SoundStream>);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Chunk")
|
||||||
|
{
|
||||||
|
const sf::SoundStream::Chunk chunk;
|
||||||
|
CHECK(chunk.samples == nullptr);
|
||||||
|
CHECK(chunk.sampleCount == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user