Skip to content

Commit 28b7be1

Browse files
[[ ReturnType ]] Turn return-type warnings into errors.
Fix Linux compilation
1 parent 027e91c commit 28b7be1

File tree

12 files changed

+40
-13
lines changed

12 files changed

+40
-13
lines changed

config/android.gypi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
'-Wextra',
7474
'-Wno-unused-parameter', # Just contributes build noise
7575
'-Werror=uninitialized',
76+
'-Werror=return-type',
7677
],
7778

7879
'cflags_c':

config/ios.gypi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
'-Werror=declaration-after-statement',
173173
'-Wno-unused-parameter',
174174
'-Werror=uninitialized',
175+
'-Werror=return-type',
175176
],
176177
},
177178
},

config/linux.gypi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
'-Wextra',
9191
'-Wno-unused-parameter', # Just contributes build noise
9292
'-Werror=uninitialized',
93+
'-Werror=return-type',
9394
],
9495
},
9596
{

config/mac.gypi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
'-Werror=declaration-after-statement',
121121
'-Wno-unused-parameter',
122122
'-Werror=uninitialized',
123+
'-Werror=return-type',
123124
],
124125
},
125126
},

engine/src/chunk.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5883,7 +5883,7 @@ bool MCTextChunkIterator::next(MCExecContext& ctxt)
58835883
return true;
58845884

58855885
default:
5886-
assert(false);
5886+
MCUnreachableReturn(false);
58875887
}
58885888
}
58895889

engine/src/customprinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ static MCCustomPrinterImageType MCCustomPrinterImageTypeFromMCGRasterFormat(MCGR
125125
return kMCCustomPrinterImageRawXRGB;
126126
case kMCGRasterFormat_A:
127127
case kMCGRasterFormat_U_ARGB:
128+
default:
128129
// Unsupported
129-
MCAssert(false);
130-
return kMCCustomPrinterImageNone;
130+
MCUnreachableReturn(kMCCustomPrinterImageNone);
131131
}
132132
}
133133

engine/src/graphicscontext.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ static inline MCGBlendMode MCBitmapEffectBlendModeToMCGBlendMode(MCBitmapEffectB
7575
return kMCGBlendModeColor;
7676
case kMCBitmapEffectBlendModeLuminosity:
7777
return kMCGBlendModeLuminosity;
78+
default:
79+
MCUnreachableReturn(kMCGBlendModeSourceOver);
7880
}
7981
}
8082

engine/src/lnxaudio.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ int X11Audio::play(int1 * p_sample, uint4 p_samplesize, uint p_rate)
107107

108108
return t_bytes_written ;
109109
}
110+
111+
return 0;
110112
}
111113

112114

engine/src/mode_installer.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ class MCInternalPayloadOpen: public MCStatement
323323
// MM-2011-03-23: Takes a file path and memory maps its contents to r_payload_data, also returning the file size.
324324
static bool mmap_payload_from_file(const char *p_file_name, const void *&r_payload_data, uint32_t &r_payload_size)
325325
{
326+
bool t_success;
326327
#if defined(_MACOSX)
327328
// The OS X code is just refactored from the method funciton.
328329
s_payload_mapped_data = nil;
@@ -356,18 +357,19 @@ class MCInternalPayloadOpen: public MCStatement
356357
}
357358

358359
if (s_payload_mapped_data == nil && s_payload_loaded_data == nil)
359-
return false;
360-
361-
r_payload_data = s_payload_mapped_data != nil ? s_payload_mapped_data : s_payload_loaded_data;
362-
r_payload_size = s_payload_mapped_size;
363-
return true;
360+
t_succes = false;
361+
else
362+
{
363+
r_payload_data = s_payload_mapped_data != nil ? s_payload_mapped_data : s_payload_loaded_data;
364+
r_payload_size = s_payload_mapped_size;
365+
t_success = true;
366+
}
364367
#elif defined(_WINDOWS)
365368
s_payload_file_handle = nil;
366369
s_payload_file_map = nil;
367370
s_payload_mapped_data = nil;
368371

369-
// Fetch a handle to the file and map the contents to memory.
370-
bool t_success;
372+
// Fetch a handle to the file and map the contents to memory.
371373
t_success = true;
372374
if (t_success)
373375
{
@@ -401,9 +403,12 @@ class MCInternalPayloadOpen: public MCStatement
401403
CloseHandle(s_payload_file_map);
402404
if (s_payload_file_handle != INVALID_HANDLE_VALUE)
403405
CloseHandle(s_payload_file_handle);
404-
}
405-
return t_success;
406+
}
407+
#else
408+
t_success = false;
406409
#endif
410+
411+
return t_success;
407412
}
408413
};
409414

engine/src/stackview.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ MCGAffineTransform view_get_stack_transform(MCStackFullscreenMode p_mode, MCRect
313313
t_rect = MCU_center_rect(p_screen_rect, p_stack_rect);
314314
// IM-2013-12-19: [[ Bug 11590 ]] Adjust for screen rect origins other than 0,0
315315
return MCGAffineTransformMakeTranslation(t_rect.x - p_screen_rect.x, t_rect.y - p_screen_rect.y);
316+
default:
317+
MCUnreachableReturn(MCGAffineTransformMakeIdentity());
316318
}
317319
}
318320

0 commit comments

Comments
 (0)