Skip to content

Commit 5ce96e6

Browse files
[[ UninitialisedVars ]] Fixes for Mac Desktop compilation
Mainly, fixes: - sequences of if(<success>) missing some of the statement in the function body unprotected - switch of ifs over an enum, without a default behaviour when some enum elements where missed
1 parent 94abe21 commit 5ce96e6

File tree

13 files changed

+56
-23
lines changed

13 files changed

+56
-23
lines changed

engine/src/bsdiff_build.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ static bool bsdiffmain(MCBsDiffInputStream *p_old_file, MCBsDiffInputStream *p_n
231231
// if(argc!=4) errx(1,"usage: %s oldfile newfile patchfile\n",argv[0]);
232232
bool t_success;
233233
t_success = true;
234+
235+
V = NULL;
234236

235237
/* Allocate oldsize+1 bytes instead of oldsize bytes to ensure
236238
that we never try to malloc(0) and get a NULL pointer */
@@ -258,11 +260,11 @@ static bool bsdiffmain(MCBsDiffInputStream *p_old_file, MCBsDiffInputStream *p_n
258260
if (t_success)
259261
t_success = MCMemoryNewArray(oldsize + 1, V);
260262

261-
262-
qsufsort(I,V,old,oldsize);
263+
if (t_success)
264+
qsufsort(I,V,old,oldsize);
263265

264266
/*free(V);*/
265-
MCMemoryDeleteArray(V);
267+
MCMemoryDeleteArray(V);
266268

267269
/* Allocate newsize+1 bytes instead of newsize bytes to ensure
268270
that we never try to malloc(0) and get a NULL pointer */
@@ -329,7 +331,7 @@ static bool bsdiffmain(MCBsDiffInputStream *p_old_file, MCBsDiffInputStream *p_n
329331
errx(1, "BZ2_bzWriteOpen, bz2err = %d", bz2err);*/
330332
scan=0;len=0;
331333
lastscan=0;lastpos=0;lastoffset=0;
332-
while(scan<newsize && t_success) {
334+
while(t_success && scan<newsize) {
333335
oldscore=0;
334336

335337
for(scsc=scan+=len;scan<newsize;scan++) {

engine/src/combiners.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,8 @@ template<Operation x_combiner, bool x_dst_alpha, bool x_src_alpha> INLINE uint32
401401
case OPERATION_SET:
402402
r = 0x00ffffff;
403403
break;
404+
default:
405+
MCAssert(false);
404406
}
405407

406408
if (x_src_alpha && x_dst_alpha)
@@ -531,6 +533,8 @@ template<int x_combiner, bool x_dst_alpha, bool x_src_alpha> INLINE uint32_t ari
531533
r = rr | rg | rb;
532534
}
533535
break;
536+
default:
537+
MCAssert(false);
534538
}
535539

536540
if (x_src_alpha && x_dst_alpha)
@@ -643,6 +647,8 @@ template<int x_combiner, bool x_dst_alpha, bool x_src_alpha> INLINE uint32_t bas
643647
case OPERATION_BLEND_SCREEN:
644648
r = packed_multiply_bounded(src, packed_inverse(dst)) + dst;
645649
break;
650+
default:
651+
MCAssert(false);
646652
}
647653

648654
return r;
@@ -867,6 +873,8 @@ template<int x_combiner, bool x_dst_alpha, bool x_src_alpha> INLINE uint32_t adv
867873
t_blue = downscale(t_src_blue * (t_dst_alpha - t_dst_blue) + t_dst_blue * (t_src_alpha - t_src_blue) + t_inv_dst_alpha_src_blue + t_inv_src_alpha_dst_blue);
868874
t_alpha = t_src_alpha + t_dst_alpha - downscale(t_src_alpha_dst_alpha);
869875
break;
876+
default:
877+
MCAssert(false);
870878
}
871879

872880
if (x_dst_alpha)

engine/src/deploy.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,16 +1091,20 @@ void MCIdeExtract::exec_ctxt(MCExecContext& ctxt)
10911091
uint32_t t_data_size;
10921092
Exec_stat t_stat;
10931093
if (!ctxt . HasError())
1094+
{
10941095
t_stat = MCDeployExtractMacOSX(*t_filename, *t_segment, *t_section, t_data, t_data_size);
10951096

1096-
if (t_stat == ES_NORMAL)
1097-
{
1098-
MCAutoStringRef t_string;
1099-
/* UNCHECKED */ MCStringCreateWithNativeChars((const char_t*)t_data, t_data_size, &t_string);
1100-
ctxt . SetItToValue(*t_string);
1101-
}
1102-
else
1103-
ctxt . SetItToEmpty();
1097+
if (t_stat == ES_NORMAL)
1098+
{
1099+
MCAutoStringRef t_string;
1100+
/* UNCHECKED */ MCStringCreateWithNativeChars((const char_t*)t_data, t_data_size, &t_string);
1101+
ctxt . SetItToValue(*t_string);
1102+
return;
1103+
}
1104+
}
1105+
1106+
// Reach this if any error occurred
1107+
ctxt . SetItToEmpty();
11041108
}
11051109

11061110
////////////////////////////////////////////////////////////////////////////////

engine/src/desktop-stack.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ void MCStack::realize(void)
9292
MCPlatformWindowStyle t_window_style;;
9393
if (getflag(F_DECORATIONS) && (decorations & WD_UTILITY) != 0)
9494
t_window_style = kMCPlatformWindowStyleUtility;
95-
else if (mode == WM_PALETTE)
95+
else if (mode == WM_PALETTE
96+
|| mode == WM_DRAWER) // COCOA-TODO: Implement drawers
9697
t_window_style = kMCPlatformWindowStylePalette;
9798
else if (mode == WM_MODAL || mode == WM_SHEET)
9899
t_window_style = kMCPlatformWindowStyleDialog;
@@ -102,8 +103,6 @@ void MCStack::realize(void)
102103
t_window_style = kMCPlatformWindowStylePopUp;
103104
else if (mode == WM_TOOLTIP)
104105
t_window_style = kMCPlatformWindowStyleToolTip;
105-
else if (mode == WM_DRAWER)
106-
; // COCOA-TODO: Implement drawers
107106
else
108107
t_window_style = kMCPlatformWindowStyleDocument;
109108

engine/src/fieldrtf.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,8 @@ static bool export_rtf_emit_paragraphs(void *p_context, MCFieldExportEventType p
483483
t_char = 0x25AA, t_marker = "square";
484484
else if (t_list_style == kMCParagraphListStyleCircle)
485485
t_char = 0x25E6, t_marker = "circle";
486+
else // kMCParagraphListStyleNone
487+
return false;
486488
/* UNCHECKED */ MCStringAppendFormat(ctxt.m_text, "{\\listlevel\\levelnfc23\\leveljc0\\levelstartat1\\levelfollow0{\\*\\levelmarker \\{%s\\}}{\\leveltext\\'01\\u%d.;}{\\levelnumbers;}",
487489
t_marker, t_char);
488490
}

engine/src/ibmp.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,7 @@ bool MCImageDecodeBMPStruct(IO_handle p_stream, uindex_t &x_bytes_read, MCImageB
11031103
t_success = true;
11041104

11051105
MCBitmapStructImageLoader *t_loader;
1106+
t_loader = NULL;
11061107
if (t_success)
11071108
t_success = nil != (t_loader = new MCBitmapStructImageLoader(p_stream));
11081109

@@ -1976,11 +1977,11 @@ bool MCXBMImageLoader::LoadFrames(MCBitmapFrame *&r_frames, uint32_t &r_count)
19761977
if (t_success)
19771978
t_success = IO_ERROR != IO_fgets(m_line, XBM_MAX_LINE, t_stream);
19781979

1979-
uint8_t *t_dst_ptr = nil;
1980-
uindex_t t_stride = (t_width + 7) / 8;
1980+
uint8_t *t_dst_ptr = nil;
19811981

19821982
if (t_success)
1983-
{
1983+
{
1984+
uindex_t t_stride = (t_width + 7) / 8;
19841985
t_dst_ptr = (uint8_t*)t_frame->image->data;
19851986
t_success = MCMemoryAllocate(t_stride, t_row_buffer);
19861987
}

engine/src/iimport.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ bool MCImageImport(IO_handle p_stream, IO_handle p_mask_stream, MCPoint &r_hotsp
262262
t_frames = nil;
263263

264264
uint32_t t_count;
265+
t_count = 0;
265266

266267
if (t_success)
267268
t_success = t_loader->GetHotSpot(t_xhot, t_yhot);

engine/src/paragrafattr.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,11 @@ IO_stat MCParagraph::loadattrs(IO_handle stream, uint32_t version)
221221
t_stat = IO_read_uint2(&t_flags, stream);
222222

223223
// Initialize the paragraph attrs to default values.
224-
attrs = new MCParagraphAttrs;
225-
attrs -> flags = t_flags;
224+
if (t_stat == IO_NORMAL)
225+
{
226+
attrs = new MCParagraphAttrs;
227+
attrs -> flags = t_flags;
228+
}
226229

227230
// Now read each attribute in turn.
228231
if (t_stat == IO_NORMAL && (attrs -> flags & (PA_HAS_TEXT_ALIGN | PA_HAS_LIST_STYLE | PA_HAS_VGRID | PA_HAS_HGRID | PA_HAS_DONT_WRAP)) != 0)

engine/src/redraw.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ MCLayerModeHint MCControl::layer_computeattrs(bool p_commit)
211211
else
212212
t_layer_mode = kMCLayerModeHintStatic;
213213
}
214+
else
215+
MCAssert(false);
214216

215217
// Now compute the sprite attribute.
216218
bool t_is_sprite;

libcore/src/module.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ bool MCModuleGetFilename(MCModuleRef p_module, char*& r_path)
163163
bool MCModuleLoad(const char *p_filename, MCModuleRef& r_module)
164164
{
165165
MCModuleRef t_module;
166+
t_module = NULL;
166167
if (MCCStringEndsWith(p_filename, ".dylib"))
167168
{
168169
t_module = (void *)dlopen(p_filename, (RTLD_NOW | RTLD_LOCAL));

0 commit comments

Comments
 (0)