Skip to content

Commit 74728f4

Browse files
peter-blivecodeali
authored andcommitted
-Wmaybe-uninitialized fixes
1 parent 503aeba commit 74728f4

File tree

17 files changed

+34
-37
lines changed

17 files changed

+34
-37
lines changed

config/linux-settings.gypi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
'-Wno-unused-parameter', # Just contributes build noise
7272
'-Werror=return-type',
7373
'-Werror=uninitialized',
74-
'-Wno-error=maybe-uninitialized',
7574
'-Werror=conversion-null',
7675
'-Werror=empty-body',
7776
],

engine/src/block.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ IO_stat MCBlock::load(IO_handle stream, uint32_t version, bool is_ext)
169169

170170
// MW-2012-03-04: [[ StackFile5500 ]] If this is an extended block, then work out
171171
// where to skip to when all the attrs currently recognized have been read.
172-
int64_t t_attr_end;
172+
int64_t t_attr_end = 0;
173173
if (is_ext)
174174
{
175175
// Read the size.

engine/src/buttondraw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ void MCButton::draw(MCDC *dc, const MCRectangle& p_dirty, bool p_isolated, bool
377377

378378
// MW-2009-06-14: We will assume (perhaps unwisely) that is 'opaque' is set
379379
// then the background is now, completely opaque.
380-
bool t_was_opaque;
380+
bool t_was_opaque = false;
381381
if (getflag(F_OPAQUE))
382382
t_was_opaque = dc -> changeopaque(true);
383383

engine/src/deploy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ void MCIdeDeploy::exec_ctxt(MCExecContext& ctxt)
858858
t_has_error = true;
859859
}
860860

861-
uint32_t t_platform;
861+
uint32_t t_platform = PLATFORM_NONE;
862862
switch(m_platform)
863863
{
864864
case PLATFORM_MACOSX:

engine/src/deploy_linux.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,7 @@ static bool MCDeployToLinuxReadProgramHeaders(MCDeployFileRef p_file, typename T
548548
template<typename T>
549549
static bool MCDeployToLinuxReadString(MCDeployFileRef p_file, typename T::Shdr& p_string_header, uint32_t p_index, char*& r_string)
550550
{
551-
bool t_success;
552-
t_success = true;
551+
bool t_success = true;
553552

554553
// First check that the index is valid
555554
if (p_index >= p_string_header . sh_size)
@@ -558,11 +557,9 @@ static bool MCDeployToLinuxReadString(MCDeployFileRef p_file, typename T::Shdr&
558557
// As the string table does not contain any string lengths and they are
559558
// just NUL terminated, we must gradually load portions until a NUL is
560559
// reached.
561-
char *t_buffer;
562-
uint32_t t_length;
563-
t_buffer = NULL;
564-
t_length = 0;
565-
560+
char *t_buffer = nullptr;
561+
uint32_t t_length = 0;
562+
566563
while(t_success)
567564
{
568565
// Compute how much data to read - this is either the fixed chunk
@@ -688,17 +685,15 @@ Exec_stat MCDeployToELF(const MCDeployParameters& p_params, bool p_is_android)
688685
t_payload_section = NULL;
689686
for(uint32_t i = 0; t_success && i < t_header . e_shnum && t_project_section == NULL; i++)
690687
{
691-
char *t_section_name;
692-
t_success = MCDeployToLinuxReadString<T>(t_engine, t_section_headers[t_header . e_shstrndx], t_section_headers[i] . sh_name, t_section_name);
688+
MCAutoPointer<char> t_section_name;
689+
t_success = MCDeployToLinuxReadString<T>(t_engine, t_section_headers[t_header . e_shstrndx], t_section_headers[i] . sh_name, &t_section_name);
693690

694691
// Notice that we compare 9 bytes, this is to ensure we match .project
695692
// only and not .project<otherchar> (i.e. we match the NUL char).
696-
if (t_success && memcmp(t_section_name, ".project", 9) == 0)
693+
if (t_success && memcmp(*t_section_name, ".project", 9) == 0)
697694
t_project_section = &t_section_headers[i];
698-
if (t_success && memcmp(t_section_name, ".payload", 9) == 0)
695+
if (t_success && memcmp(*t_section_name, ".payload", 9) == 0)
699696
t_payload_section = &t_section_headers[i];
700-
701-
delete t_section_name;
702697
}
703698

704699
if (t_success && t_project_section == NULL)

engine/src/field.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2522,7 +2522,7 @@ void MCField::draw(MCDC *dc, const MCRectangle& p_dirty, bool p_isolated, bool p
25222522

25232523
// MW-2009-06-14: If the field is opaque, then render the contents with that
25242524
// marked.
2525-
bool t_was_opaque;
2525+
bool t_was_opaque = false;
25262526
if (getflag(F_OPAQUE))
25272527
t_was_opaque = dc -> changeopaque(true);
25282528
drawrect(dc, dirty);

engine/src/fields.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ Exec_stat MCField::settextindex(uint4 parid, findex_t si, findex_t ei, MCStringR
701701
MCParagraph *t_initial_pgptr;
702702
t_initial_pgptr = pgptr;
703703

704-
int32_t t_initial_height;
704+
int32_t t_initial_height = 0;
705705
if (opened && fptr == fdata)
706706
t_initial_height = t_initial_pgptr -> getheight(fixedheight);
707707

@@ -780,7 +780,7 @@ Exec_stat MCField::settextindex(uint4 parid, findex_t si, findex_t ei, MCStringR
780780
// MM-2014-04-09: [[ Bug 12088 ]] Get the width of the paragraph before insertion and layout.
781781
// If as a result of the update the width of the field has changed, we need to recompute.
782782
// MW-2014-06-06: [[ Bug 12385 ]] Don't do anything layout related if not open.
783-
int2 t_initial_width;
783+
int2 t_initial_width = 0;
784784
if (opened != 0)
785785
t_initial_width = pgptr -> getwidth();
786786

engine/src/hc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,9 +674,9 @@ MCCdata *MCHctext::buildf(MCHcstak *hcsptr, MCField *parent)
674674
string = MCU_empty();
675675
char *eptr = string;
676676
MCParagraph *paragraphs = NULL;
677-
const char *tname;
678-
uint2 tsize;
679-
uint2 tstyle;
677+
const char *tname = nullptr;
678+
uint2 tsize = 0;
679+
uint2 tstyle = 0;
680680
uint2 aindex = 2;
681681
uint2 aoffset = 0;
682682
uint2 alength = 0;

engine/src/ibmp.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,8 @@ bool bmp_read_rle4_image(IO_handle p_stream, uindex_t &x_bytes_read, MCImageBitm
633633
else
634634
{
635635
// absolute mode
636-
uint8_t t_byte, t_upper, t_lower;
636+
uint8_t t_byte, t_upper;
637+
uint8_t t_lower = 0;
637638

638639
uint8_t t_run_buffer[128];
639640
uint32_t t_run_bytes;
@@ -1556,7 +1557,7 @@ bool MCNetPBMImageLoader::LoadFrames(MCBitmapFrame *&r_frames, uint32_t &r_count
15561557
uindex_t t_token_size;
15571558

15581559
bool t_binary;
1559-
uindex_t t_depth;
1560+
uindex_t t_depth = 1;
15601561
uindex_t t_channel_count = 1;
15611562
uindex_t t_stride;
15621563

engine/src/idraw.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,10 @@ void MCImage::drawwithgravity(MCDC *dc, MCRectangle r, MCGravity p_gravity)
285285
t_old_opacity = dc -> getopacity();
286286
dc -> setopacity(blendlevel * 255 / 100);
287287

288-
int2 dx, dy;
289-
uint2 dw, dh;
288+
int2 dx = 0;
289+
int2 dy = 0;
290+
uint2 dw = 0;
291+
uint2 dh = 0;
290292

291293
switch(p_gravity)
292294
{

0 commit comments

Comments
 (0)