Skip to content

Commit

Permalink
AK, LibGfx, LibGUI: Initialize various variables to zero.
Browse files Browse the repository at this point in the history
The not initialized variables can lead to compiler warnings that
become errors with the -Werror flag.
  • Loading branch information
lnzero1dev authored and awesomekling committed Feb 25, 2020
1 parent cbf2881 commit 074d935
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions AK/Utf8View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Utf8CodepointIterator& Utf8CodepointIterator::operator++()
{
ASSERT(m_length > 0);

int codepoint_length_in_bytes;
int codepoint_length_in_bytes = 0;
u32 value;
bool first_byte_makes_sense = decode_first_byte(*m_ptr, codepoint_length_in_bytes, value);

Expand All @@ -169,7 +169,7 @@ Utf8CodepointIterator& Utf8CodepointIterator::operator++()
int Utf8CodepointIterator::codepoint_length_in_bytes() const
{
ASSERT(m_length > 0);
int codepoint_length_in_bytes;
int codepoint_length_in_bytes = 0;
u32 value;
bool first_byte_makes_sense = decode_first_byte(*m_ptr, codepoint_length_in_bytes, value);
ASSERT(first_byte_makes_sense);
Expand All @@ -180,8 +180,8 @@ u32 Utf8CodepointIterator::operator*() const
{
ASSERT(m_length > 0);

u32 codepoint_value_so_far;
int codepoint_length_in_bytes;
u32 codepoint_value_so_far = 0;
int codepoint_length_in_bytes = 0;

bool first_byte_makes_sense = decode_first_byte(m_ptr[0], codepoint_length_in_bytes, codepoint_value_so_far);
if (!first_byte_makes_sense) {
Expand Down
2 changes: 1 addition & 1 deletion Libraries/LibGfx/Color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ const LogStream& operator<<(const LogStream& stream, Color value)

bool IPC::decode(BufferStream& stream, Color& color)
{
u32 rgba;
u32 rgba = 0;
stream >> rgba;
if (stream.handle_read_failure())
return false;
Expand Down
2 changes: 1 addition & 1 deletion Libraries/LibGfx/GIFLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ RefPtr<Gfx::Bitmap> load_gif_impl(const u8* data, size_t data_size)
if (sentinel == 0x2c) {
images.append(make<ImageDescriptor>());
auto& image = images.last();
u8 packed_fields;
u8 packed_fields { 0 };
stream >> image.x;
stream >> image.y;
stream >> image.width;
Expand Down
4 changes: 2 additions & 2 deletions Libraries/LibGfx/Point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ namespace IPC {

bool decode(BufferStream& stream, Gfx::Point& point)
{
int x;
int y;
int x = 0;
int y = 0;
stream >> x;
stream >> y;
if (stream.handle_read_failure())
Expand Down
4 changes: 2 additions & 2 deletions Libraries/LibGfx/Size.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ namespace IPC {

bool decode(BufferStream& stream, Gfx::Size& size)
{
int width;
int height;
int width = 0;
int height = 0;
stream >> width;
stream >> height;
if (stream.handle_read_failure())
Expand Down

0 comments on commit 074d935

Please sign in to comment.