Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 7ae403a

Browse files
authored
Merge pull request #5461 from livecodeali/maybe-uninitialized
Remove -Wno-error=maybe-uninitialized
2 parents 8e80a70 + 86470dd commit 7ae403a

19 files changed

+112
-120
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/bitmapeffect.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -678,10 +678,6 @@ bool MCBitmapEffectsGetProperty(MCExecContext& ctxt, MCBitmapEffectsRef& self, M
678678
t_effect = &self -> effects[t_type];
679679
else
680680
t_effect = nil;
681-
682-
MCBitmapEffectProperty t_prop;
683-
if (!MCNameIsEmpty(p_index) && MCBitmapEffectLookupProperty(t_type, p_index, t_prop) != ES_NORMAL)
684-
return false;
685681

686682
if (t_is_array)
687683
{
@@ -716,6 +712,10 @@ bool MCBitmapEffectsGetProperty(MCExecContext& ctxt, MCBitmapEffectsRef& self, M
716712
}
717713
else
718714
{
715+
MCBitmapEffectProperty t_prop;
716+
if (MCBitmapEffectLookupProperty(t_type, p_index,
717+
t_prop) != ES_NORMAL)
718+
return false;
719719
MCBitmapEffectFetchProperty(ctxt, t_effect, t_prop, r_value);
720720
return true;
721721
}
@@ -983,7 +983,6 @@ bool MCBitmapEffectsSetProperty(MCExecContext& ctxt, MCBitmapEffectsRef& self, M
983983
return true;
984984
}
985985

986-
MCBitmapEffectProperty t_prop;
987986
MCBitmapEffect effect;
988987
bool t_dirty;
989988

@@ -1003,10 +1002,6 @@ bool MCBitmapEffectsSetProperty(MCExecContext& ctxt, MCBitmapEffectsRef& self, M
10031002
t_dirty = true;
10041003
}
10051004

1006-
// Lookup the property and ensure it is appropriate for our type.
1007-
if (!MCNameIsEmpty(p_index) && MCBitmapEffectLookupProperty(t_type, p_index, t_prop) != ES_NORMAL)
1008-
return false;
1009-
10101005
if (t_is_array)
10111006
{
10121007
bool t_dirty_array;
@@ -1035,8 +1030,15 @@ bool MCBitmapEffectsSetProperty(MCExecContext& ctxt, MCBitmapEffectsRef& self, M
10351030

10361031
}
10371032
else
1033+
{
1034+
MCBitmapEffectProperty t_prop;
1035+
if (MCBitmapEffectLookupProperty(t_type, p_index,
1036+
t_prop) != ES_NORMAL)
1037+
return false;
1038+
10381039
MCBitmapEffectStoreProperty(ctxt, effect, t_prop, p_value, t_dirty);
1039-
1040+
}
1041+
10401042
if (t_dirty)
10411043
{
10421044
// If we are currently empty, then allocate a new object

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
@@ -882,7 +882,7 @@ void MCIdeDeploy::exec_ctxt(MCExecContext& ctxt)
882882
t_has_error = true;
883883
}
884884

885-
uint32_t t_platform;
885+
uint32_t t_platform = PLATFORM_NONE;
886886
switch(m_platform)
887887
{
888888
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
@@ -2523,7 +2523,7 @@ void MCField::draw(MCDC *dc, const MCRectangle& p_dirty, bool p_isolated, bool p
25232523

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

engine/src/fields.cpp

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

709-
int32_t t_initial_height;
709+
int32_t t_initial_height = 0;
710710
if (opened && fptr == fdata)
711711
t_initial_height = t_initial_pgptr -> getheight(fixedheight);
712712

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

engine/src/graphicscontext.cpp

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -782,10 +782,10 @@ void MCGraphicsContext::setgradient(MCGradientFill *p_gradient)
782782
break;
783783
}
784784

785-
MCGFloat *t_stops;
786-
/* UNCHECKED */ MCMemoryNewArray(p_gradient -> ramp_length, t_stops);
787-
MCGColor *t_colors;
788-
/* UNCHECKED */ MCMemoryNewArray(p_gradient -> ramp_length, t_colors);
785+
/* UNCHECKED */ MCAutoPointer<MCGFloat[]> t_stops =
786+
new MCGFloat[p_gradient->ramp_length]();
787+
/* UNCHECKED */ MCAutoPointer<MCGColor[]> t_colors =
788+
new MCGColor[p_gradient->ramp_length]();
789789
for (uint32_t i = 0; i < p_gradient -> ramp_length; i++)
790790
{
791791
t_stops[i] = (MCGFloat) p_gradient -> ramp[i] . offset / STOP_INT_MAX;
@@ -800,11 +800,8 @@ void MCGraphicsContext::setgradient(MCGradientFill *p_gradient)
800800
t_transform . tx = p_gradient -> origin . x;
801801
t_transform . ty = p_gradient -> origin . y;
802802

803-
MCGContextSetFillGradient(m_gcontext, t_function, t_stops, t_colors, p_gradient -> ramp_length, p_gradient -> mirror, p_gradient -> wrap, p_gradient -> repeat, t_transform, t_filter);
804-
MCGContextSetStrokeGradient(m_gcontext, t_function, t_stops, t_colors, p_gradient -> ramp_length, p_gradient -> mirror, p_gradient -> wrap, p_gradient -> repeat, t_transform, t_filter);
805-
806-
MCMemoryDeleteArray(t_stops);
807-
MCMemoryDeleteArray(t_colors);
803+
MCGContextSetFillGradient(m_gcontext, t_function, t_stops.Get(), t_colors.Get(), p_gradient -> ramp_length, p_gradient -> mirror, p_gradient -> wrap, p_gradient -> repeat, t_transform, t_filter);
804+
MCGContextSetStrokeGradient(m_gcontext, t_function, t_stops.Get(), t_colors.Get(), p_gradient -> ramp_length, p_gradient -> mirror, p_gradient -> wrap, p_gradient -> repeat, t_transform, t_filter);
808805
}
809806
}
810807

@@ -1011,36 +1008,32 @@ void MCGraphicsContext::drawlines(MCPoint *points, uint2 npoints, bool p_closed)
10111008
else
10121009
{
10131010
// MM-2013-11-14: [[ Bug 11457 ]] Adjust lines and polygons to make sure antialiased lines don't draw across pixels.
1014-
MCGPoint *t_points;
1015-
/* UNCHECKED */ MCMemoryNewArray(npoints, t_points);
1011+
/* UNCHECKED */ MCAutoPointer<MCGPoint[]> t_points =
1012+
new MCGPoint[npoints]();
10161013
for (uint32_t i = 0; i < npoints; i++)
10171014
t_points[i] = MCPointToMCGPoint(points[i], 0.5f);
10181015

10191016
MCGContextBeginPath(m_gcontext);
10201017
if (p_closed)
1021-
MCGContextAddPolygon(m_gcontext, t_points, npoints);
1018+
MCGContextAddPolygon(m_gcontext, t_points.Get(), npoints);
10221019
else
1023-
MCGContextAddPolyline(m_gcontext, t_points, npoints);
1020+
MCGContextAddPolyline(m_gcontext, t_points.Get(), npoints);
10241021
MCGContextStroke(m_gcontext);
1025-
1026-
MCMemoryDeleteArray(t_points);
10271022
}
10281023
}
10291024

10301025
void MCGraphicsContext::fillpolygon(MCPoint *points, uint2 npoints)
10311026
{
10321027
// MM-2013-11-26: [[ Bug 11501 ]] Adjust lines and polygons to make sure antialiased lines don't draw across pixels.
10331028
// Here the adjust is 0.25 - not the same path as draw lines but appears to solve the issue where the fill interfers with the stroke.
1034-
MCGPoint *t_points;
1035-
/* UNCHECKED */ MCMemoryNewArray(npoints, t_points);
1029+
/* UNCHECKED */ MCAutoPointer<MCGPoint[]> t_points =
1030+
new MCGPoint[npoints]();
10361031
for (uint32_t i = 0; i < npoints; i++)
10371032
t_points[i] = MCPointToMCGPoint(points[i], 0.25f);
10381033

10391034
MCGContextBeginPath(m_gcontext);
1040-
MCGContextAddPolygon(m_gcontext, t_points, npoints);
1035+
MCGContextAddPolygon(m_gcontext, t_points.Get(), npoints);
10411036
MCGContextFill(m_gcontext);
1042-
1043-
MCMemoryDeleteArray(t_points);
10441037
}
10451038

10461039
static MCGRectangle MCGRectangleInset(const MCGRectangle &p_rect, MCGFloat p_inset)

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;

0 commit comments

Comments
 (0)