Skip to content

Commit c028d2b

Browse files
committed
[[ Cleanup ]] Non-void functions should return a value or fail.
There are several cases where non-void functions dispatch on a switch statement which does not cover all possible values. Add a default clause which aborts in order to ensure that the switch statement does not fall through.
1 parent 9b73bcc commit c028d2b

4 files changed

Lines changed: 10 additions & 0 deletions

File tree

engine/src/customprinter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ static MCCustomPrinterImageType MCCustomPrinterImageTypeFromMCGRasterFormat(MCGR
128128
// Unsupported
129129
MCAssert(false);
130130
return kMCCustomPrinterImageNone;
131+
default:
132+
MCUnreachable();
131133
}
132134
}
133135

engine/src/graphicscontext.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ static inline MCGBlendMode MCBitmapEffectBlendModeToMCGBlendMode(MCBitmapEffectB
5959
return kMCGBlendModeColor;
6060
case kMCBitmapEffectBlendModeLuminosity:
6161
return kMCGBlendModeLuminosity;
62+
default:
63+
MCUnreachable();
6264
}
6365
}
6466

engine/src/stackview.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ 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+
317+
default:
318+
MCUnreachable();
316319
}
317320
}
318321

libgraphics/include/graphics.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ static inline uint32_t MCGPixelPack(MCGPixelFormat p_format, uint8_t p_red, uint
8282

8383
case kMCGPixelFormatARGB:
8484
return __MCGPixelPackComponents(p_alpha, p_red, p_green, p_blue);
85+
86+
default:
87+
MCUnreachable();
8588
}
8689
}
8790

0 commit comments

Comments
 (0)