From 95b953d53669e0a6139c9e00e6b79d961cfcbbda Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Fri, 25 Jan 2019 22:17:26 +0000 Subject: [PATCH] Bug 1521694 - Make DisplaySystemMenu() handle all nsSizeMode value r=jmathies DisplaySystemMenu() does not handle nsSizeMode_Invalid that causes warning of clang. This patch makes it treat nsSizeMode_Invalid. When it receives the value, it will call NS_ASSERTION() to be detectable on debug builds during automated tests. Additionally, this adds default case into the switch statement with MOZ_ASSERT_UNREACHABLE(). Then, when somebody adds new nsSizeMode, they can detect it with crash in debug build if they forget to change this method. Differential Revision: https://phabricator.services.mozilla.com/D17217 --HG-- extra : moz-landing-system : lando --- widget/windows/nsWindow.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 5161a680ef33..0cb433104dd3 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -4699,6 +4699,12 @@ static bool DisplaySystemMenu(HWND hWnd, nsSizeMode sizeMode, bool isRtl, case nsSizeMode_Normal: SetMenuItemInfo(hMenu, SC_RESTORE, FALSE, &mii); break; + case nsSizeMode_Invalid: + NS_ASSERTION(false, "Did the argument come from invalid IPC?"); + break; + default: + MOZ_ASSERT_UNREACHABLE("Unhnalded nsSizeMode value detected"); + break; } LPARAM cmd = TrackPopupMenu( hMenu,